| 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 "base/time.h" |
| 16 #include "chrome/browser/extensions/management_policy.h" | 17 #include "chrome/browser/extensions/management_policy.h" |
| 17 #include "chrome/browser/ui/browser_list_observer.h" | 18 #include "chrome/browser/ui/browser_list_observer.h" |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 | 21 |
| 21 class Browser; | 22 class Browser; |
| 22 template<typename T> | 23 template<typename T> |
| 23 struct DefaultSingletonTraits; | 24 struct DefaultSingletonTraits; |
| 24 class ManagedModeSiteList; | 25 class ManagedModeSiteList; |
| 25 class ManagedModeURLFilter; | 26 class ManagedModeURLFilter; |
| 26 class PrefChangeRegistrar; | 27 class PrefChangeRegistrar; |
| 27 class PrefServiceSimple; | 28 class PrefServiceSimple; |
| 28 class PrefServiceSyncable; | 29 class PrefServiceSyncable; |
| 29 class Profile; | 30 class Profile; |
| 30 | 31 |
| 31 namespace policy{ | 32 namespace policy { |
| 32 class URLBlacklist; | 33 class URLBlacklist; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // Managed mode allows one person to manage the Chrome experience for another | 36 // Managed mode allows one person to manage the Chrome experience for another |
| 36 // person by pre-configuring and then locking a managed User profile. | 37 // person by pre-configuring and then locking a managed User profile. |
| 37 // The ManagedMode class provides methods to check whether the browser is in | 38 // The ManagedMode class provides methods to check whether the browser is in |
| 38 // managed mode, and to attempt to enter or leave managed mode. | 39 // managed mode, and to attempt to enter or leave managed mode. |
| 39 // Except where otherwise noted, this class should be used on the UI thread. | 40 // Except where otherwise noted, this class should be used on the UI thread. |
| 40 class ManagedMode : public chrome::BrowserListObserver, | 41 class ManagedMode : public chrome::BrowserListObserver, |
| 41 public extensions::ManagementPolicy::Provider, | 42 public extensions::ManagementPolicy::Provider, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // |is_whitelist|) both in URL filter and in preferences. | 88 // |is_whitelist|) both in URL filter and in preferences. |
| 88 static void RemoveFromManualList(const bool is_whitelist, | 89 static void RemoveFromManualList(const bool is_whitelist, |
| 89 const base::ListValue& list); | 90 const base::ListValue& list); |
| 90 | 91 |
| 91 // Updates the whitelist and the blacklist from the prefs. | 92 // Updates the whitelist and the blacklist from the prefs. |
| 92 static void UpdateManualLists(); | 93 static void UpdateManualLists(); |
| 93 | 94 |
| 94 // Returns the profile blacklist. | 95 // Returns the profile blacklist. |
| 95 static scoped_ptr<base::ListValue> GetBlacklist(); | 96 static scoped_ptr<base::ListValue> GetBlacklist(); |
| 96 | 97 |
| 98 // Returns the URL's category (ID number). |
| 99 static int GetCategory(const GURL& url); |
| 100 |
| 97 // ExtensionManagementPolicy::Provider implementation: | 101 // ExtensionManagementPolicy::Provider implementation: |
| 98 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 102 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
| 99 virtual bool UserMayLoad(const extensions::Extension* extension, | 103 virtual bool UserMayLoad(const extensions::Extension* extension, |
| 100 string16* error) const OVERRIDE; | 104 string16* error) const OVERRIDE; |
| 101 virtual bool UserMayModifySettings(const extensions::Extension* extension, | 105 virtual bool UserMayModifySettings(const extensions::Extension* extension, |
| 102 string16* error) const OVERRIDE; | 106 string16* error) const OVERRIDE; |
| 103 | 107 |
| 104 // chrome::BrowserListObserver implementation: | 108 // chrome::BrowserListObserver implementation: |
| 105 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; | 109 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; |
| 106 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; | 110 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 124 friend class Singleton<ManagedMode, LeakySingletonTraits<ManagedMode> >; | 128 friend class Singleton<ManagedMode, LeakySingletonTraits<ManagedMode> >; |
| 125 friend struct DefaultSingletonTraits<ManagedMode>; | 129 friend struct DefaultSingletonTraits<ManagedMode>; |
| 126 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ManagedModeOnChange); | 130 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ManagedModeOnChange); |
| 127 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, | 131 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, |
| 128 ManagedModeProhibitsModification); | 132 ManagedModeProhibitsModification); |
| 129 | 133 |
| 130 static ManagedMode* GetInstance(); | 134 static ManagedMode* GetInstance(); |
| 131 | 135 |
| 132 virtual void InitImpl(Profile* profile); | 136 virtual void InitImpl(Profile* profile); |
| 133 | 137 |
| 138 // Collect statistics about URLs and categories in the history database. |
| 139 // The |description| will be used in the name of the UMA histogram. |
| 140 void CollectDetailedHistoryMetrics(Profile* profile, |
| 141 base::Time start_time, |
| 142 std::string description); |
| 143 |
| 134 // Internal implementation for ExtensionManagementPolicy::Delegate methods. | 144 // Internal implementation for ExtensionManagementPolicy::Delegate methods. |
| 135 // If |error| is not NULL, it will be filled with an error message if the | 145 // If |error| is not NULL, it will be filled with an error message if the |
| 136 // requested extension action (install, modify status, etc.) is not permitted. | 146 // requested extension action (install, modify status, etc.) is not permitted. |
| 137 bool ExtensionManagementPolicyImpl(string16* error) const; | 147 bool ExtensionManagementPolicyImpl(string16* error) const; |
| 138 | 148 |
| 139 void LeaveManagedModeImpl(); | 149 void LeaveManagedModeImpl(); |
| 140 | 150 |
| 141 const ManagedModeURLFilter* GetURLFilterForIOThreadImpl(); | 151 const ManagedModeURLFilter* GetURLFilterForIOThreadImpl(); |
| 142 const ManagedModeURLFilter* GetURLFilterForUIThreadImpl(); | 152 const ManagedModeURLFilter* GetURLFilterForUIThreadImpl(); |
| 143 | 153 |
| 154 int GetCategoryImpl(const GURL& url); |
| 155 |
| 144 void FinalizeEnter(bool result); | 156 void FinalizeEnter(bool result); |
| 145 | 157 |
| 146 // Platform-specific methods that confirm whether we can enter or leave | 158 // Platform-specific methods that confirm whether we can enter or leave |
| 147 // managed mode. | 159 // managed mode. |
| 148 virtual bool PlatformConfirmEnter(); | 160 virtual bool PlatformConfirmEnter(); |
| 149 virtual bool PlatformConfirmLeave(); | 161 virtual bool PlatformConfirmLeave(); |
| 150 | 162 |
| 151 virtual bool IsInManagedModeImpl() const; | 163 virtual bool IsInManagedModeImpl() const; |
| 152 | 164 |
| 153 // Enables or disables managed mode and registers or unregisters it with the | 165 // Enables or disables managed mode and registers or unregisters it with the |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 scoped_ptr<URLFilterContext> io_url_filter_context_; | 206 scoped_ptr<URLFilterContext> io_url_filter_context_; |
| 195 scoped_ptr<URLFilterContext> ui_url_filter_context_; | 207 scoped_ptr<URLFilterContext> ui_url_filter_context_; |
| 196 | 208 |
| 197 std::set<Browser*> browsers_to_close_; | 209 std::set<Browser*> browsers_to_close_; |
| 198 std::vector<EnterCallback> callbacks_; | 210 std::vector<EnterCallback> callbacks_; |
| 199 | 211 |
| 200 DISALLOW_COPY_AND_ASSIGN(ManagedMode); | 212 DISALLOW_COPY_AND_ASSIGN(ManagedMode); |
| 201 }; | 213 }; |
| 202 | 214 |
| 203 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 215 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
| OLD | NEW |