Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: chrome/browser/managed_mode.h

Issue 10690151: Move implementation of BrowserList onto an inner, instantiatable class, BrowserListImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_H_ 5 #ifndef CHROME_BROWSER_MANAGED_MODE_H_
6 #define CHROME_BROWSER_MANAGED_MODE_H_ 6 #define CHROME_BROWSER_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/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "chrome/browser/extensions/management_policy.h" 15 #include "chrome/browser/extensions/management_policy.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list_observer.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 19
20 class Browser; 20 class Browser;
21 template<typename T> 21 template<typename T>
22 struct DefaultSingletonTraits; 22 struct DefaultSingletonTraits;
23 class PrefService; 23 class PrefService;
24 class Profile; 24 class Profile;
25 25
26 // Managed mode allows one person to manage the Chrome experience for another 26 // Managed mode allows one person to manage the Chrome experience for another
27 // person by pre-configuring and then locking a managed User profile. 27 // person by pre-configuring and then locking a managed User profile.
28 // The ManagedMode class provides methods to check whether the browser is in 28 // The ManagedMode class provides methods to check whether the browser is in
29 // managed mode, and to attempt to enter or leave managed mode. 29 // managed mode, and to attempt to enter or leave managed mode.
30 class ManagedMode : public BrowserList::Observer, 30 class ManagedMode : public chrome::BrowserListObserver,
31 public extensions::ManagementPolicy::Provider, 31 public extensions::ManagementPolicy::Provider,
32 public content::NotificationObserver { 32 public content::NotificationObserver {
33 public: 33 public:
34 typedef base::Callback<void(bool)> EnterCallback; 34 typedef base::Callback<void(bool)> EnterCallback;
35 35
36 static void RegisterPrefs(PrefService* prefs); 36 static void RegisterPrefs(PrefService* prefs);
37 37
38 // Initializes the singleton, setting the managed_profile_. Must be called 38 // Initializes the singleton, setting the managed_profile_. Must be called
39 // after g_browser_process and the LocalState have been created. 39 // after g_browser_process and the LocalState have been created.
40 static void Init(Profile* profile); 40 static void Init(Profile* profile);
41 static bool IsInManagedMode(); 41 static bool IsInManagedMode();
42 42
43 // Calls |callback| with the argument true iff managed mode was entered 43 // Calls |callback| with the argument true iff managed mode was entered
44 // sucessfully. 44 // sucessfully.
45 static void EnterManagedMode(Profile* profile, const EnterCallback& callback); 45 static void EnterManagedMode(Profile* profile, const EnterCallback& callback);
46 static void LeaveManagedMode(); 46 static void LeaveManagedMode();
47 47
48 // ExtensionManagementPolicy::Provider implementation: 48 // ExtensionManagementPolicy::Provider implementation:
49 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; 49 virtual std::string GetDebugPolicyProviderName() const OVERRIDE;
50 virtual bool UserMayLoad(const extensions::Extension* extension, 50 virtual bool UserMayLoad(const extensions::Extension* extension,
51 string16* error) const OVERRIDE; 51 string16* error) const OVERRIDE;
52 virtual bool UserMayModifySettings(const extensions::Extension* extension, 52 virtual bool UserMayModifySettings(const extensions::Extension* extension,
53 string16* error) const OVERRIDE; 53 string16* error) const OVERRIDE;
54 54
55 // BrowserList::Observer implementation: 55 // chrome::BrowserListObserver implementation:
56 virtual void OnBrowserAdded(Browser* browser) OVERRIDE; 56 virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
57 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; 57 virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
58 58
59 // content::NotificationObserver implementation: 59 // content::NotificationObserver implementation:
60 virtual void Observe(int type, 60 virtual void Observe(int type,
61 const content::NotificationSource& source, 61 const content::NotificationSource& source,
62 const content::NotificationDetails& details) OVERRIDE; 62 const content::NotificationDetails& details) OVERRIDE;
63 63
64 protected: 64 protected:
65 ManagedMode(); 65 ManagedMode();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 content::NotificationRegistrar registrar_; 106 content::NotificationRegistrar registrar_;
107 107
108 std::set<Browser*> browsers_to_close_; 108 std::set<Browser*> browsers_to_close_;
109 std::vector<EnterCallback> callbacks_; 109 std::vector<EnterCallback> callbacks_;
110 110
111 DISALLOW_COPY_AND_ASSIGN(ManagedMode); 111 DISALLOW_COPY_AND_ASSIGN(ManagedMode);
112 }; 112 };
113 113
114 #endif // CHROME_BROWSER_MANAGED_MODE_H_ 114 #endif // CHROME_BROWSER_MANAGED_MODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698