Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "chrome/browser/extensions/management_policy.h" | 16 #include "chrome/browser/extensions/management_policy.h" |
| 17 #include "chrome/browser/ui/browser_list_observer.h" | 17 #include "chrome/browser/ui/browser_list_observer.h" |
| 18 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 | 20 |
| 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 PrefService; | 27 class PrefService; |
| 28 class Profile; | 28 class Profile; |
| 29 | |
| 29 namespace policy{ | 30 namespace policy{ |
| 30 class URLBlacklist; | 31 class URLBlacklist; |
| 31 } | 32 } |
| 32 | 33 |
| 33 // Managed mode allows one person to manage the Chrome experience for another | 34 // Managed mode allows one person to manage the Chrome experience for another |
| 34 // person by pre-configuring and then locking a managed User profile. | 35 // person by pre-configuring and then locking a managed User profile. |
| 35 // The ManagedMode class provides methods to check whether the browser is in | 36 // The ManagedMode class provides methods to check whether the browser is in |
| 36 // managed mode, and to attempt to enter or leave managed mode. | 37 // managed mode, and to attempt to enter or leave managed mode. |
| 37 // Except where otherwise noted, this class should be used on the UI thread. | 38 // Except where otherwise noted, this class should be used on the UI thread. |
| 38 class ManagedMode : public chrome::BrowserListObserver, | 39 class ManagedMode : public chrome::BrowserListObserver, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 63 // classifying sites in the history view. | 64 // classifying sites in the history view. |
| 64 // This method should only be called on the UI thread. | 65 // This method should only be called on the UI thread. |
| 65 static const ManagedModeURLFilter* GetURLFilterForUIThread(); | 66 static const ManagedModeURLFilter* GetURLFilterForUIThread(); |
| 66 | 67 |
| 67 // Returns the URL's category. | 68 // Returns the URL's category. |
| 68 static int GetCategory(const GURL& url); | 69 static int GetCategory(const GURL& url); |
| 69 | 70 |
| 70 // Called in the critical path of drawing the history UI, so needs to be fast. | 71 // Called in the critical path of drawing the history UI, so needs to be fast. |
| 71 static void GetCategoryNames(CategoryList* list); | 72 static void GetCategoryNames(CategoryList* list); |
| 72 | 73 |
| 73 // Returns the profile whitelist. | 74 // Checks if the url pattern is in the manual whitelist. |
| 74 static scoped_ptr<base::ListValue> GetWhitelist(); | 75 static bool IsInManualWhitelist(const std::string& url_pattern); |
| 75 | 76 |
| 76 // Sets the profile whitelist to |whitelist|. | 77 // Appends |whitelist| to the manual whitelist(both in URL filter and in |
|
Bernhard Bauer
2012/11/26 16:06:30
Nit: space before opening parenthesis.
Sergiu
2012/11/27 15:37:34
Done.
| |
| 77 static void SetWhitelist(base::ListValue* whitelist); | 78 // preferences). |
| 79 static bool AddToManualWhitelist(const base::ListValue& whitelist); | |
|
Bernhard Bauer
2012/11/26 16:06:30
What does the return value mean?
Sergiu
2012/11/27 15:37:34
Done.
| |
| 78 | 80 |
| 79 // Adds the |url| to the manual lists. | 81 // Adds the |url_patter| to the manual lists in the URL filter. |
|
Bernhard Bauer
2012/11/26 16:06:30
Nit: |url_pattern|
Sergiu
2012/11/27 15:37:34
Done.
| |
| 80 static void AddStringToManualWhitelist(const std::string& url); | 82 static void AddURLPatternToManualWhitelist(const std::string& url_pattern); |
| 81 static void AddStringToManualBlacklist(const std::string& url); | 83 static void AddURLPatternToManualBlacklist(const std::string& url_pattern); |
| 82 | 84 |
| 83 // Returns the profile blacklist. | 85 // Returns the profile blacklist. |
| 84 static scoped_ptr<base::ListValue> GetBlacklist(); | 86 static scoped_ptr<base::ListValue> GetBlacklist(); |
|
Bernhard Bauer
2012/11/26 16:06:30
Is this method used?
Sergiu
2012/11/27 15:37:34
Not right now but it will almost surely be used in
Bernhard Bauer
2012/11/27 18:44:46
It's fine if you move it together with GetWhiteLis
| |
| 85 | 87 |
| 86 // ExtensionManagementPolicy::Provider implementation: | 88 // ExtensionManagementPolicy::Provider implementation: |
| 87 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 89 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
| 88 virtual bool UserMayLoad(const extensions::Extension* extension, | 90 virtual bool UserMayLoad(const extensions::Extension* extension, |
| 89 string16* error) const OVERRIDE; | 91 string16* error) const OVERRIDE; |
| 90 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 92 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
| 91 string16* error) const OVERRIDE; | 93 string16* error) const OVERRIDE; |
| 92 | 94 |
| 93 // chrome::BrowserListObserver implementation: | 95 // chrome::BrowserListObserver implementation: |
| 94 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 96 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 152 |
| 151 // Returns a list of all installed and enabled site lists in the current | 153 // Returns a list of all installed and enabled site lists in the current |
| 152 // managed profile. | 154 // managed profile. |
| 153 // This method should only be called if managed mode is active. | 155 // This method should only be called if managed mode is active. |
| 154 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); | 156 ScopedVector<ManagedModeSiteList> GetActiveSiteLists(); |
| 155 | 157 |
| 156 void OnFamilyPackOptionsChanged(); | 158 void OnFamilyPackOptionsChanged(); |
| 157 | 159 |
| 158 void UpdateWhitelist(); | 160 void UpdateWhitelist(); |
| 159 | 161 |
| 162 // Returns a copy of the manual whitelist which is stored in each profile. | |
| 163 static scoped_ptr<base::ListValue> GetWhitelist(); | |
|
Bernhard Bauer
2012/11/26 16:06:30
If this method is private, we don't need a separat
Sergiu
2012/11/27 15:37:34
Yes, it is by ManagedMode::UpdateWhitelist. Initia
| |
| 164 scoped_ptr<base::ListValue> GetWhitelistImpl(); | |
| 165 | |
| 160 content::NotificationRegistrar registrar_; | 166 content::NotificationRegistrar registrar_; |
| 161 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; | 167 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| 162 | 168 |
| 163 scoped_ptr<URLFilterContext> io_url_filter_context_; | 169 scoped_ptr<URLFilterContext> io_url_filter_context_; |
| 164 scoped_ptr<URLFilterContext> ui_url_filter_context_; | 170 scoped_ptr<URLFilterContext> ui_url_filter_context_; |
| 165 | 171 |
| 166 std::set<Browser*> browsers_to_close_; | 172 std::set<Browser*> browsers_to_close_; |
| 167 std::vector<EnterCallback> callbacks_; | 173 std::vector<EnterCallback> callbacks_; |
| 168 | 174 |
| 169 DISALLOW_COPY_AND_ASSIGN(ManagedMode); | 175 DISALLOW_COPY_AND_ASSIGN(ManagedMode); |
| 170 }; | 176 }; |
| 171 | 177 |
| 172 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 178 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
| OLD | NEW |