| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_EXTENSION_WEBSTORE_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
| 12 #include "chrome/browser/extensions/extension_install_ui.h" | 12 #include "chrome/browser/extensions/extension_install_ui.h" |
| 13 #include "chrome/browser/extensions/webstore_install_helper.h" | 13 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 14 #include "chrome/browser/extensions/webstore_installer.h" | 14 #include "chrome/browser/extensions/webstore_installer.h" |
| 15 #include "chrome/common/net/gaia/google_service_auth_error.h" | 15 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 | 18 |
| 19 class ProfileSyncService; | 19 class ProfileSyncService; |
| 20 | 20 |
| 21 class WebstorePrivateApi { | 21 class WebstorePrivateApi { |
| 22 public: | 22 public: |
| 23 // Allows you to set the ProfileSyncService the function will use for | 23 // Allows you to set the ProfileSyncService the function will use for |
| 24 // testing purposes. | 24 // testing purposes. |
| 25 static void SetTestingProfileSyncService(ProfileSyncService* service); | 25 static void SetTestingProfileSyncService(ProfileSyncService* service); |
| 26 | 26 |
| 27 // Allows you to override the WebstoreInstaller delegate for testing. | 27 // Allows you to override the WebstoreInstaller delegate for testing. |
| 28 static void SetWebstoreInstallerDelegateForTesting( | 28 static void SetWebstoreInstallerDelegateForTesting( |
| 29 WebstoreInstaller::Delegate* delegate); | 29 WebstoreInstaller::Delegate* delegate); |
| 30 |
| 31 // If |allow| is true, then the extension IDs used by the SilentlyInstall |
| 32 // apitest will be trusted. |
| 33 static void SetTrustTestIDsForTesting(bool allow); |
| 30 }; | 34 }; |
| 31 | 35 |
| 32 class BeginInstallWithManifestFunction | 36 class BeginInstallWithManifestFunction |
| 33 : public AsyncExtensionFunction, | 37 : public AsyncExtensionFunction, |
| 34 public ExtensionInstallUI::Delegate, | 38 public ExtensionInstallUI::Delegate, |
| 35 public WebstoreInstallHelper::Delegate { | 39 public WebstoreInstallHelper::Delegate { |
| 36 public: | 40 public: |
| 37 BeginInstallWithManifestFunction(); | 41 BeginInstallWithManifestFunction(); |
| 38 | 42 |
| 39 // Result codes for the return value. If you change this, make sure to | 43 // Result codes for the return value. If you change this, make sure to |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 scoped_refptr<Extension> dummy_extension_; | 106 scoped_refptr<Extension> dummy_extension_; |
| 103 | 107 |
| 104 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.beginInstallWithManifest3"); | 108 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.beginInstallWithManifest3"); |
| 105 }; | 109 }; |
| 106 | 110 |
| 107 class CompleteInstallFunction : public SyncExtensionFunction { | 111 class CompleteInstallFunction : public SyncExtensionFunction { |
| 108 virtual bool RunImpl(); | 112 virtual bool RunImpl(); |
| 109 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.completeInstall"); | 113 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.completeInstall"); |
| 110 }; | 114 }; |
| 111 | 115 |
| 116 class SilentlyInstallFunction : public AsyncExtensionFunction, |
| 117 public WebstoreInstallHelper::Delegate, |
| 118 public WebstoreInstaller::Delegate { |
| 119 public: |
| 120 SilentlyInstallFunction(); |
| 121 |
| 122 // WebstoreInstallHelper::Delegate implementation. |
| 123 virtual void OnWebstoreParseSuccess( |
| 124 const std::string& id, |
| 125 const SkBitmap& icon, |
| 126 base::DictionaryValue* parsed_manifest) OVERRIDE; |
| 127 virtual void OnWebstoreParseFailure( |
| 128 const std::string& id, |
| 129 InstallHelperResultCode result_code, |
| 130 const std::string& error_message) OVERRIDE; |
| 131 |
| 132 // WebstoreInstaller::Delegate implementation. |
| 133 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
| 134 virtual void OnExtensionInstallFailure(const std::string& id, |
| 135 const std::string& error) OVERRIDE; |
| 136 |
| 137 protected: |
| 138 virtual ~SilentlyInstallFunction(); |
| 139 virtual bool RunImpl() OVERRIDE; |
| 140 |
| 141 private: |
| 142 std::string id_; |
| 143 std::string manifest_; |
| 144 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.silentlyInstall"); |
| 145 }; |
| 146 |
| 112 class GetBrowserLoginFunction : public SyncExtensionFunction { | 147 class GetBrowserLoginFunction : public SyncExtensionFunction { |
| 113 virtual bool RunImpl(); | 148 virtual bool RunImpl(); |
| 114 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin"); | 149 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getBrowserLogin"); |
| 115 }; | 150 }; |
| 116 | 151 |
| 117 class GetStoreLoginFunction : public SyncExtensionFunction { | 152 class GetStoreLoginFunction : public SyncExtensionFunction { |
| 118 virtual bool RunImpl(); | 153 virtual bool RunImpl(); |
| 119 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getStoreLogin"); | 154 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getStoreLogin"); |
| 120 }; | 155 }; |
| 121 | 156 |
| 122 class SetStoreLoginFunction : public SyncExtensionFunction { | 157 class SetStoreLoginFunction : public SyncExtensionFunction { |
| 123 virtual bool RunImpl(); | 158 virtual bool RunImpl(); |
| 124 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.setStoreLogin"); | 159 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.setStoreLogin"); |
| 125 }; | 160 }; |
| 126 | 161 |
| 127 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ | 162 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ |
| OLD | NEW |