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 // They all receive the |is_whitelist| parameter which dictates whether they |
| 74 // act on the whitelist (for |is_whitelist| == true) or on the blacklist (for |
| 75 // |is_whitelist| == false). |
| 76 |
| 77 // Checks if the |url_pattern| is in the manual whitelist. |
| 78 static bool IsInManualList(const bool is_whitelist, |
| 79 const std::string& url_pattern); |
| 80 |
| 81 // Appends |list| to the manual white/black list (according to |is_whitelist|) |
| 82 // both in URL filter and in preferences. |
| 83 static void AddToManualList(const bool is_whitelist, |
| 84 const base::ListValue& list); |
| 85 |
| 86 // Removes |list| from the manual white/black list (according to |
| 87 // |is_whitelist|) both in URL filter and in preferences. |
| 88 static void RemoveFromManualList(const bool is_whitelist, |
| 89 const base::ListValue& list); |
| 90 |
| 91 // Updates the whitelist and the blacklist from the prefs. |
| 92 static void UpdateManualLists(); |
| 93 |
| 94 // Returns the profile blacklist. |
| 95 static scoped_ptr<base::ListValue> GetBlacklist(); |
| 96 |
65 // ExtensionManagementPolicy::Provider implementation: | 97 // ExtensionManagementPolicy::Provider implementation: |
66 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 98 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
67 virtual bool UserMayLoad(const extensions::Extension* extension, | 99 virtual bool UserMayLoad(const extensions::Extension* extension, |
68 string16* error) const OVERRIDE; | 100 string16* error) const OVERRIDE; |
69 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 101 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
70 string16* error) const OVERRIDE; | 102 string16* error) const OVERRIDE; |
71 | 103 |
72 // chrome::BrowserListObserver implementation: | 104 // chrome::BrowserListObserver implementation: |
73 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 105 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
74 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 106 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 // testing). | 157 // testing). |
126 virtual void SetInManagedMode(Profile* newly_managed_profile); | 158 virtual void SetInManagedMode(Profile* newly_managed_profile); |
127 | 159 |
128 // Returns a list of all installed and enabled site lists in the current | 160 // Returns a list of all installed and enabled site lists in the current |
129 // managed profile. | 161 // managed profile. |
130 // This method should only be called if managed mode is active. | 162 // This method should only be called if managed mode is active. |
131 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); | 163 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); |
132 | 164 |
133 void OnDefaultFilteringBehaviorChanged(); | 165 void OnDefaultFilteringBehaviorChanged(); |
134 | 166 |
135 void UpdateWhitelist(); | 167 void UpdateManualListsImpl(); |
| 168 |
| 169 // Returns a copy of the manual whitelist which is stored in each profile. |
| 170 scoped_ptr<base::ListValue> GetWhitelist(); |
| 171 |
| 172 // The following functions use |is_whitelist| to select between the whitelist |
| 173 // and the blacklist as the target of the function. If |is_whitelist| is true |
| 174 // |url_pattern| is added to the whitelist, otherwise it is added to the |
| 175 // blacklist. |
| 176 |
| 177 void RemoveFromManualListImpl(const bool is_whitelist, |
| 178 const base::ListValue& whitelist); |
| 179 |
| 180 // Adds the |url_pattern| to the manual lists in the URL filter. This is used |
| 181 // by AddToManualListImpl(). |
| 182 void AddURLPatternToManualList(const bool is_whitelist, |
| 183 const std::string& url_pattern); |
| 184 |
| 185 void AddToManualListImpl(const bool is_whitelist, |
| 186 const base::ListValue& whitelist); |
| 187 |
| 188 bool IsInManualListImpl(const bool is_whitelist, |
| 189 const std::string& url_pattern); |
136 | 190 |
137 content::NotificationRegistrar registrar_; | 191 content::NotificationRegistrar registrar_; |
138 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 192 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
139 | 193 |
140 scoped_ptr<URLFilterContext> io_url_filter_context_; | 194 scoped_ptr<URLFilterContext> io_url_filter_context_; |
141 scoped_ptr<URLFilterContext> ui_url_filter_context_; | 195 scoped_ptr<URLFilterContext> ui_url_filter_context_; |
142 | 196 |
143 std::set<Browser*> browsers_to_close_; | 197 std::set<Browser*> browsers_to_close_; |
144 std::vector<EnterCallback> callbacks_; | 198 std::vector<EnterCallback> callbacks_; |
145 | 199 |
146 DISALLOW_COPY_AND_ASSIGN(ManagedMode); | 200 DISALLOW_COPY_AND_ASSIGN(ManagedMode); |
147 }; | 201 }; |
148 | 202 |
149 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 203 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
OLD | NEW |