blob: 6220db402faae83e1b21c08782f73641ff6185b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
// Copyright 2022 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_POLICY_CORE_COMMON_DEFAULT_CHROME_APPS_MIGRATOR_H_
#define COMPONENTS_POLICY_CORE_COMMON_DEFAULT_CHROME_APPS_MIGRATOR_H_
#include <map>
#include <string>
#include "base/values.h"
#include "components/policy/core/common/policy_map.h"
namespace policy {
// This class is used as a temporary solution to handle force install policies
// for deprecated Chrome apps. It replaces ExtensionInstallForcelist policy
// for Chrome app with ExtensionInstallBlocklist for Chrome app and
// WebAppInstallForceList policy for the corresponding Web App. To preserve the
// pinning state, PinnedLauncherApps policy for Chrome app is replaced with the
// one for Web App.
// This code will be removed when the following steps are done:
// 1. Build discoverability for default apps in Admin panel (Dpanel).
// 2. Build new control logic for blocking installation (but not blocking use
// of) PWAs.
// 3. Migrate policy from Chrome Apps to PWAs in Admin surface (DMServer).
class POLICY_EXPORT DefaultChromeAppsMigrator {
public:
DefaultChromeAppsMigrator();
explicit DefaultChromeAppsMigrator(
std::map<std::string, std::string> chrome_app_to_web_app);
DefaultChromeAppsMigrator(const DefaultChromeAppsMigrator&) = delete;
DefaultChromeAppsMigrator& operator=(const DefaultChromeAppsMigrator&) =
delete;
DefaultChromeAppsMigrator(DefaultChromeAppsMigrator&&) noexcept;
DefaultChromeAppsMigrator& operator=(DefaultChromeAppsMigrator&&) noexcept;
~DefaultChromeAppsMigrator();
// Replaces ExtensionInstallForcelist policy for Chrome apps listed in
// `chrome_app_to_web_app_`.
void Migrate(PolicyMap* policies) const;
private:
// Removes chrome apps listed in `chrome_app_to_web_app_` from
// ExtensionInstallForcelist policy. Returns ids of removed apps.
std::vector<std::string> RemoveChromeAppsFromExtensionForcelist(
PolicyMap* policies) const;
// Checks that policy value type is list. If not, adds error message to the
// policy entry and overrides policy value with an empty list.
void EnsurePolicyValueIsList(PolicyMap* policies,
const std::string& policy_name) const;
// Replaces policy to pin Chrome app from `chrome_app_to_web_app_` with policy
// to pin corresponding Web App. It only changes PinnedLauncherApps policy,
// which specifies pinned apps on Chrome OS.
void MigratePinningPolicy(PolicyMap* policies) const;
// Maps from ids of Chrome apps that need to be replaced to Web App urls.
std::map<std::string, std::string> chrome_app_to_web_app_;
};
} // namespace policy
#endif // COMPONENTS_POLICY_CORE_COMMON_DEFAULT_CHROME_APPS_MIGRATOR_H_
|