| 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_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/extensions/active_install_data.h" | 10 #include "chrome/browser/extensions/active_install_data.h" |
| 11 #include "chrome/browser/extensions/chrome_extension_function.h" | 11 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 12 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
| 12 #include "chrome/browser/extensions/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 13 #include "chrome/browser/extensions/webstore_install_helper.h" | 14 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 14 #include "chrome/browser/extensions/webstore_installer.h" | 15 #include "chrome/browser/extensions/webstore_installer.h" |
| 15 #include "chrome/common/extensions/api/webstore_private.h" | 16 #include "chrome/common/extensions/api/webstore_private.h" |
| 16 #include "chrome/common/extensions/webstore_install_result.h" | 17 #include "chrome/common/extensions/webstore_install_result.h" |
| 17 #include "content/public/browser/gpu_data_manager_observer.h" | 18 #include "content/public/browser/gpu_data_manager_observer.h" |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 WebstoreInstaller::Delegate* delegate); | 38 WebstoreInstaller::Delegate* delegate); |
| 38 | 39 |
| 39 // Gets the pending approval for the |extension_id| in |profile|. Pending | 40 // Gets the pending approval for the |extension_id| in |profile|. Pending |
| 40 // approvals are held between the calls to beginInstallWithManifest and | 41 // approvals are held between the calls to beginInstallWithManifest and |
| 41 // completeInstall. This should only be used for testing. | 42 // completeInstall. This should only be used for testing. |
| 42 static scoped_ptr<WebstoreInstaller::Approval> PopApprovalForTesting( | 43 static scoped_ptr<WebstoreInstaller::Approval> PopApprovalForTesting( |
| 43 Profile* profile, const std::string& extension_id); | 44 Profile* profile, const std::string& extension_id); |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 class WebstorePrivateBeginInstallWithManifest3Function | 47 class WebstorePrivateBeginInstallWithManifest3Function |
| 47 : public ChromeAsyncExtensionFunction, | 48 : public UIThreadExtensionFunction, |
| 48 public ExtensionInstallPrompt::Delegate, | 49 public ExtensionInstallPrompt::Delegate, |
| 49 public WebstoreInstallHelper::Delegate { | 50 public WebstoreInstallHelper::Delegate { |
| 50 public: | 51 public: |
| 51 DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", | 52 DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", |
| 52 WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) | 53 WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) |
| 53 | 54 |
| 54 // Result codes for the return value. If you change this, make sure to | 55 // Result codes for the return value. If you change this, make sure to |
| 55 // update the description for the beginInstallWithManifest3 callback in | 56 // update the description for the beginInstallWithManifest3 callback in |
| 56 // the extension API JSON. | 57 // the extension API JSON. |
| 57 enum ResultCode { | 58 enum ResultCode { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 77 | 78 |
| 78 // Invalid icon url. | 79 // Invalid icon url. |
| 79 INVALID_ICON_URL, | 80 INVALID_ICON_URL, |
| 80 | 81 |
| 81 // An extension with the same extension id has already been installed. | 82 // An extension with the same extension id has already been installed. |
| 82 ALREADY_INSTALLED, | 83 ALREADY_INSTALLED, |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 WebstorePrivateBeginInstallWithManifest3Function(); | 86 WebstorePrivateBeginInstallWithManifest3Function(); |
| 86 | 87 |
| 88 private: |
| 89 ~WebstorePrivateBeginInstallWithManifest3Function() override; |
| 90 |
| 91 // ExtensionFunction: |
| 92 ExtensionFunction::ResponseAction Run() override; |
| 93 |
| 87 // WebstoreInstallHelper::Delegate: | 94 // WebstoreInstallHelper::Delegate: |
| 88 void OnWebstoreParseSuccess(const std::string& id, | 95 void OnWebstoreParseSuccess(const std::string& id, |
| 89 const SkBitmap& icon, | 96 const SkBitmap& icon, |
| 90 base::DictionaryValue* parsed_manifest) override; | 97 base::DictionaryValue* parsed_manifest) override; |
| 91 void OnWebstoreParseFailure(const std::string& id, | 98 void OnWebstoreParseFailure(const std::string& id, |
| 92 InstallHelperResultCode result_code, | 99 InstallHelperResultCode result_code, |
| 93 const std::string& error_message) override; | 100 const std::string& error_message) override; |
| 94 | 101 |
| 95 // ExtensionInstallPrompt::Delegate: | 102 // ExtensionInstallPrompt::Delegate: |
| 96 void InstallUIProceed() override; | 103 void InstallUIProceed() override; |
| 97 void InstallUIAbort(bool user_initiated) override; | 104 void InstallUIAbort(bool user_initiated) override; |
| 98 | 105 |
| 99 protected: | 106 // Response helpers. |
| 100 ~WebstorePrivateBeginInstallWithManifest3Function() override; | 107 const char* ResultCodeToString(ResultCode code) const; |
| 108 ExtensionFunction::ResponseValue BuildResponseForSuccess(); |
| 109 ExtensionFunction::ResponseValue BuildResponseForError( |
| 110 ResultCode code, const std::string& error); |
| 101 | 111 |
| 102 // ExtensionFunction: | 112 // Convenience response methods. |
| 103 bool RunAsync() override; | 113 ExtensionFunction::ResponseAction RespondNowWithError( |
| 114 ResultCode code, const std::string& error); |
| 115 void RespondWithSuccess(); |
| 116 void RespondWithError(ResultCode code, const std::string& error); |
| 104 | 117 |
| 105 // Sets the result_ as a string based on |code|. | 118 ChromeExtensionFunctionDetails chrome_details_; |
| 106 void SetResultCode(ResultCode code); | |
| 107 | 119 |
| 108 private: | 120 // This stores the input parameters to the function. |
| 109 const char* ResultCodeToString(ResultCode code); | |
| 110 | |
| 111 // These store the input parameters to the function. | |
| 112 scoped_ptr<api::webstore_private::BeginInstallWithManifest3::Params> params_; | 121 scoped_ptr<api::webstore_private::BeginInstallWithManifest3::Params> params_; |
| 113 | 122 |
| 114 // The results of parsing manifest_ and icon_data_ go into these two. | 123 // The results of parsing manifest_ and icon_data_ go into these two. |
| 115 scoped_ptr<base::DictionaryValue> parsed_manifest_; | 124 scoped_ptr<base::DictionaryValue> parsed_manifest_; |
| 116 SkBitmap icon_; | 125 SkBitmap icon_; |
| 117 | 126 |
| 118 // A dummy Extension object we create for the purposes of using | 127 // A dummy Extension object we create for the purposes of using |
| 119 // ExtensionInstallPrompt to prompt for confirmation of the install. | 128 // ExtensionInstallPrompt to prompt for confirmation of the install. |
| 120 scoped_refptr<extensions::Extension> dummy_extension_; | 129 scoped_refptr<extensions::Extension> dummy_extension_; |
| 121 | 130 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 protected: | 309 protected: |
| 301 ~WebstorePrivateGetEphemeralAppsEnabledFunction() override; | 310 ~WebstorePrivateGetEphemeralAppsEnabledFunction() override; |
| 302 | 311 |
| 303 // ExtensionFunction: | 312 // ExtensionFunction: |
| 304 bool RunSync() override; | 313 bool RunSync() override; |
| 305 }; | 314 }; |
| 306 | 315 |
| 307 } // namespace extensions | 316 } // namespace extensions |
| 308 | 317 |
| 309 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H
_ | 318 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H
_ |
| OLD | NEW |