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

Side by Side Diff: chrome/browser/extensions/api/managed_mode/managed_mode_api.h

Issue 11719004: Remove Profile-keyed factory boilerplate: cookies, managed_mode & web_navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 11 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
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 // Defines the Chrome Extensions Managed Mode API relevant classes to realize 5 // Defines the Chrome Extensions Managed Mode API relevant classes to realize
6 // the API as specified in the extension API JSON. 6 // the API as specified in the extension API JSON.
7 7
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_MANAGED_MODE_API_H_ 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_MANAGED_MODE_API_H_
9 #define CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_MANAGED_MODE_API_H_ 9 #define CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_MANAGED_MODE_API_H_
10 10
11 #include "base/prefs/public/pref_change_registrar.h" 11 #include "base/prefs/public/pref_change_registrar.h"
12 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
12 #include "chrome/browser/extensions/event_router.h" 13 #include "chrome/browser/extensions/event_router.h"
13 #include "chrome/browser/extensions/extension_function.h" 14 #include "chrome/browser/extensions/extension_function.h"
14 #include "chrome/browser/profiles/profile_keyed_service.h"
15 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
16 16
17 class Profile; 17 class Profile;
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 class ManagedModeEventRouter { 21 class ManagedModeEventRouter {
22 public: 22 public:
23 explicit ManagedModeEventRouter(Profile* profile); 23 explicit ManagedModeEventRouter(Profile* profile);
24 virtual ~ManagedModeEventRouter(); 24 virtual ~ManagedModeEventRouter();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 public: 74 public:
75 DECLARE_EXTENSION_FUNCTION_NAME("managedModePrivate.setPolicy") 75 DECLARE_EXTENSION_FUNCTION_NAME("managedModePrivate.setPolicy")
76 76
77 protected: 77 protected:
78 virtual ~SetPolicyFunction(); 78 virtual ~SetPolicyFunction();
79 79
80 // ExtensionFunction: 80 // ExtensionFunction:
81 virtual bool RunImpl() OVERRIDE; 81 virtual bool RunImpl() OVERRIDE;
82 }; 82 };
83 83
84 class ManagedModeAPI : public ProfileKeyedService, 84 class ManagedModeAPI : public ProfileKeyedAPI,
85 public extensions::EventRouter::Observer { 85 public extensions::EventRouter::Observer {
86 public: 86 public:
87 explicit ManagedModeAPI(Profile* profile); 87 explicit ManagedModeAPI(Profile* profile);
88 virtual ~ManagedModeAPI(); 88 virtual ~ManagedModeAPI();
89 89
90 // ProfileKeyedService implementation. 90 // ProfileKeyedService implementation.
91 virtual void Shutdown() OVERRIDE; 91 virtual void Shutdown() OVERRIDE;
92 92
93 // EventRouter::Observer implementation. 93 // EventRouter::Observer implementation.
94 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) 94 virtual void OnListenerAdded(const extensions::EventListenerInfo& details)
95 OVERRIDE; 95 OVERRIDE;
96 96
97 private: 97 private:
98 friend class ProfileKeyedAPIFactory<ManagedModeAPI>;
99
98 Profile* profile_; 100 Profile* profile_;
99 101
102 // ProfileKeyedAPI implementation.
103 static const char* service_name() {
104 return "ManagedModeAPI";
105 }
106 static const bool kServiceIsNULLWhileTesting = true;
107
100 // Created lazily upon OnListenerAdded. 108 // Created lazily upon OnListenerAdded.
101 scoped_ptr<ManagedModeEventRouter> managed_mode_event_router_; 109 scoped_ptr<ManagedModeEventRouter> managed_mode_event_router_;
110
111 DISALLOW_COPY_AND_ASSIGN(ManagedModeAPI);
102 }; 112 };
103 113
114 template <>
115 ProfileKeyedAPIFactory<ManagedModeAPI>*
116 ProfileKeyedAPIFactory<ManagedModeAPI>::GetInstance();
117
104 } // namespace extensions 118 } // namespace extensions
105 119
106 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_MANAGED_MODE_API_H_ 120 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGED_MODE_MANAGED_MODE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698