| 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 ManagementFunction : public SyncExtensionFunction { | |
| 27 protected: | |
| 28 ~ManagementFunction() override {} | |
| 29 }; | |
| 30 | |
| 31 class AsyncManagementFunction : public AsyncExtensionFunction { | 26 class AsyncManagementFunction : public AsyncExtensionFunction { |
| 32 protected: | 27 protected: |
| 33 ~AsyncManagementFunction() override {} | 28 ~AsyncManagementFunction() override {} |
| 34 }; | 29 }; |
| 35 | 30 |
| 36 class ManagementGetAllFunction : public ManagementFunction { | 31 class ManagementGetAllFunction : public UIThreadExtensionFunction { |
| 37 public: | 32 public: |
| 38 DECLARE_EXTENSION_FUNCTION("management.getAll", MANAGEMENT_GETALL) | 33 DECLARE_EXTENSION_FUNCTION("management.getAll", MANAGEMENT_GETALL) |
| 39 | 34 |
| 40 protected: | 35 protected: |
| 41 ~ManagementGetAllFunction() override {} | 36 ~ManagementGetAllFunction() override {} |
| 42 | 37 |
| 43 // ExtensionFunction: | 38 // ExtensionFunction: |
| 44 bool RunSync() override; | 39 ResponseAction Run() override; |
| 45 }; | 40 }; |
| 46 | 41 |
| 47 class ManagementGetFunction : public ManagementFunction { | 42 class ManagementGetFunction : public UIThreadExtensionFunction { |
| 48 public: | 43 public: |
| 49 DECLARE_EXTENSION_FUNCTION("management.get", MANAGEMENT_GET) | 44 DECLARE_EXTENSION_FUNCTION("management.get", MANAGEMENT_GET) |
| 50 | 45 |
| 51 protected: | 46 protected: |
| 52 ~ManagementGetFunction() override {} | 47 ~ManagementGetFunction() override {} |
| 53 | 48 |
| 54 // ExtensionFunction: | 49 // ExtensionFunction: |
| 55 bool RunSync() override; | 50 ResponseAction Run() override; |
| 56 }; | 51 }; |
| 57 | 52 |
| 58 class ManagementGetSelfFunction : public ManagementFunction { | 53 class ManagementGetSelfFunction : public UIThreadExtensionFunction { |
| 59 public: | 54 public: |
| 60 DECLARE_EXTENSION_FUNCTION("management.getSelf", MANAGEMENT_GETSELF) | 55 DECLARE_EXTENSION_FUNCTION("management.getSelf", MANAGEMENT_GETSELF) |
| 61 | 56 |
| 62 protected: | 57 protected: |
| 63 ~ManagementGetSelfFunction() override {} | 58 ~ManagementGetSelfFunction() override {} |
| 64 | 59 |
| 65 // ExtensionFunction: | 60 // ExtensionFunction: |
| 66 bool RunSync() override; | 61 ResponseAction Run() override; |
| 67 }; | 62 }; |
| 68 | 63 |
| 69 class ManagementGetPermissionWarningsByIdFunction : public ManagementFunction { | 64 class ManagementGetPermissionWarningsByIdFunction |
| 65 : public UIThreadExtensionFunction { |
| 70 public: | 66 public: |
| 71 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsById", | 67 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsById", |
| 72 MANAGEMENT_GETPERMISSIONWARNINGSBYID) | 68 MANAGEMENT_GETPERMISSIONWARNINGSBYID) |
| 73 | 69 |
| 74 protected: | 70 protected: |
| 75 ~ManagementGetPermissionWarningsByIdFunction() override {} | 71 ~ManagementGetPermissionWarningsByIdFunction() override {} |
| 76 | 72 |
| 77 // ExtensionFunction: | 73 // ExtensionFunction: |
| 78 bool RunSync() override; | 74 ResponseAction Run() override; |
| 79 }; | 75 }; |
| 80 | 76 |
| 81 class ManagementGetPermissionWarningsByManifestFunction | 77 class ManagementGetPermissionWarningsByManifestFunction |
| 82 : public AsyncExtensionFunction { | 78 : public AsyncExtensionFunction { |
| 83 public: | 79 public: |
| 84 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsByManifest", | 80 DECLARE_EXTENSION_FUNCTION("management.getPermissionWarningsByManifest", |
| 85 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); | 81 MANAGEMENT_GETPERMISSIONWARNINGSBYMANIFEST); |
| 86 | 82 |
| 87 // Called when utility process finishes. | 83 // Called when utility process finishes. |
| 88 void OnParseSuccess(std::unique_ptr<base::Value> value); | 84 void OnParseSuccess(std::unique_ptr<base::Value> value); |
| 89 void OnParseFailure(const std::string& error); | 85 void OnParseFailure(const std::string& error); |
| 90 | 86 |
| 91 protected: | 87 protected: |
| 92 ~ManagementGetPermissionWarningsByManifestFunction() override {} | 88 ~ManagementGetPermissionWarningsByManifestFunction() override {} |
| 93 | 89 |
| 94 // ExtensionFunction: | 90 // ExtensionFunction: |
| 95 bool RunAsync() override; | 91 bool RunAsync() override; |
| 96 }; | 92 }; |
| 97 | 93 |
| 98 class ManagementLaunchAppFunction : public ManagementFunction { | 94 class ManagementLaunchAppFunction : public UIThreadExtensionFunction { |
| 99 public: | 95 public: |
| 100 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) | 96 DECLARE_EXTENSION_FUNCTION("management.launchApp", MANAGEMENT_LAUNCHAPP) |
| 101 | 97 |
| 102 protected: | 98 protected: |
| 103 ~ManagementLaunchAppFunction() override {} | 99 ~ManagementLaunchAppFunction() override {} |
| 104 | 100 |
| 105 // ExtensionFunction: | 101 // ExtensionFunction: |
| 106 bool RunSync() override; | 102 ResponseAction Run() override; |
| 107 }; | 103 }; |
| 108 | 104 |
| 109 class ManagementSetEnabledFunction : public UIThreadExtensionFunction { | 105 class ManagementSetEnabledFunction : public UIThreadExtensionFunction { |
| 110 public: | 106 public: |
| 111 DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED) | 107 DECLARE_EXTENSION_FUNCTION("management.setEnabled", MANAGEMENT_SETENABLED) |
| 112 | 108 |
| 113 ManagementSetEnabledFunction(); | 109 ManagementSetEnabledFunction(); |
| 114 | 110 |
| 115 protected: | 111 protected: |
| 116 ~ManagementSetEnabledFunction() override; | 112 ~ManagementSetEnabledFunction() override; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 void OnCloseShortcutPrompt(bool created); | 181 void OnCloseShortcutPrompt(bool created); |
| 186 | 182 |
| 187 static void SetAutoConfirmForTest(bool should_proceed); | 183 static void SetAutoConfirmForTest(bool should_proceed); |
| 188 | 184 |
| 189 protected: | 185 protected: |
| 190 ~ManagementCreateAppShortcutFunction() override; | 186 ~ManagementCreateAppShortcutFunction() override; |
| 191 | 187 |
| 192 bool RunAsync() override; | 188 bool RunAsync() override; |
| 193 }; | 189 }; |
| 194 | 190 |
| 195 class ManagementSetLaunchTypeFunction : public ManagementFunction { | 191 class ManagementSetLaunchTypeFunction : public UIThreadExtensionFunction { |
| 196 public: | 192 public: |
| 197 DECLARE_EXTENSION_FUNCTION("management.setLaunchType", | 193 DECLARE_EXTENSION_FUNCTION("management.setLaunchType", |
| 198 MANAGEMENT_SETLAUNCHTYPE); | 194 MANAGEMENT_SETLAUNCHTYPE); |
| 199 | 195 |
| 200 protected: | 196 protected: |
| 201 ~ManagementSetLaunchTypeFunction() override {} | 197 ~ManagementSetLaunchTypeFunction() override {} |
| 202 | 198 |
| 203 bool RunSync() override; | 199 ResponseAction Run() override; |
| 204 }; | 200 }; |
| 205 | 201 |
| 206 class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction { | 202 class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction { |
| 207 public: | 203 public: |
| 208 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink", | 204 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink", |
| 209 MANAGEMENT_GENERATEAPPFORLINK); | 205 MANAGEMENT_GENERATEAPPFORLINK); |
| 210 | 206 |
| 211 ManagementGenerateAppForLinkFunction(); | 207 ManagementGenerateAppForLinkFunction(); |
| 212 | 208 |
| 213 void FinishCreateBookmarkApp(const Extension* extension, | 209 void FinishCreateBookmarkApp(const Extension* extension, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 std::unique_ptr<ManagementEventRouter> management_event_router_; | 282 std::unique_ptr<ManagementEventRouter> management_event_router_; |
| 287 | 283 |
| 288 std::unique_ptr<ManagementAPIDelegate> delegate_; | 284 std::unique_ptr<ManagementAPIDelegate> delegate_; |
| 289 | 285 |
| 290 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); | 286 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); |
| 291 }; | 287 }; |
| 292 | 288 |
| 293 } // namespace extensions | 289 } // namespace extensions |
| 294 | 290 |
| 295 #endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ | 291 #endif // EXTENSIONS_BROWSER_API_MANAGEMENT_MANAGEMENT_API_H_ |
| OLD | NEW |