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/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/singleton.h" | 16 #include "base/memory/singleton.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 PrefServiceSimple; | 27 class PrefRegistrySimple; |
28 class PrefServiceSyncable; | 28 class PrefServiceSyncable; |
29 class Profile; | 29 class Profile; |
30 | 30 |
31 namespace policy { | 31 namespace policy { |
32 class URLBlacklist; | 32 class URLBlacklist; |
33 } | 33 } |
34 | 34 |
35 // Managed mode locks the UI to a certain managed user profile, preventing the | 35 // Managed mode locks the UI to a certain managed user profile, preventing the |
36 // user from accessing other profiles. | 36 // user from accessing other profiles. |
37 // 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 |
38 // managed mode, and to attempt to enter or leave managed mode. | 38 // 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. | 39 // Except where otherwise noted, this class should be used on the UI thread. |
40 class ManagedMode : public chrome::BrowserListObserver, | 40 class ManagedMode : public chrome::BrowserListObserver, |
41 public content::NotificationObserver { | 41 public content::NotificationObserver { |
42 public: | 42 public: |
43 typedef base::Callback<void(bool)> EnterCallback; | 43 typedef base::Callback<void(bool)> EnterCallback; |
44 | 44 |
45 static void RegisterPrefs(PrefServiceSimple* prefs); | 45 static void RegisterPrefs(PrefRegistrySimple* registry); |
46 | 46 |
47 // Initializes the singleton, setting the managed_profile_. Must be called | 47 // Initializes the singleton, setting the managed_profile_. Must be called |
48 // after g_browser_process and the LocalState have been created. | 48 // after g_browser_process and the LocalState have been created. |
49 static void Init(Profile* profile); | 49 static void Init(Profile* profile); |
50 static bool IsInManagedMode(); | 50 static bool IsInManagedMode(); |
51 | 51 |
52 // Calls |callback| with the argument true iff managed mode was entered | 52 // Calls |callback| with the argument true iff managed mode was entered |
53 // sucessfully. | 53 // sucessfully. |
54 static void EnterManagedMode(Profile* profile, const EnterCallback& callback); | 54 static void EnterManagedMode(Profile* profile, const EnterCallback& callback); |
55 static void LeaveManagedMode(); | 55 static void LeaveManagedMode(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 virtual void SetInManagedMode(Profile* newly_managed_profile); | 102 virtual void SetInManagedMode(Profile* newly_managed_profile); |
103 | 103 |
104 content::NotificationRegistrar registrar_; | 104 content::NotificationRegistrar registrar_; |
105 std::set<Browser*> browsers_to_close_; | 105 std::set<Browser*> browsers_to_close_; |
106 std::vector<EnterCallback> callbacks_; | 106 std::vector<EnterCallback> callbacks_; |
107 | 107 |
108 DISALLOW_COPY_AND_ASSIGN(ManagedMode); | 108 DISALLOW_COPY_AND_ASSIGN(ManagedMode); |
109 }; | 109 }; |
110 | 110 |
111 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ | 111 #endif // CHROME_BROWSER_MANAGED_MODE_MANAGED_MODE_H_ |
OLD | NEW |