| 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 EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ | 6 #define EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 13 #include "extensions/browser/api/management/management_api_delegate.h" | 13 #include "extensions/browser/api/management/management_api_delegate.h" |
| 14 #include "extensions/browser/browser_context_keyed_api_factory.h" | 14 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 15 #include "extensions/browser/event_router.h" | 15 #include "extensions/browser/event_router.h" |
| 16 #include "extensions/browser/extension_event_histogram_value.h" | 16 #include "extensions/browser/extension_event_histogram_value.h" |
| 17 #include "extensions/browser/extension_function.h" | 17 #include "extensions/browser/extension_function.h" |
| 18 #include "extensions/browser/extension_registry_observer.h" | 18 #include "extensions/browser/extension_registry_observer.h" |
| 19 | 19 |
| 20 struct WebApplicationInfo; | 20 struct WebApplicationInfo; |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 class ExtensionRegistry; | 23 class ExtensionRegistry; |
| 24 class RequirementsChecker; | 24 class RequirementsChecker; |
| 25 | 25 |
| 26 class AsyncManagementFunction : public AsyncExtensionFunction { | |
| 27 protected: | |
| 28 ~AsyncManagementFunction() override {} | |
| 29 }; | |
| 30 | |
| 31 class ManagementGetAllFunction : public UIThreadExtensionFunction { | 26 class ManagementGetAllFunction : public UIThreadExtensionFunction { |
| 32 public: | 27 public: |
| 33 DECLARE_EXTENSION_FUNCTION("management.getAll", MANAGEMENT_GETALL) | 28 DECLARE_EXTENSION_FUNCTION("management.getAll", MANAGEMENT_GETALL) |
| 34 | 29 |
| 35 protected: | 30 protected: |
| 36 ~ManagementGetAllFunction() override {} | 31 ~ManagementGetAllFunction() override {} |
| 37 | 32 |
| 38 // ExtensionFunction: | 33 // ExtensionFunction: |
| 39 ResponseAction Run() override; | 34 ResponseAction Run() override; |
| 40 }; | 35 }; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 MANAGEMENT_GETPERMISSIONWARNINGSBYID) | 63 MANAGEMENT_GETPERMISSIONWARNINGSBYID) |
| 69 | 64 |
| 70 protected: | 65 protected: |
| 71 ~ManagementGetPermissionWarningsByIdFunction() override {} | 66 ~ManagementGetPermissionWarningsByIdFunction() override {} |
| 72 | 67 |
| 73 // ExtensionFunction: | 68 // ExtensionFunction: |
| 74 ResponseAction Run() override; | 69 ResponseAction Run() override; |
| 75 }; | 70 }; |
| 76 | 71 |
| 77 class ManagementGetPermissionWarningsByManifestFunction | 72 class ManagementGetPermissionWarningsByManifestFunction |
| 78 : public AsyncExtensionFunction { | 73 : public UIThreadExtensionFunction { |
| 79 public: | 74 public: |
| 80 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsByManifest", | 75 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsByManifest", |
| 81 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); | 76 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); |
| 82 | 77 |
| 83 // Called when utility process finishes. | 78 // Called when utility process finishes. |
| 84 void OnParseSuccess(std::unique_ptr<base::Value> value); | 79 void OnParseSuccess(std::unique_ptr<base::Value> value); |
| 85 void OnParseFailure(const std::string& error); | 80 void OnParseFailure(const std::string& error); |
| 86 | 81 |
| 87 protected: | 82 protected: |
| 88 ~ManagementGetPermissionWarningsByManifestFunction() override {} | 83 ~ManagementGetPermissionWarningsByManifestFunction() override {} |
| 89 | 84 |
| 90 // ExtensionFunction: | 85 // ExtensionFunction: |
| 91 bool RunAsync() override; | 86 ResponseAction Run() override; |
| 92 }; | 87 }; |
| 93 | 88 |
| 94 class ManagementLaunchAppFunction : public UIThreadExtensionFunction { | 89 class ManagementLaunchAppFunction : public UIThreadExtensionFunction { |
| 95 public: | 90 public: |
| 96 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) | 91 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) |
| 97 | 92 |
| 98 protected: | 93 protected: |
| 99 ~ManagementLaunchAppFunction() override {} | 94 ~ManagementLaunchAppFunction() override {} |
| 100 | 95 |
| 101 // ExtensionFunction: | 96 // ExtensionFunction: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 public: | 159 public: |
| 165 DECLARE_EXTENSION_FUNCTION("management.uninstallSelf", | 160 DECLARE_EXTENSION_FUNCTION("management.uninstallSelf", |
| 166 MANAGEMENT_UNINSTALLSELF); | 161 MANAGEMENT_UNINSTALLSELF); |
| 167 ManagementUninstallSelfFunction(); | 162 ManagementUninstallSelfFunction(); |
| 168 | 163 |
| 169 private: | 164 private: |
| 170 ~ManagementUninstallSelfFunction() override; | 165 ~ManagementUninstallSelfFunction() override; |
| 171 ResponseAction Run() override; | 166 ResponseAction Run() override; |
| 172 }; | 167 }; |
| 173 | 168 |
| 174 class ManagementCreateAppShortcutFunction : public AsyncManagementFunction { | 169 class ManagementCreateAppShortcutFunction : public UIThreadExtensionFunction { |
| 175 public: | 170 public: |
| 176 DECLARE_EXTENSION_FUNCTION("management.createAppShortcut", | 171 DECLARE_EXTENSION_FUNCTION("management.createAppShortcut", |
| 177 MANAGEMENT_CREATEAPPSHORTCUT); | 172 MANAGEMENT_CREATEAPPSHORTCUT); |
| 178 | 173 |
| 179 ManagementCreateAppShortcutFunction(); | 174 ManagementCreateAppShortcutFunction(); |
| 180 | 175 |
| 181 void OnCloseShortcutPrompt(bool created); | 176 void OnCloseShortcutPrompt(bool created); |
| 182 | 177 |
| 183 static void SetAutoConfirmForTest(bool should_proceed); | 178 static void SetAutoConfirmForTest(bool should_proceed); |
| 184 | 179 |
| 185 protected: | 180 protected: |
| 186 ~ManagementCreateAppShortcutFunction() override; | 181 ~ManagementCreateAppShortcutFunction() override; |
| 187 | 182 |
| 188 bool RunAsync() override; | 183 ResponseAction Run() override; |
| 189 }; | 184 }; |
| 190 | 185 |
| 191 class ManagementSetLaunchTypeFunction : public UIThreadExtensionFunction { | 186 class ManagementSetLaunchTypeFunction : public UIThreadExtensionFunction { |
| 192 public: | 187 public: |
| 193 DECLARE_EXTENSION_FUNCTION("management.setLaunchType", | 188 DECLARE_EXTENSION_FUNCTION("management.setLaunchType", |
| 194 MANAGEMENT_SETLAUNCHTYPE); | 189 MANAGEMENT_SETLAUNCHTYPE); |
| 195 | 190 |
| 196 protected: | 191 protected: |
| 197 ~ManagementSetLaunchTypeFunction() override {} | 192 ~ManagementSetLaunchTypeFunction() override {} |
| 198 | 193 |
| 199 ResponseAction Run() override; | 194 ResponseAction Run() override; |
| 200 }; | 195 }; |
| 201 | 196 |
| 202 class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction { | 197 class ManagementGenerateAppForLinkFunction : public UIThreadExtensionFunction { |
| 203 public: | 198 public: |
| 204 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink", | 199 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink", |
| 205 MANAGEMENT_GENERATEAPPFORLINK); | 200 MANAGEMENT_GENERATEAPPFORLINK); |
| 206 | 201 |
| 207 ManagementGenerateAppForLinkFunction(); | 202 ManagementGenerateAppForLinkFunction(); |
| 208 | 203 |
| 209 void FinishCreateBookmarkApp(const Extension* extension, | 204 void FinishCreateBookmarkApp(const Extension* extension, |
| 210 const WebApplicationInfo& web_app_info); | 205 const WebApplicationInfo& web_app_info); |
| 211 | 206 |
| 212 protected: | 207 protected: |
| 213 ~ManagementGenerateAppForLinkFunction() override; | 208 ~ManagementGenerateAppForLinkFunction() override; |
| 214 | 209 |
| 215 bool RunAsync() override; | 210 ResponseAction Run() override; |
| 216 | 211 |
| 217 private: | 212 private: |
| 218 std::unique_ptr<AppForLinkDelegate> app_for_link_delegate_; | 213 std::unique_ptr<AppForLinkDelegate> app_for_link_delegate_; |
| 219 }; | 214 }; |
| 220 | 215 |
| 221 class ManagementEventRouter : public ExtensionRegistryObserver { | 216 class ManagementEventRouter : public ExtensionRegistryObserver { |
| 222 public: | 217 public: |
| 223 explicit ManagementEventRouter(content::BrowserContext* context); | 218 explicit ManagementEventRouter(content::BrowserContext* context); |
| 224 ~ManagementEventRouter() override; | 219 ~ManagementEventRouter() override; |
| 225 | 220 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 std::unique_ptr<ManagementEventRouter> management_event_router_; | 277 std::unique_ptr<ManagementEventRouter> management_event_router_; |
| 283 | 278 |
| 284 std::unique_ptr<ManagementAPIDelegate> delegate_; | 279 std::unique_ptr<ManagementAPIDelegate> delegate_; |
| 285 | 280 |
| 286 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); | 281 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); |
| 287 }; | 282 }; |
| 288 | 283 |
| 289 } // namespace extensions | 284 } // namespace extensions |
| 290 | 285 |
| 291 #endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ | 286 #endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ |
| OLD | NEW |