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; |
(...skipping 14 matching lines...) Expand all Loading... | |
55 // Returns the URL filter for the IO thread, for filtering network requests | 59 // Returns the URL filter for the IO thread, for filtering network requests |
56 // (in ChromeNetworkDelegate). | 60 // (in ChromeNetworkDelegate). |
57 // This method should only be called on the IO thread. | 61 // This method should only be called on the IO thread. |
58 static const ManagedModeURLFilter* GetURLFilterForIOThread(); | 62 static const ManagedModeURLFilter* GetURLFilterForIOThread(); |
59 | 63 |
60 // Returns the URL filter for the UI thread, for filtering navigations and | 64 // Returns the URL filter for the UI thread, for filtering navigations and |
61 // classifying sites in the history view. | 65 // classifying sites in the history view. |
62 // This method should only be called on the UI thread. | 66 // This method should only be called on the UI thread. |
63 static const ManagedModeURLFilter* GetURLFilterForUIThread(); | 67 static const ManagedModeURLFilter* GetURLFilterForUIThread(); |
64 | 68 |
69 // The functions that handle manual whitelists use |url_pattern| or lists | |
70 // of "url patterns". An "url pattern" is a pattern in the format used by the | |
71 // policy::URLBlacklist filter. A description of the format used can be found | |
72 // here: http://dev.chromium.org/administrators/url-blacklist-filter-format. | |
73 | |
74 // Checks if the |url_pattern| is in the manual whitelist. | |
Pam (message me for reviews)
2013/01/08 09:15:52
"...whitelist (if |is_whitelist| is true) or black
| |
75 static bool IsInManualList(const bool is_whitelist, | |
76 const std::string& url_pattern); | |
77 | |
78 // Appends |list| to the manual white/black list (according to |is_whitelist|) | |
79 // both in URL filter and in preferences. | |
80 static void AddToManualList(const bool is_whitelist, | |
81 const base::ListValue& list); | |
82 | |
83 // Removes |list| from the manual white/black list (according to | |
84 // |is_whitelist|) both in URL filter and in preferences. | |
85 static void RemoveFromManualList(const bool is_whitelist, | |
86 const base::ListValue& list); | |
87 | |
88 // Updates the whitelist and the blacklist from the prefs. | |
89 static void UpdateManualLists(); | |
90 | |
91 // Returns the profile blacklist. | |
92 static scoped_ptr<base::ListValue> GetBlacklist(); | |
93 | |
65 // ExtensionManagementPolicy::Provider implementation: | 94 // ExtensionManagementPolicy::Provider implementation: |
66 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 95 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
67 virtual bool UserMayLoad(const extensions::Extension* extension, | 96 virtual bool UserMayLoad(const extensions::Extension* extension, |
68 string16* error) const OVERRIDE; | 97 string16* error) const OVERRIDE; |
69 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 98 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
70 string16* error) const OVERRIDE; | 99 string16* error) const OVERRIDE; |
71 | 100 |
72 // chrome::BrowserListObserver implementation: | 101 // chrome::BrowserListObserver implementation: |
73 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 102 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
74 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 103 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 // testing). | 154 // testing). |
126 virtual void SetInManagedMode(Profile* newly_managed_profile); | 155 virtual void SetInManagedMode(Profile* newly_managed_profile); |
127 | 156 |
128 // Returns a list of all installed and enabled site lists in the current | 157 // Returns a list of all installed and enabled site lists in the current |
129 // managed profile. | 158 // managed profile. |
130 // This method should only be called if managed mode is active. | 159 // This method should only be called if managed mode is active. |
131 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); | 160 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); |
132 | 161 |
133 void OnDefaultFilteringBehaviorChanged(); | 162 void OnDefaultFilteringBehaviorChanged(); |
134 | 163 |
135 void UpdateWhitelist(); | 164 void UpdateManualListsImpl(); |
165 | |
166 // Returns a copy of the manual whitelist which is stored in each profile. | |
167 scoped_ptr<base::ListValue> GetWhitelist(); | |
168 | |
169 // The following functions use |is_whitelist| to select between the whitelist | |
170 // and the blacklist as the target of the function. If |is_whitelist| is true | |
171 // |url_pattern| is added to the whitelist, otherwise it is added to the | |
172 // blacklist. | |
173 | |
174 void RemoveFromManualListImpl(const bool is_whitelist, | |
175 const base::ListValue& whitelist); | |
176 | |
177 // Adds the |url_pattern| to the manual lists in the URL filter. This is used | |
178 // by AddToManualListImpl(). | |
179 void AddURLPatternToManualList(const bool is_whitelist, | |
180 const std::string& url_pattern); | |
181 | |
182 void AddToManualListImpl(const bool is_whitelist, | |
183 const base::ListValue& whitelist); | |
184 | |
185 bool IsInManualListImpl(const bool is_whitelist, | |
186 const std::string& url_pattern); | |
136 | 187 |
137 content::NotificationRegistrar registrar_; | 188 content::NotificationRegistrar registrar_; |
138 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 189 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
139 | 190 |
140 scoped_ptr<URLFilterContext> io_url_filter_context_; | 191 scoped_ptr<URLFilterContext> io_url_filter_context_; |
141 scoped_ptr<URLFilterContext> ui_url_filter_context_; | 192 scoped_ptr<URLFilterContext> ui_url_filter_context_; |
142 | 193 |
143 std::set<Browser*> browsers_to_close_; | 194 std::set<Browser*> browsers_to_close_; |
144 std::vector<EnterCallback> callbacks_; | 195 std::vector<EnterCallback> callbacks_; |
145 | 196 |
146 DISALLOW_COPY_AND_ASSIGN(ManagedMode); | 197 DISALLOW_COPY_AND_ASSIGN(ManagedMode); |
147 }; | 198 }; |
148 | 199 |
149 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 200 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
OLD | NEW |