| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_WHITELIST_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_WHITELIST_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_WHITELIST_SERVICE_H_ | 6 #define CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_WHITELIST_SERVICE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "chrome/browser/supervised_user/supervised_users.h" | 17 #include "chrome/browser/supervised_user/supervised_users.h" |
| 17 #include "sync/api/syncable_service.h" | 18 #include "sync/api/syncable_service.h" |
| 18 | 19 |
| 19 class PrefService; | 20 class PrefService; |
| 20 class SupervisedUserSiteList; | 21 class SupervisedUserSiteList; |
| 21 | 22 |
| 22 namespace base { | 23 namespace base { |
| 23 class DictionaryValue; | 24 class DictionaryValue; |
| 24 class FilePath; | 25 class FilePath; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // site lists. | 58 // site lists. |
| 58 void AddSiteListsChangedCallback(const SiteListsChangedCallback& callback); | 59 void AddSiteListsChangedCallback(const SiteListsChangedCallback& callback); |
| 59 | 60 |
| 60 // Returns a map (from CRX ID to name) of whitelists to be installed, | 61 // Returns a map (from CRX ID to name) of whitelists to be installed, |
| 61 // specified on the command line. | 62 // specified on the command line. |
| 62 static std::map<std::string, std::string> GetWhitelistsFromCommandLine(); | 63 static std::map<std::string, std::string> GetWhitelistsFromCommandLine(); |
| 63 | 64 |
| 64 // Loads an already existing whitelist on disk (i.e. without downloading it as | 65 // Loads an already existing whitelist on disk (i.e. without downloading it as |
| 65 // a component). | 66 // a component). |
| 66 void LoadWhitelistForTesting(const std::string& id, | 67 void LoadWhitelistForTesting(const std::string& id, |
| 68 const base::string16& title, |
| 67 const base::FilePath& path); | 69 const base::FilePath& path); |
| 68 | 70 |
| 69 // Unloads a whitelist. Public for testing. | 71 // Unloads a whitelist. Public for testing. |
| 70 void UnloadWhitelist(const std::string& id); | 72 void UnloadWhitelist(const std::string& id); |
| 71 | 73 |
| 72 // Creates Sync data for a whitelist with the given |id| and |name|. | 74 // Creates Sync data for a whitelist with the given |id| and |name|. |
| 73 // Public for testing. | 75 // Public for testing. |
| 74 static syncer::SyncData CreateWhitelistSyncData(const std::string& id, | 76 static syncer::SyncData CreateWhitelistSyncData(const std::string& id, |
| 75 const std::string& name); | 77 const std::string& name); |
| 76 | 78 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 105 void RegisterWhitelist(const std::string& id, | 107 void RegisterWhitelist(const std::string& id, |
| 106 const std::string& name, | 108 const std::string& name, |
| 107 WhitelistSource source); | 109 WhitelistSource source); |
| 108 | 110 |
| 109 void GetLoadedWhitelists( | 111 void GetLoadedWhitelists( |
| 110 std::vector<scoped_refptr<SupervisedUserSiteList>>* whitelists); | 112 std::vector<scoped_refptr<SupervisedUserSiteList>>* whitelists); |
| 111 | 113 |
| 112 void NotifyWhitelistsChanged(); | 114 void NotifyWhitelistsChanged(); |
| 113 | 115 |
| 114 void OnWhitelistReady(const std::string& id, | 116 void OnWhitelistReady(const std::string& id, |
| 117 const base::string16& title, |
| 115 const base::FilePath& whitelist_path); | 118 const base::FilePath& whitelist_path); |
| 116 void OnWhitelistLoaded( | 119 void OnWhitelistLoaded( |
| 117 const std::string& id, | 120 const std::string& id, |
| 118 base::TimeTicks start_time, | 121 base::TimeTicks start_time, |
| 119 const scoped_refptr<SupervisedUserSiteList>& whitelist); | 122 const scoped_refptr<SupervisedUserSiteList>& whitelist); |
| 120 | 123 |
| 121 PrefService* prefs_; | 124 PrefService* prefs_; |
| 122 component_updater::SupervisedUserWhitelistInstaller* installer_; | 125 component_updater::SupervisedUserWhitelistInstaller* installer_; |
| 123 | 126 |
| 124 std::string client_id_; | 127 std::string client_id_; |
| 125 std::vector<SiteListsChangedCallback> site_lists_changed_callbacks_; | 128 std::vector<SiteListsChangedCallback> site_lists_changed_callbacks_; |
| 126 | 129 |
| 127 // The set of registered whitelists. A whitelist might be registered but not | 130 // The set of registered whitelists. A whitelist might be registered but not |
| 128 // loaded yet, in which case it will not be in |loaded_whitelists_| yet. | 131 // loaded yet, in which case it will not be in |loaded_whitelists_| yet. |
| 129 // On the other hand, every loaded whitelist has to be registered. | 132 // On the other hand, every loaded whitelist has to be registered. |
| 130 std::set<std::string> registered_whitelists_; | 133 std::set<std::string> registered_whitelists_; |
| 131 std::map<std::string, scoped_refptr<SupervisedUserSiteList> > | 134 std::map<std::string, scoped_refptr<SupervisedUserSiteList> > |
| 132 loaded_whitelists_; | 135 loaded_whitelists_; |
| 133 | 136 |
| 134 base::WeakPtrFactory<SupervisedUserWhitelistService> weak_ptr_factory_; | 137 base::WeakPtrFactory<SupervisedUserWhitelistService> weak_ptr_factory_; |
| 135 | 138 |
| 136 DISALLOW_COPY_AND_ASSIGN(SupervisedUserWhitelistService); | 139 DISALLOW_COPY_AND_ASSIGN(SupervisedUserWhitelistService); |
| 137 }; | 140 }; |
| 138 | 141 |
| 139 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_WHITELIST_SERVICE_H_ | 142 #endif // CHROME_BROWSER_SUPERVISED_USER_SUPERVISED_USER_WHITELIST_SERVICE_H_ |
| OLD | NEW |