| 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 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 "chrome/browser/extensions/event_router.h" | 9 #include "chrome/browser/extensions/event_router.h" |
| 10 #include "chrome/browser/extensions/extension_function.h" | 10 #include "chrome/browser/extensions/extension_function.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 ExtensionService* service(); | 24 ExtensionService* service(); |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 class AsyncExtensionManagementFunction : public AsyncExtensionFunction { | 27 class AsyncExtensionManagementFunction : public AsyncExtensionFunction { |
| 28 protected: | 28 protected: |
| 29 virtual ~AsyncExtensionManagementFunction() {} | 29 virtual ~AsyncExtensionManagementFunction() {} |
| 30 | 30 |
| 31 ExtensionService* service(); | 31 ExtensionService* service(); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class GetAllExtensionsFunction : public ExtensionManagementFunction { | 34 class ManagementGetAllFunction : public ExtensionManagementFunction { |
| 35 public: | 35 public: |
| 36 DECLARE_EXTENSION_FUNCTION_NAME("management.getAll"); | 36 DECLARE_EXTENSION_FUNCTION_NAME("management.getAll"); |
| 37 | 37 |
| 38 protected: | 38 protected: |
| 39 virtual ~GetAllExtensionsFunction() {} | 39 virtual ~ManagementGetAllFunction() {} |
| 40 | 40 |
| 41 // ExtensionFunction: | 41 // ExtensionFunction: |
| 42 virtual bool RunImpl() OVERRIDE; | 42 virtual bool RunImpl() OVERRIDE; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 class GetExtensionByIdFunction : public ExtensionManagementFunction { | 45 class ManagementGetFunction : public ExtensionManagementFunction { |
| 46 public: | 46 public: |
| 47 DECLARE_EXTENSION_FUNCTION_NAME("management.get"); | 47 DECLARE_EXTENSION_FUNCTION_NAME("management.get"); |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 virtual ~GetExtensionByIdFunction() {} | 50 virtual ~ManagementGetFunction() {} |
| 51 | 51 |
| 52 // ExtensionFunction: | 52 // ExtensionFunction: |
| 53 virtual bool RunImpl() OVERRIDE; | 53 virtual bool RunImpl() OVERRIDE; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 class GetPermissionWarningsByIdFunction : public ExtensionManagementFunction { | 56 class ManagementGetPermissionWarningsByIdFunction |
| 57 : public ExtensionManagementFunction { |
| 57 public: | 58 public: |
| 58 DECLARE_EXTENSION_FUNCTION_NAME("management.getPermissionWarningsById"); | 59 DECLARE_EXTENSION_FUNCTION_NAME("management.getPermissionWarningsById"); |
| 59 | 60 |
| 60 protected: | 61 protected: |
| 61 virtual ~GetPermissionWarningsByIdFunction() {} | 62 virtual ~ManagementGetPermissionWarningsByIdFunction() {} |
| 62 | 63 |
| 63 // ExtensionFunction: | 64 // ExtensionFunction: |
| 64 virtual bool RunImpl() OVERRIDE; | 65 virtual bool RunImpl() OVERRIDE; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 class GetPermissionWarningsByManifestFunction : public AsyncExtensionFunction { | 68 class ManagementGetPermissionWarningsByManifestFunction |
| 69 : public AsyncExtensionFunction { |
| 68 public: | 70 public: |
| 69 DECLARE_EXTENSION_FUNCTION_NAME( | 71 DECLARE_EXTENSION_FUNCTION_NAME( |
| 70 "management.getPermissionWarningsByManifest"); | 72 "management.getPermissionWarningsByManifest"); |
| 71 | 73 |
| 72 // Called when utility process finishes. | 74 // Called when utility process finishes. |
| 73 void OnParseSuccess(base::DictionaryValue* parsed_manifest); | 75 void OnParseSuccess(base::DictionaryValue* parsed_manifest); |
| 74 void OnParseFailure(const std::string& error); | 76 void OnParseFailure(const std::string& error); |
| 75 | 77 |
| 76 protected: | 78 protected: |
| 77 virtual ~GetPermissionWarningsByManifestFunction() {} | 79 virtual ~ManagementGetPermissionWarningsByManifestFunction() {} |
| 78 | 80 |
| 79 // ExtensionFunction: | 81 // ExtensionFunction: |
| 80 virtual bool RunImpl() OVERRIDE; | 82 virtual bool RunImpl() OVERRIDE; |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 class LaunchAppFunction : public ExtensionManagementFunction { | 85 class ManagementLaunchAppFunction : public ExtensionManagementFunction { |
| 84 public: | 86 public: |
| 85 DECLARE_EXTENSION_FUNCTION_NAME("management.launchApp"); | 87 DECLARE_EXTENSION_FUNCTION_NAME("management.launchApp"); |
| 86 | 88 |
| 87 protected: | 89 protected: |
| 88 virtual ~LaunchAppFunction() {} | 90 virtual ~ManagementLaunchAppFunction() {} |
| 89 | 91 |
| 90 // ExtensionFunction: | 92 // ExtensionFunction: |
| 91 virtual bool RunImpl() OVERRIDE; | 93 virtual bool RunImpl() OVERRIDE; |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 class SetEnabledFunction : public AsyncExtensionManagementFunction, | 96 class ManagementSetEnabledFunction : public AsyncExtensionManagementFunction, |
| 95 public ExtensionInstallPrompt::Delegate { | 97 public ExtensionInstallPrompt::Delegate { |
| 96 public: | 98 public: |
| 97 DECLARE_EXTENSION_FUNCTION_NAME("management.setEnabled"); | 99 DECLARE_EXTENSION_FUNCTION_NAME("management.setEnabled"); |
| 98 | 100 |
| 99 SetEnabledFunction(); | 101 ManagementSetEnabledFunction(); |
| 100 | 102 |
| 101 protected: | 103 protected: |
| 102 virtual ~SetEnabledFunction(); | 104 virtual ~ManagementSetEnabledFunction(); |
| 103 | 105 |
| 104 // ExtensionFunction: | 106 // ExtensionFunction: |
| 105 virtual bool RunImpl() OVERRIDE; | 107 virtual bool RunImpl() OVERRIDE; |
| 106 | 108 |
| 107 // ExtensionInstallPrompt::Delegate. | 109 // ExtensionInstallPrompt::Delegate. |
| 108 virtual void InstallUIProceed() OVERRIDE; | 110 virtual void InstallUIProceed() OVERRIDE; |
| 109 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 111 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
| 110 | 112 |
| 111 private: | 113 private: |
| 112 std::string extension_id_; | 114 std::string extension_id_; |
| 113 | 115 |
| 114 // Used for prompting to re-enable items with permissions escalation updates. | 116 // Used for prompting to re-enable items with permissions escalation updates. |
| 115 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | 117 scoped_ptr<ExtensionInstallPrompt> install_prompt_; |
| 116 }; | 118 }; |
| 117 | 119 |
| 118 class UninstallFunction : public AsyncExtensionManagementFunction, | 120 class ManagementUninstallFunction : public AsyncExtensionManagementFunction, |
| 119 public ExtensionUninstallDialog::Delegate { | 121 public ExtensionUninstallDialog::Delegate { |
| 120 public: | 122 public: |
| 121 DECLARE_EXTENSION_FUNCTION_NAME("management.uninstall"); | 123 DECLARE_EXTENSION_FUNCTION_NAME("management.uninstall"); |
| 122 | 124 |
| 123 UninstallFunction(); | 125 ManagementUninstallFunction(); |
| 124 static void SetAutoConfirmForTest(bool should_proceed); | 126 static void SetAutoConfirmForTest(bool should_proceed); |
| 125 | 127 |
| 126 // ExtensionUninstallDialog::Delegate implementation. | 128 // ExtensionUninstallDialog::Delegate implementation. |
| 127 virtual void ExtensionUninstallAccepted() OVERRIDE; | 129 virtual void ExtensionUninstallAccepted() OVERRIDE; |
| 128 virtual void ExtensionUninstallCanceled() OVERRIDE; | 130 virtual void ExtensionUninstallCanceled() OVERRIDE; |
| 129 | 131 |
| 130 private: | 132 private: |
| 131 virtual ~UninstallFunction(); | 133 virtual ~ManagementUninstallFunction(); |
| 132 | 134 |
| 133 virtual bool RunImpl() OVERRIDE; | 135 virtual bool RunImpl() OVERRIDE; |
| 134 | 136 |
| 135 // If should_uninstall is true, this method does the actual uninstall. | 137 // If should_uninstall is true, this method does the actual uninstall. |
| 136 // If |show_uninstall_dialog|, then this function will be called by one of the | 138 // If |show_uninstall_dialog|, then this function will be called by one of the |
| 137 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunImpl. | 139 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunImpl. |
| 138 void Finish(bool should_uninstall); | 140 void Finish(bool should_uninstall); |
| 139 | 141 |
| 140 std::string extension_id_; | 142 std::string extension_id_; |
| 141 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 143 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 OVERRIDE; | 175 OVERRIDE; |
| 174 | 176 |
| 175 private: | 177 private: |
| 176 Profile* profile_; | 178 Profile* profile_; |
| 177 | 179 |
| 178 // Created lazily upon OnListenerAdded. | 180 // Created lazily upon OnListenerAdded. |
| 179 scoped_ptr<ExtensionManagementEventRouter> management_event_router_; | 181 scoped_ptr<ExtensionManagementEventRouter> management_event_router_; |
| 180 }; | 182 }; |
| 181 | 183 |
| 182 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 184 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
| OLD | NEW |