| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_H__ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_H__ | |
| 7 | |
| 8 #include "base/compiler_specific.h" | |
| 9 #include "chrome/browser/extensions/extension_function.h" | |
| 10 #include "chrome/browser/extensions/extension_install_prompt.h" | |
| 11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | |
| 15 class ExtensionService; | |
| 16 class ExtensionUninstallDialog; | |
| 17 | |
| 18 class ExtensionManagementFunction : public SyncExtensionFunction { | |
| 19 protected: | |
| 20 virtual ~ExtensionManagementFunction() {} | |
| 21 | |
| 22 ExtensionService* service(); | |
| 23 }; | |
| 24 | |
| 25 class AsyncExtensionManagementFunction : public AsyncExtensionFunction { | |
| 26 protected: | |
| 27 virtual ~AsyncExtensionManagementFunction() {} | |
| 28 | |
| 29 ExtensionService* service(); | |
| 30 }; | |
| 31 | |
| 32 class GetAllExtensionsFunction : public ExtensionManagementFunction { | |
| 33 public: | |
| 34 DECLARE_EXTENSION_FUNCTION_NAME("management.getAll"); | |
| 35 | |
| 36 protected: | |
| 37 virtual ~GetAllExtensionsFunction() {} | |
| 38 | |
| 39 // ExtensionFunction: | |
| 40 virtual bool RunImpl() OVERRIDE; | |
| 41 }; | |
| 42 | |
| 43 class GetExtensionByIdFunction : public ExtensionManagementFunction { | |
| 44 public: | |
| 45 DECLARE_EXTENSION_FUNCTION_NAME("management.get"); | |
| 46 | |
| 47 protected: | |
| 48 virtual ~GetExtensionByIdFunction() {} | |
| 49 | |
| 50 // ExtensionFunction: | |
| 51 virtual bool RunImpl() OVERRIDE; | |
| 52 }; | |
| 53 | |
| 54 class GetPermissionWarningsByIdFunction : public ExtensionManagementFunction { | |
| 55 public: | |
| 56 DECLARE_EXTENSION_FUNCTION_NAME("management.getPermissionWarningsById"); | |
| 57 | |
| 58 protected: | |
| 59 virtual ~GetPermissionWarningsByIdFunction() {} | |
| 60 | |
| 61 // ExtensionFunction: | |
| 62 virtual bool RunImpl() OVERRIDE; | |
| 63 }; | |
| 64 | |
| 65 class GetPermissionWarningsByManifestFunction : public AsyncExtensionFunction { | |
| 66 public: | |
| 67 DECLARE_EXTENSION_FUNCTION_NAME( | |
| 68 "management.getPermissionWarningsByManifest"); | |
| 69 | |
| 70 // Called when utility process finishes. | |
| 71 void OnParseSuccess(base::DictionaryValue* parsed_manifest); | |
| 72 void OnParseFailure(const std::string& error); | |
| 73 | |
| 74 protected: | |
| 75 virtual ~GetPermissionWarningsByManifestFunction() {} | |
| 76 | |
| 77 // ExtensionFunction: | |
| 78 virtual bool RunImpl() OVERRIDE; | |
| 79 }; | |
| 80 | |
| 81 class LaunchAppFunction : public ExtensionManagementFunction { | |
| 82 public: | |
| 83 DECLARE_EXTENSION_FUNCTION_NAME("management.launchApp"); | |
| 84 | |
| 85 protected: | |
| 86 virtual ~LaunchAppFunction() {} | |
| 87 | |
| 88 // ExtensionFunction: | |
| 89 virtual bool RunImpl() OVERRIDE; | |
| 90 }; | |
| 91 | |
| 92 class SetEnabledFunction : public AsyncExtensionManagementFunction, | |
| 93 public ExtensionInstallPrompt::Delegate { | |
| 94 public: | |
| 95 DECLARE_EXTENSION_FUNCTION_NAME("management.setEnabled"); | |
| 96 | |
| 97 SetEnabledFunction(); | |
| 98 | |
| 99 protected: | |
| 100 virtual ~SetEnabledFunction(); | |
| 101 | |
| 102 // ExtensionFunction: | |
| 103 virtual bool RunImpl() OVERRIDE; | |
| 104 | |
| 105 // ExtensionInstallPrompt::Delegate. | |
| 106 virtual void InstallUIProceed() OVERRIDE; | |
| 107 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | |
| 108 | |
| 109 private: | |
| 110 std::string extension_id_; | |
| 111 | |
| 112 // Used for prompting to re-enable items with permissions escalation updates. | |
| 113 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | |
| 114 }; | |
| 115 | |
| 116 class UninstallFunction : public AsyncExtensionManagementFunction, | |
| 117 public ExtensionUninstallDialog::Delegate { | |
| 118 public: | |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("management.uninstall"); | |
| 120 | |
| 121 UninstallFunction(); | |
| 122 static void SetAutoConfirmForTest(bool should_proceed); | |
| 123 | |
| 124 // ExtensionUninstallDialog::Delegate implementation. | |
| 125 virtual void ExtensionUninstallAccepted() OVERRIDE; | |
| 126 virtual void ExtensionUninstallCanceled() OVERRIDE; | |
| 127 | |
| 128 private: | |
| 129 virtual ~UninstallFunction(); | |
| 130 | |
| 131 virtual bool RunImpl() OVERRIDE; | |
| 132 | |
| 133 // If should_uninstall is true, this method does the actual uninstall. | |
| 134 // If |show_uninstall_dialog|, then this function will be called by one of the | |
| 135 // Accepted/Canceled callbacks. Otherwise, it's called directly from RunImpl. | |
| 136 void Finish(bool should_uninstall); | |
| 137 | |
| 138 std::string extension_id_; | |
| 139 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | |
| 140 }; | |
| 141 | |
| 142 class ExtensionManagementEventRouter : public content::NotificationObserver { | |
| 143 public: | |
| 144 explicit ExtensionManagementEventRouter(Profile* profile); | |
| 145 virtual ~ExtensionManagementEventRouter(); | |
| 146 | |
| 147 void Init(); | |
| 148 | |
| 149 private: | |
| 150 // content::NotificationObserver implementation. | |
| 151 virtual void Observe(int type, | |
| 152 const content::NotificationSource& source, | |
| 153 const content::NotificationDetails& details) OVERRIDE; | |
| 154 | |
| 155 content::NotificationRegistrar registrar_; | |
| 156 | |
| 157 Profile* profile_; | |
| 158 | |
| 159 DISALLOW_COPY_AND_ASSIGN(ExtensionManagementEventRouter); | |
| 160 }; | |
| 161 | |
| 162 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_MANAGEMENT_API_H__ | |
| OLD | NEW |