OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_MANAGED_MODE_MANAGED_MODE_H_ | 5 #ifndef CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 6 #define CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 10 matching lines...) Expand all Loading... | |
21 class Browser; | 21 class Browser; |
22 template<typename T> | 22 template<typename T> |
23 struct DefaultSingletonTraits; | 23 struct DefaultSingletonTraits; |
24 class ManagedModeSiteList; | 24 class ManagedModeSiteList; |
25 class ManagedModeURLFilter; | 25 class ManagedModeURLFilter; |
26 class PrefChangeRegistrar; | 26 class PrefChangeRegistrar; |
27 class PrefServiceSimple; | 27 class PrefServiceSimple; |
28 class PrefServiceSyncable; | 28 class PrefServiceSyncable; |
29 class Profile; | 29 class Profile; |
30 | 30 |
31 namespace policy{ | |
32 class URLBlacklist; | |
33 } | |
34 | |
31 // Managed mode allows one person to manage the Chrome experience for another | 35 // Managed mode allows one person to manage the Chrome experience for another |
32 // person by pre-configuring and then locking a managed User profile. | 36 // person by pre-configuring and then locking a managed User profile. |
33 // The ManagedMode class provides methods to check whether the browser is in | 37 // The ManagedMode class provides methods to check whether the browser is in |
34 // managed mode, and to attempt to enter or leave managed mode. | 38 // managed mode, and to attempt to enter or leave managed mode. |
35 // Except where otherwise noted, this class should be used on the UI thread. | 39 // Except where otherwise noted, this class should be used on the UI thread. |
36 class ManagedMode : public chrome::BrowserListObserver, | 40 class ManagedMode : public chrome::BrowserListObserver, |
37 public extensions::ManagementPolicy::Provider, | 41 public extensions::ManagementPolicy::Provider, |
38 public content::NotificationObserver { | 42 public content::NotificationObserver { |
39 public: | 43 public: |
40 typedef base::Callback<void(bool)> EnterCallback; | 44 typedef base::Callback<void(bool)> EnterCallback; |
45 typedef base::ListValue URLPatternList; | |
41 | 46 |
42 static void RegisterPrefs(PrefServiceSimple* prefs); | 47 static void RegisterPrefs(PrefServiceSimple* prefs); |
43 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | 48 static void RegisterUserPrefs(PrefServiceSyncable* prefs); |
44 | 49 |
45 // Initializes the singleton, setting the managed_profile_. Must be called | 50 // Initializes the singleton, setting the managed_profile_. Must be called |
46 // after g_browser_process and the LocalState have been created. | 51 // after g_browser_process and the LocalState have been created. |
47 static void Init(Profile* profile); | 52 static void Init(Profile* profile); |
48 static bool IsInManagedMode(); | 53 static bool IsInManagedMode(); |
49 | 54 |
50 // Calls |callback| with the argument true iff managed mode was entered | 55 // Calls |callback| with the argument true iff managed mode was entered |
51 // sucessfully. | 56 // sucessfully. |
52 static void EnterManagedMode(Profile* profile, const EnterCallback& callback); | 57 static void EnterManagedMode(Profile* profile, const EnterCallback& callback); |
53 static void LeaveManagedMode(); | 58 static void LeaveManagedMode(); |
54 | 59 |
55 // Returns the URL filter for the IO thread, for filtering network requests | 60 // Returns the URL filter for the IO thread, for filtering network requests |
56 // (in ChromeNetworkDelegate). | 61 // (in ChromeNetworkDelegate). |
57 // This method should only be called on the IO thread. | 62 // This method should only be called on the IO thread. |
58 static const ManagedModeURLFilter* GetURLFilterForIOThread(); | 63 static const ManagedModeURLFilter* GetURLFilterForIOThread(); |
59 | 64 |
60 // Returns the URL filter for the UI thread, for filtering navigations and | 65 // Returns the URL filter for the UI thread, for filtering navigations and |
61 // classifying sites in the history view. | 66 // classifying sites in the history view. |
62 // This method should only be called on the UI thread. | 67 // This method should only be called on the UI thread. |
63 static const ManagedModeURLFilter* GetURLFilterForUIThread(); | 68 static const ManagedModeURLFilter* GetURLFilterForUIThread(); |
64 | 69 |
70 // The functions that handle manual whitelists use |url_pattern| or lists | |
71 // of "url patterns". An "url pattern" is a pattern in the format used by the | |
72 // URLBlacklist filter. A description of the format used can be found here: | |
Bernhard Bauer
2013/01/07 12:34:19
Nit: policy::URLBacklist is the fully qualified cl
Sergiu
2013/01/07 16:25:05
Done.
| |
73 // http://dev.chromium.org/administrators/url-blacklist-filter-format | |
74 | |
75 // Checks if the |url_pattern| is in the manual whitelist. | |
76 static bool IsInManualList(const bool isWhitelist, | |
Pam (message me for reviews)
2013/01/07 13:00:16
Style nit: is_whitelist (also below)
Comment nit:
Sergiu
2013/01/07 16:25:05
Done.
| |
77 const std::string& url_pattern); | |
78 | |
79 // Appends |list| to the manual white/black list (according to |isWhitelist|) | |
80 // both in URL filter and in preferences. | |
81 static void AddToManualList(const bool isWhitelist, | |
82 const URLPatternList& list); | |
83 | |
84 // Removes |list| from the manual white/black list (according to | |
85 // |isWhitelist|) both in URL filter and in preferences. | |
86 static void RemoveFromManualList(const bool isWhitelist, | |
87 const URLPatternList& list); | |
88 | |
89 // Updates the whitelist and the blacklist from the prefs. | |
90 static void UpdateWhitelist(); | |
Pam (message me for reviews)
2013/01/07 13:00:16
If this updates both the white- and blacklists, it
Sergiu
2013/01/07 16:25:05
Done, renamed to UpdateManualLists to fit with the
| |
91 | |
92 // Returns the profile blacklist. | |
93 static scoped_ptr<URLPatternList> GetBlacklist(); | |
94 | |
65 // ExtensionManagementPolicy::Provider implementation: | 95 // ExtensionManagementPolicy::Provider implementation: |
66 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 96 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
67 virtual bool UserMayLoad(const extensions::Extension* extension, | 97 virtual bool UserMayLoad(const extensions::Extension* extension, |
68 string16* error) const OVERRIDE; | 98 string16* error) const OVERRIDE; |
69 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 99 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
70 string16* error) const OVERRIDE; | 100 string16* error) const OVERRIDE; |
71 | 101 |
72 // chrome::BrowserListObserver implementation: | 102 // chrome::BrowserListObserver implementation: |
73 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 103 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
74 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 104 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 // testing). | 155 // testing). |
126 virtual void SetInManagedMode(Profile* newly_managed_profile); | 156 virtual void SetInManagedMode(Profile* newly_managed_profile); |
127 | 157 |
128 // Returns a list of all installed and enabled site lists in the current | 158 // Returns a list of all installed and enabled site lists in the current |
129 // managed profile. | 159 // managed profile. |
130 // This method should only be called if managed mode is active. | 160 // This method should only be called if managed mode is active. |
131 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); | 161 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); |
132 | 162 |
133 void OnDefaultFilteringBehaviorChanged(); | 163 void OnDefaultFilteringBehaviorChanged(); |
134 | 164 |
135 void UpdateWhitelist(); | 165 void UpdateWhitelistImpl(); |
166 | |
167 // Returns a copy of the manual whitelist which is stored in each profile. | |
168 scoped_ptr<URLPatternList> GetWhitelist(); | |
169 | |
170 void RemoveFromManualListImpl(const bool isWhitelist, | |
171 const URLPatternList& whitelist); | |
172 | |
173 // Adds the |url_pattern| to the manual lists in the URL filter. This is used | |
174 // by AddToManualListImpl(). | |
175 static void AddURLPatternToManualList(const bool isWhitelist, | |
Bernhard Bauer
2013/01/07 12:34:19
Can you move this method to an anonymous namespace
Sergiu
2013/01/07 16:25:05
It shouldn't have been static at all, made it just
| |
176 const std::string& url_pattern); | |
177 | |
178 void AddToManualListImpl(const bool isWhitelist, | |
179 const URLPatternList& whitelist); | |
180 | |
181 bool IsInManualListImpl(const bool isWhitelist, | |
182 const std::string& url_pattern); | |
136 | 183 |
137 content::NotificationRegistrar registrar_; | 184 content::NotificationRegistrar registrar_; |
138 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 185 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
139 | 186 |
140 scoped_ptr<URLFilterContext> io_url_filter_context_; | 187 scoped_ptr<URLFilterContext> io_url_filter_context_; |
141 scoped_ptr<URLFilterContext> ui_url_filter_context_; | 188 scoped_ptr<URLFilterContext> ui_url_filter_context_; |
142 | 189 |
143 std::set<Browser*> browsers_to_close_; | 190 std::set<Browser*> browsers_to_close_; |
144 std::vector<EnterCallback> callbacks_; | 191 std::vector<EnterCallback> callbacks_; |
145 | 192 |
146 DISALLOW_COPY_AND_ASSIGN(ManagedMode); | 193 DISALLOW_COPY_AND_ASSIGN(ManagedMode); |
147 }; | 194 }; |
148 | 195 |
149 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 196 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
OLD | NEW |