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

Side by Side Diff: chrome/browser/extensions/api/management/management_api.h

Issue 666153002: Standardize usage of virtual/override/final in chrome/browser/extensions/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/scoped_observer.h" 9 #include "base/scoped_observer.h"
10 #include "base/task/cancelable_task_tracker.h" 10 #include "base/task/cancelable_task_tracker.h"
11 #include "chrome/browser/extensions/bookmark_app_helper.h" 11 #include "chrome/browser/extensions/bookmark_app_helper.h"
12 #include "chrome/browser/extensions/chrome_extension_function.h" 12 #include "chrome/browser/extensions/chrome_extension_function.h"
13 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
14 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 14 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
15 #include "chrome/common/web_application_info.h" 15 #include "chrome/common/web_application_info.h"
16 #include "components/favicon_base/favicon_types.h" 16 #include "components/favicon_base/favicon_types.h"
17 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
18 #include "extensions/browser/browser_context_keyed_api_factory.h" 18 #include "extensions/browser/browser_context_keyed_api_factory.h"
19 #include "extensions/browser/event_router.h" 19 #include "extensions/browser/event_router.h"
20 #include "extensions/browser/extension_registry_observer.h" 20 #include "extensions/browser/extension_registry_observer.h"
21 21
22 class ExtensionService; 22 class ExtensionService;
23 class ExtensionUninstallDialog; 23 class ExtensionUninstallDialog;
24 24
25 namespace extensions { 25 namespace extensions {
26 class ExtensionRegistry; 26 class ExtensionRegistry;
27 27
28 class ManagementFunction : public ChromeSyncExtensionFunction { 28 class ManagementFunction : public ChromeSyncExtensionFunction {
29 protected: 29 protected:
30 virtual ~ManagementFunction() {} 30 ~ManagementFunction() override {}
31 31
32 ExtensionService* service(); 32 ExtensionService* service();
33 }; 33 };
34 34
35 class AsyncManagementFunction : public ChromeAsyncExtensionFunction { 35 class AsyncManagementFunction : public ChromeAsyncExtensionFunction {
36 protected: 36 protected:
37 virtual ~AsyncManagementFunction() {} 37 ~AsyncManagementFunction() override {}
38 38
39 ExtensionService* service(); 39 ExtensionService* service();
40 }; 40 };
41 41
42 class ManagementGetAllFunction : public ManagementFunction { 42 class ManagementGetAllFunction : public ManagementFunction {
43 public: 43 public:
44 DECLARE_EXTENSION_FUNCTION("management.getAll", MANAGEMENT_GETALL) 44 DECLARE_EXTENSION_FUNCTION("management.getAll", MANAGEMENT_GETALL)
45 45
46 protected: 46 protected:
47 virtual ~ManagementGetAllFunction() {} 47 ~ManagementGetAllFunction() override {}
48 48
49 // ExtensionFunction: 49 // ExtensionFunction:
50 virtual bool RunSync() override; 50 bool RunSync() override;
51 }; 51 };
52 52
53 class ManagementGetFunction : public ManagementFunction { 53 class ManagementGetFunction : public ManagementFunction {
54 public: 54 public:
55 DECLARE_EXTENSION_FUNCTION("management.get", MANAGEMENT_GET) 55 DECLARE_EXTENSION_FUNCTION("management.get", MANAGEMENT_GET)
56 56
57 protected: 57 protected:
58 virtual ~ManagementGetFunction() {} 58 ~ManagementGetFunction() override {}
59 59
60 // ExtensionFunction: 60 // ExtensionFunction:
61 virtual bool RunSync() override; 61 bool RunSync() override;
62 }; 62 };
63 63
64 class ManagementGetSelfFunction : public ManagementFunction { 64 class ManagementGetSelfFunction : public ManagementFunction {
65 public: 65 public:
66 DECLARE_EXTENSION_FUNCTION("management.getSelf", MANAGEMENT_GETSELF) 66 DECLARE_EXTENSION_FUNCTION("management.getSelf", MANAGEMENT_GETSELF)
67 67
68 protected: 68 protected:
69 virtual ~ManagementGetSelfFunction() {} 69 ~ManagementGetSelfFunction() override {}
70 70
71 // ExtensionFunction: 71 // ExtensionFunction:
72 virtual bool RunSync() override; 72 bool RunSync() override;
73 }; 73 };
74 74
75 class ManagementGetPermissionWarningsByIdFunction : public ManagementFunction { 75 class ManagementGetPermissionWarningsByIdFunction : public ManagementFunction {
76 public: 76 public:
77 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsById", 77 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsById",
78 MANAGEMENT_GETPERMISSIONWARNINGSBYID) 78 MANAGEMENT_GETPERMISSIONWARNINGSBYID)
79 79
80 protected: 80 protected:
81 virtual ~ManagementGetPermissionWarningsByIdFunction() {} 81 ~ManagementGetPermissionWarningsByIdFunction() override {}
82 82
83 // ExtensionFunction: 83 // ExtensionFunction:
84 virtual bool RunSync() override; 84 bool RunSync() override;
85 }; 85 };
86 86
87 class ManagementGetPermissionWarningsByManifestFunction 87 class ManagementGetPermissionWarningsByManifestFunction
88 : public ChromeAsyncExtensionFunction { 88 : public ChromeAsyncExtensionFunction {
89 public: 89 public:
90 DECLARE_EXTENSION_FUNCTION( 90 DECLARE_EXTENSION_FUNCTION(
91 "management.getPermissionWarningsByManifest", 91 "management.getPermissionWarningsByManifest",
92 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); 92 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST);
93 93
94 // Called when utility process finishes. 94 // Called when utility process finishes.
95 void OnParseSuccess(scoped_ptr<base::DictionaryValue> parsed_manifest); 95 void OnParseSuccess(scoped_ptr<base::DictionaryValue> parsed_manifest);
96 void OnParseFailure(const std::string& error); 96 void OnParseFailure(const std::string& error);
97 97
98 protected: 98 protected:
99 virtual ~ManagementGetPermissionWarningsByManifestFunction() {} 99 ~ManagementGetPermissionWarningsByManifestFunction() override {}
100 100
101 // ExtensionFunction: 101 // ExtensionFunction:
102 virtual bool RunAsync() override; 102 bool RunAsync() override;
103 }; 103 };
104 104
105 class ManagementLaunchAppFunction : public ManagementFunction { 105 class ManagementLaunchAppFunction : public ManagementFunction {
106 public: 106 public:
107 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) 107 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP)
108 108
109 protected: 109 protected:
110 virtual ~ManagementLaunchAppFunction() {} 110 ~ManagementLaunchAppFunction() override {}
111 111
112 // ExtensionFunction: 112 // ExtensionFunction:
113 virtual bool RunSync() override; 113 bool RunSync() override;
114 }; 114 };
115 115
116 class ManagementSetEnabledFunction : public AsyncManagementFunction, 116 class ManagementSetEnabledFunction : public AsyncManagementFunction,
117 public ExtensionInstallPrompt::Delegate { 117 public ExtensionInstallPrompt::Delegate {
118 public: 118 public:
119 DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED) 119 DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED)
120 120
121 ManagementSetEnabledFunction(); 121 ManagementSetEnabledFunction();
122 122
123 protected: 123 protected:
124 virtual ~ManagementSetEnabledFunction(); 124 ~ManagementSetEnabledFunction() override;
125 125
126 // ExtensionFunction: 126 // ExtensionFunction:
127 virtual bool RunAsync() override; 127 bool RunAsync() override;
128 128
129 // ExtensionInstallPrompt::Delegate. 129 // ExtensionInstallPrompt::Delegate.
130 virtual void InstallUIProceed() override; 130 void InstallUIProceed() override;
131 virtual void InstallUIAbort(bool user_initiated) override; 131 void InstallUIAbort(bool user_initiated) override;
132 132
133 private: 133 private:
134 std::string extension_id_; 134 std::string extension_id_;
135 135
136 // Used for prompting to re-enable items with permissions escalation updates. 136 // Used for prompting to re-enable items with permissions escalation updates.
137 scoped_ptr<ExtensionInstallPrompt> install_prompt_; 137 scoped_ptr<ExtensionInstallPrompt> install_prompt_;
138 }; 138 };
139 139
140 class ManagementUninstallFunctionBase : public AsyncManagementFunction, 140 class ManagementUninstallFunctionBase : public AsyncManagementFunction,
141 public ExtensionUninstallDialog::Delegate { 141 public ExtensionUninstallDialog::Delegate {
142 public: 142 public:
143 ManagementUninstallFunctionBase(); 143 ManagementUninstallFunctionBase();
144 144
145 static void SetAutoConfirmForTest(bool should_proceed); 145 static void SetAutoConfirmForTest(bool should_proceed);
146 146
147 // ExtensionUninstallDialog::Delegate implementation. 147 // ExtensionUninstallDialog::Delegate implementation.
148 virtual void ExtensionUninstallAccepted() override; 148 void ExtensionUninstallAccepted() override;
149 virtual void ExtensionUninstallCanceled() override; 149 void ExtensionUninstallCanceled() override;
150 150
151 protected: 151 protected:
152 virtual ~ManagementUninstallFunctionBase(); 152 ~ManagementUninstallFunctionBase() override;
153 153
154 bool Uninstall(const std::string& extension_id, bool show_confirm_dialog); 154 bool Uninstall(const std::string& extension_id, bool show_confirm_dialog);
155 private: 155 private:
156 156
157 // If should_uninstall is true, this method does the actual uninstall. 157 // If should_uninstall is true, this method does the actual uninstall.
158 // If |show_uninstall_dialog|, then this function will be called by one of the 158 // If |show_uninstall_dialog|, then this function will be called by one of the
159 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunAsync. 159 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunAsync.
160 void Finish(bool should_uninstall); 160 void Finish(bool should_uninstall);
161 161
162 std::string extension_id_; 162 std::string extension_id_;
163 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; 163 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
164 }; 164 };
165 165
166 class ManagementUninstallFunction : public ManagementUninstallFunctionBase { 166 class ManagementUninstallFunction : public ManagementUninstallFunctionBase {
167 public: 167 public:
168 DECLARE_EXTENSION_FUNCTION("management.uninstall", MANAGEMENT_UNINSTALL) 168 DECLARE_EXTENSION_FUNCTION("management.uninstall", MANAGEMENT_UNINSTALL)
169 169
170 ManagementUninstallFunction(); 170 ManagementUninstallFunction();
171 171
172 private: 172 private:
173 virtual ~ManagementUninstallFunction(); 173 ~ManagementUninstallFunction() override;
174 174
175 virtual bool RunAsync() override; 175 bool RunAsync() override;
176 }; 176 };
177 177
178 class ManagementUninstallSelfFunction : public ManagementUninstallFunctionBase { 178 class ManagementUninstallSelfFunction : public ManagementUninstallFunctionBase {
179 public: 179 public:
180 DECLARE_EXTENSION_FUNCTION("management.uninstallSelf", 180 DECLARE_EXTENSION_FUNCTION("management.uninstallSelf",
181 MANAGEMENT_UNINSTALLSELF); 181 MANAGEMENT_UNINSTALLSELF);
182 182
183 ManagementUninstallSelfFunction(); 183 ManagementUninstallSelfFunction();
184 184
185 private: 185 private:
186 virtual ~ManagementUninstallSelfFunction(); 186 ~ManagementUninstallSelfFunction() override;
187 187
188 virtual bool RunAsync() override; 188 bool RunAsync() override;
189 }; 189 };
190 190
191 class ManagementCreateAppShortcutFunction : public AsyncManagementFunction { 191 class ManagementCreateAppShortcutFunction : public AsyncManagementFunction {
192 public: 192 public:
193 DECLARE_EXTENSION_FUNCTION("management.createAppShortcut", 193 DECLARE_EXTENSION_FUNCTION("management.createAppShortcut",
194 MANAGEMENT_CREATEAPPSHORTCUT); 194 MANAGEMENT_CREATEAPPSHORTCUT);
195 195
196 ManagementCreateAppShortcutFunction(); 196 ManagementCreateAppShortcutFunction();
197 197
198 void OnCloseShortcutPrompt(bool created); 198 void OnCloseShortcutPrompt(bool created);
199 199
200 static void SetAutoConfirmForTest(bool should_proceed); 200 static void SetAutoConfirmForTest(bool should_proceed);
201 201
202 protected: 202 protected:
203 virtual ~ManagementCreateAppShortcutFunction(); 203 ~ManagementCreateAppShortcutFunction() override;
204 204
205 virtual bool RunAsync() override; 205 bool RunAsync() override;
206 }; 206 };
207 207
208 class ManagementSetLaunchTypeFunction : public ManagementFunction { 208 class ManagementSetLaunchTypeFunction : public ManagementFunction {
209 public: 209 public:
210 DECLARE_EXTENSION_FUNCTION("management.setLaunchType", 210 DECLARE_EXTENSION_FUNCTION("management.setLaunchType",
211 MANAGEMENT_SETLAUNCHTYPE); 211 MANAGEMENT_SETLAUNCHTYPE);
212 212
213 protected: 213 protected:
214 virtual ~ManagementSetLaunchTypeFunction() {} 214 ~ManagementSetLaunchTypeFunction() override {}
215 215
216 virtual bool RunSync() override; 216 bool RunSync() override;
217 }; 217 };
218 218
219 class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction { 219 class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction {
220 public: 220 public:
221 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink", 221 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink",
222 MANAGEMENT_GENERATEAPPFORLINK); 222 MANAGEMENT_GENERATEAPPFORLINK);
223 223
224 ManagementGenerateAppForLinkFunction(); 224 ManagementGenerateAppForLinkFunction();
225 225
226 protected: 226 protected:
227 virtual ~ManagementGenerateAppForLinkFunction(); 227 ~ManagementGenerateAppForLinkFunction() override;
228 228
229 virtual bool RunAsync() override; 229 bool RunAsync() override;
230 230
231 private: 231 private:
232 void OnFaviconForApp(const favicon_base::FaviconImageResult& image_result); 232 void OnFaviconForApp(const favicon_base::FaviconImageResult& image_result);
233 void FinishCreateBookmarkApp(const Extension* extension, 233 void FinishCreateBookmarkApp(const Extension* extension,
234 const WebApplicationInfo& web_app_info); 234 const WebApplicationInfo& web_app_info);
235 235
236 std::string title_; 236 std::string title_;
237 GURL launch_url_; 237 GURL launch_url_;
238 238
239 scoped_ptr<BookmarkAppHelper> bookmark_app_helper_; 239 scoped_ptr<BookmarkAppHelper> bookmark_app_helper_;
240 240
241 // Used for favicon loading tasks. 241 // Used for favicon loading tasks.
242 base::CancelableTaskTracker cancelable_task_tracker_; 242 base::CancelableTaskTracker cancelable_task_tracker_;
243 }; 243 };
244 244
245 class ManagementEventRouter : public ExtensionRegistryObserver { 245 class ManagementEventRouter : public ExtensionRegistryObserver {
246 public: 246 public:
247 explicit ManagementEventRouter(content::BrowserContext* context); 247 explicit ManagementEventRouter(content::BrowserContext* context);
248 virtual ~ManagementEventRouter(); 248 ~ManagementEventRouter() override;
249 249
250 private: 250 private:
251 // ExtensionRegistryObserver implementation. 251 // ExtensionRegistryObserver implementation.
252 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, 252 void OnExtensionLoaded(content::BrowserContext* browser_context,
253 const Extension* extension) override; 253 const Extension* extension) override;
254 virtual void OnExtensionUnloaded( 254 void OnExtensionUnloaded(content::BrowserContext* browser_context,
255 content::BrowserContext* browser_context, 255 const Extension* extension,
256 const Extension* extension, 256 UnloadedExtensionInfo::Reason reason) override;
257 UnloadedExtensionInfo::Reason reason) override; 257 void OnExtensionInstalled(content::BrowserContext* browser_context,
258 virtual void OnExtensionInstalled(content::BrowserContext* browser_context, 258 const Extension* extension,
259 const Extension* extension, 259 bool is_update) override;
260 bool is_update) override; 260 void OnExtensionUninstalled(content::BrowserContext* browser_context,
261 virtual void OnExtensionUninstalled( 261 const Extension* extension,
262 content::BrowserContext* browser_context, 262 extensions::UninstallReason reason) override;
263 const Extension* extension,
264 extensions::UninstallReason reason) override;
265 263
266 // Dispatches management api events to listening extensions. 264 // Dispatches management api events to listening extensions.
267 void BroadcastEvent(const Extension* extension, const char* event_name); 265 void BroadcastEvent(const Extension* extension, const char* event_name);
268 266
269 content::BrowserContext* browser_context_; 267 content::BrowserContext* browser_context_;
270 268
271 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 269 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
272 extension_registry_observer_; 270 extension_registry_observer_;
273 271
274 DISALLOW_COPY_AND_ASSIGN(ManagementEventRouter); 272 DISALLOW_COPY_AND_ASSIGN(ManagementEventRouter);
275 }; 273 };
276 274
277 class ManagementAPI : public BrowserContextKeyedAPI, 275 class ManagementAPI : public BrowserContextKeyedAPI,
278 public EventRouter::Observer { 276 public EventRouter::Observer {
279 public: 277 public:
280 explicit ManagementAPI(content::BrowserContext* context); 278 explicit ManagementAPI(content::BrowserContext* context);
281 virtual ~ManagementAPI(); 279 ~ManagementAPI() override;
282 280
283 // KeyedService implementation. 281 // KeyedService implementation.
284 virtual void Shutdown() override; 282 void Shutdown() override;
285 283
286 // BrowserContextKeyedAPI implementation. 284 // BrowserContextKeyedAPI implementation.
287 static BrowserContextKeyedAPIFactory<ManagementAPI>* GetFactoryInstance(); 285 static BrowserContextKeyedAPIFactory<ManagementAPI>* GetFactoryInstance();
288 286
289 // EventRouter::Observer implementation. 287 // EventRouter::Observer implementation.
290 virtual void OnListenerAdded(const EventListenerInfo& details) override; 288 void OnListenerAdded(const EventListenerInfo& details) override;
291 289
292 private: 290 private:
293 friend class BrowserContextKeyedAPIFactory<ManagementAPI>; 291 friend class BrowserContextKeyedAPIFactory<ManagementAPI>;
294 292
295 content::BrowserContext* browser_context_; 293 content::BrowserContext* browser_context_;
296 294
297 // BrowserContextKeyedAPI implementation. 295 // BrowserContextKeyedAPI implementation.
298 static const char* service_name() { 296 static const char* service_name() {
299 return "ManagementAPI"; 297 return "ManagementAPI";
300 } 298 }
301 static const bool kServiceIsNULLWhileTesting = true; 299 static const bool kServiceIsNULLWhileTesting = true;
302 300
303 // Created lazily upon OnListenerAdded. 301 // Created lazily upon OnListenerAdded.
304 scoped_ptr<ManagementEventRouter> management_event_router_; 302 scoped_ptr<ManagementEventRouter> management_event_router_;
305 303
306 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); 304 DISALLOW_COPY_AND_ASSIGN(ManagementAPI);
307 }; 305 };
308 306
309 } // namespace extensions 307 } // namespace extensions
310 308
311 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ 309 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/location/location_manager.cc ('k') | chrome/browser/extensions/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698