Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / component_updater / supervised_user_whitelist_installer.h
blob48157134a034b1341f68c32a0b282119228cf1f7
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_SUPERVISED_USER_WHITELIST_INSTALLER_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_SUPERVISED_USER_WHITELIST_INSTALLER_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/callback_forward.h"
13 #include "base/memory/scoped_ptr.h"
15 namespace base {
16 class FilePath;
19 class PrefRegistrySimple;
20 class PrefService;
21 class ProfileInfoCache;
23 namespace component_updater {
25 class ComponentUpdateService;
26 class OnDemandUpdater;
28 class SupervisedUserWhitelistInstaller {
29 public:
30 using WhitelistReadyCallback =
31 base::Callback<void(const std::string& crx_id,
32 const base::FilePath& whitelist_path)>;
34 virtual ~SupervisedUserWhitelistInstaller() {}
36 static scoped_ptr<SupervisedUserWhitelistInstaller> Create(
37 ComponentUpdateService* cus,
38 ProfileInfoCache* profile_info_cache,
39 PrefService* local_state);
41 static void RegisterPrefs(PrefRegistrySimple* registry);
43 // Generates a client ID suitable for RegisterWhitelist() and
44 // UnregisterWhitelist() below from a profile path.
45 static std::string ClientIdForProfilePath(const base::FilePath& profile_path);
47 // Turns a CRX ID (which is derived from a hash) back into a hash.
48 // Note that the resulting hash will be only 16 bytes long instead of the
49 // usual 32 bytes, as the CRX ID is created from the first half of the
50 // original hash, but the component installer will still accept this.
51 // Public for testing.
52 static std::vector<uint8_t> GetHashFromCrxId(const std::string& crx_id);
54 // Starts registering all components with the ComponentUpdaterService.
55 // Also removes unregistered components on disk (which are most likely left
56 // over from a previous uninstallation that was interrupted, e.g. during
57 // shutdown or a crash).
58 virtual void RegisterComponents() = 0;
60 // Subscribes for notifications about available whitelists. Clients should
61 // filter out the whitelists they are interested in via the |crx_id|
62 // parameter.
63 virtual void Subscribe(const WhitelistReadyCallback& callback) = 0;
65 // Registers a new whitelist with the given |crx_id|.
66 // The |client_id| should be a unique identifier for the client that is stable
67 // across restarts.
68 virtual void RegisterWhitelist(const std::string& client_id,
69 const std::string& crx_id,
70 const std::string& name) = 0;
72 // Unregisters a whitelist.
73 virtual void UnregisterWhitelist(const std::string& client_id,
74 const std::string& crx_id) = 0;
76 protected:
77 // Triggers an update for a whitelist to be installed. Protected so it can be
78 // called from the implementation subclass, and declared here so that the
79 // OnDemandUpdater can friend this class and the implementation subclass can
80 // live in an anonymous namespace.
81 static void TriggerComponentUpdate(OnDemandUpdater* updater,
82 const std::string& crx_id);
85 } // namespace component_updater
87 #endif // CHROME_BROWSER_COMPONENT_UPDATER_SUPERVISED_USER_WHITELIST_INSTALLER_H_