| 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/bundle_installer.h" | 11 #include "chrome/browser/extensions/bundle_installer.h" |
| 12 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 13 #include "chrome/browser/extensions/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 14 #include "chrome/browser/extensions/webstore_install_helper.h" | 14 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 15 #include "chrome/browser/extensions/webstore_installer.h" | 15 #include "chrome/browser/extensions/webstore_installer.h" |
| 16 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 17 #include "chrome/common/extensions/api/webstore_private.h" | 16 #include "chrome/common/extensions/api/webstore_private.h" |
| 18 #include "chrome/common/extensions/webstore_install_result.h" | 17 #include "chrome/common/extensions/webstore_install_result.h" |
| 19 #include "components/signin/core/browser/signin_tracker.h" | |
| 20 #include "content/public/browser/gpu_data_manager_observer.h" | 18 #include "content/public/browser/gpu_data_manager_observer.h" |
| 21 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 23 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
| 24 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| 25 | 23 |
| 26 class ProfileSyncService; | 24 class ProfileSyncService; |
| 27 class SigninManagerBase; | |
| 28 | 25 |
| 29 namespace content { | 26 namespace content { |
| 30 class GpuDataManager; | 27 class GpuDataManager; |
| 31 } | 28 } |
| 32 | 29 |
| 33 class GPUFeatureChecker; | 30 class GPUFeatureChecker; |
| 34 | 31 |
| 35 namespace extensions { | 32 namespace extensions { |
| 36 | 33 |
| 37 class WebstorePrivateApi { | 34 class WebstorePrivateApi { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const api::webstore_private::InstallBundle::Params& details, | 69 const api::webstore_private::InstallBundle::Params& details, |
| 73 extensions::BundleInstaller::ItemList* items); | 70 extensions::BundleInstaller::ItemList* items); |
| 74 | 71 |
| 75 private: | 72 private: |
| 76 scoped_refptr<extensions::BundleInstaller> bundle_; | 73 scoped_refptr<extensions::BundleInstaller> bundle_; |
| 77 }; | 74 }; |
| 78 | 75 |
| 79 class WebstorePrivateBeginInstallWithManifest3Function | 76 class WebstorePrivateBeginInstallWithManifest3Function |
| 80 : public ChromeAsyncExtensionFunction, | 77 : public ChromeAsyncExtensionFunction, |
| 81 public ExtensionInstallPrompt::Delegate, | 78 public ExtensionInstallPrompt::Delegate, |
| 82 public WebstoreInstallHelper::Delegate, | 79 public WebstoreInstallHelper::Delegate { |
| 83 public SigninTracker::Observer { | |
| 84 public: | 80 public: |
| 85 DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", | 81 DECLARE_EXTENSION_FUNCTION("webstorePrivate.beginInstallWithManifest3", |
| 86 WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) | 82 WEBSTOREPRIVATE_BEGININSTALLWITHMANIFEST3) |
| 87 | 83 |
| 88 // Result codes for the return value. If you change this, make sure to | 84 // Result codes for the return value. If you change this, make sure to |
| 89 // update the description for the beginInstallWithManifest3 callback in | 85 // update the description for the beginInstallWithManifest3 callback in |
| 90 // the extension API JSON. | 86 // the extension API JSON. |
| 91 enum ResultCode { | 87 enum ResultCode { |
| 92 ERROR_NONE = 0, | 88 ERROR_NONE = 0, |
| 93 | 89 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 105 | 101 |
| 106 // The extension id was invalid. | 102 // The extension id was invalid. |
| 107 INVALID_ID, | 103 INVALID_ID, |
| 108 | 104 |
| 109 // The page does not have permission to call this function. | 105 // The page does not have permission to call this function. |
| 110 PERMISSION_DENIED, | 106 PERMISSION_DENIED, |
| 111 | 107 |
| 112 // Invalid icon url. | 108 // Invalid icon url. |
| 113 INVALID_ICON_URL, | 109 INVALID_ICON_URL, |
| 114 | 110 |
| 115 // Signin has failed. | |
| 116 SIGNIN_FAILED, | |
| 117 | |
| 118 // An extension with the same extension id has already been installed. | 111 // An extension with the same extension id has already been installed. |
| 119 ALREADY_INSTALLED, | 112 ALREADY_INSTALLED, |
| 120 }; | 113 }; |
| 121 | 114 |
| 122 WebstorePrivateBeginInstallWithManifest3Function(); | 115 WebstorePrivateBeginInstallWithManifest3Function(); |
| 123 | 116 |
| 124 // WebstoreInstallHelper::Delegate: | 117 // WebstoreInstallHelper::Delegate: |
| 125 virtual void OnWebstoreParseSuccess( | 118 virtual void OnWebstoreParseSuccess( |
| 126 const std::string& id, | 119 const std::string& id, |
| 127 const SkBitmap& icon, | 120 const SkBitmap& icon, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 138 protected: | 131 protected: |
| 139 virtual ~WebstorePrivateBeginInstallWithManifest3Function(); | 132 virtual ~WebstorePrivateBeginInstallWithManifest3Function(); |
| 140 | 133 |
| 141 // ExtensionFunction: | 134 // ExtensionFunction: |
| 142 virtual bool RunAsync() OVERRIDE; | 135 virtual bool RunAsync() OVERRIDE; |
| 143 | 136 |
| 144 // Sets the result_ as a string based on |code|. | 137 // Sets the result_ as a string based on |code|. |
| 145 void SetResultCode(ResultCode code); | 138 void SetResultCode(ResultCode code); |
| 146 | 139 |
| 147 private: | 140 private: |
| 148 // SigninTracker::Observer override. | |
| 149 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; | |
| 150 virtual void SigninSuccess() OVERRIDE; | |
| 151 virtual void MergeSessionComplete( | |
| 152 const GoogleServiceAuthError& error) OVERRIDE; | |
| 153 | |
| 154 // Called when signin is complete or not needed. | |
| 155 void SigninCompletedOrNotNeeded(); | |
| 156 | |
| 157 const char* ResultCodeToString(ResultCode code); | 141 const char* ResultCodeToString(ResultCode code); |
| 158 | 142 |
| 159 // These store the input parameters to the function. | 143 // These store the input parameters to the function. |
| 160 scoped_ptr<api::webstore_private::BeginInstallWithManifest3::Params> params_; | 144 scoped_ptr<api::webstore_private::BeginInstallWithManifest3::Params> params_; |
| 161 | 145 |
| 162 // The results of parsing manifest_ and icon_data_ go into these two. | 146 // The results of parsing manifest_ and icon_data_ go into these two. |
| 163 scoped_ptr<base::DictionaryValue> parsed_manifest_; | 147 scoped_ptr<base::DictionaryValue> parsed_manifest_; |
| 164 SkBitmap icon_; | 148 SkBitmap icon_; |
| 165 | 149 |
| 166 // A dummy Extension object we create for the purposes of using | 150 // A dummy Extension object we create for the purposes of using |
| 167 // ExtensionInstallPrompt to prompt for confirmation of the install. | 151 // ExtensionInstallPrompt to prompt for confirmation of the install. |
| 168 scoped_refptr<extensions::Extension> dummy_extension_; | 152 scoped_refptr<extensions::Extension> dummy_extension_; |
| 169 | 153 |
| 170 // The class that displays the install prompt. | 154 // The class that displays the install prompt. |
| 171 scoped_ptr<ExtensionInstallPrompt> install_prompt_; | 155 scoped_ptr<ExtensionInstallPrompt> install_prompt_; |
| 172 | 156 |
| 173 scoped_ptr<SigninTracker> signin_tracker_; | |
| 174 | |
| 175 scoped_ptr<ScopedActiveInstall> scoped_active_install_; | 157 scoped_ptr<ScopedActiveInstall> scoped_active_install_; |
| 176 | 158 |
| 177 // The authuser query parameter value which should be used with CRX download | 159 // The authuser query parameter value which should be used with CRX download |
| 178 // requests. This is empty if authuser should not be set on download requests. | 160 // requests. This is empty if authuser should not be set on download requests. |
| 179 std::string authuser_; | 161 std::string authuser_; |
| 180 }; | 162 }; |
| 181 | 163 |
| 182 class WebstorePrivateCompleteInstallFunction | 164 class WebstorePrivateCompleteInstallFunction |
| 183 : public ChromeAsyncExtensionFunction, | 165 : public ChromeAsyncExtensionFunction, |
| 184 public WebstoreInstaller::Delegate { | 166 public WebstoreInstaller::Delegate { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 292 |
| 311 WebstorePrivateIsInIncognitoModeFunction() {} | 293 WebstorePrivateIsInIncognitoModeFunction() {} |
| 312 | 294 |
| 313 protected: | 295 protected: |
| 314 virtual ~WebstorePrivateIsInIncognitoModeFunction() {} | 296 virtual ~WebstorePrivateIsInIncognitoModeFunction() {} |
| 315 | 297 |
| 316 // ExtensionFunction: | 298 // ExtensionFunction: |
| 317 virtual bool RunSync() OVERRIDE; | 299 virtual bool RunSync() OVERRIDE; |
| 318 }; | 300 }; |
| 319 | 301 |
| 320 class WebstorePrivateSignInFunction : public ChromeAsyncExtensionFunction, | |
| 321 public SigninManagerFactory::Observer, | |
| 322 public SigninTracker::Observer { | |
| 323 public: | |
| 324 DECLARE_EXTENSION_FUNCTION("webstorePrivate.signIn", | |
| 325 WEBSTOREPRIVATE_SIGNINFUNCTION) | |
| 326 | |
| 327 WebstorePrivateSignInFunction(); | |
| 328 | |
| 329 protected: | |
| 330 virtual ~WebstorePrivateSignInFunction(); | |
| 331 | |
| 332 // ExtensionFunction: | |
| 333 virtual bool RunAsync() OVERRIDE; | |
| 334 | |
| 335 // SigninManagerFactory::Observer: | |
| 336 virtual void SigninManagerShutdown(SigninManagerBase* manager) OVERRIDE; | |
| 337 | |
| 338 // SigninTracker::Observer: | |
| 339 virtual void SigninFailed(const GoogleServiceAuthError& error) OVERRIDE; | |
| 340 virtual void SigninSuccess() OVERRIDE; | |
| 341 virtual void MergeSessionComplete(const GoogleServiceAuthError& error) | |
| 342 OVERRIDE; | |
| 343 | |
| 344 private: | |
| 345 // The sign-in manager for the invoking tab's Chrome Profile. Weak reference. | |
| 346 SigninManagerBase* signin_manager_; | |
| 347 | |
| 348 // Tracks changes to sign-in state. Used to notify the page when an existing | |
| 349 // in-progress sign-in completes, either with success or failure. | |
| 350 scoped_ptr<SigninTracker> signin_tracker_; | |
| 351 }; | |
| 352 | |
| 353 class WebstorePrivateLaunchEphemeralAppFunction | 302 class WebstorePrivateLaunchEphemeralAppFunction |
| 354 : public ChromeAsyncExtensionFunction { | 303 : public ChromeAsyncExtensionFunction { |
| 355 public: | 304 public: |
| 356 DECLARE_EXTENSION_FUNCTION("webstorePrivate.launchEphemeralApp", | 305 DECLARE_EXTENSION_FUNCTION("webstorePrivate.launchEphemeralApp", |
| 357 WEBSTOREPRIVATE_LAUNCHEPHEMERALAPP) | 306 WEBSTOREPRIVATE_LAUNCHEPHEMERALAPP) |
| 358 | 307 |
| 359 WebstorePrivateLaunchEphemeralAppFunction(); | 308 WebstorePrivateLaunchEphemeralAppFunction(); |
| 360 | 309 |
| 361 protected: | 310 protected: |
| 362 virtual ~WebstorePrivateLaunchEphemeralAppFunction(); | 311 virtual ~WebstorePrivateLaunchEphemeralAppFunction(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 383 protected: | 332 protected: |
| 384 virtual ~WebstorePrivateGetEphemeralAppsEnabledFunction(); | 333 virtual ~WebstorePrivateGetEphemeralAppsEnabledFunction(); |
| 385 | 334 |
| 386 // ExtensionFunction: | 335 // ExtensionFunction: |
| 387 virtual bool RunSync() OVERRIDE; | 336 virtual bool RunSync() OVERRIDE; |
| 388 }; | 337 }; |
| 389 | 338 |
| 390 } // namespace extensions | 339 } // namespace extensions |
| 391 | 340 |
| 392 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H
_ | 341 #endif // CHROME_BROWSER_EXTENSIONS_API_WEBSTORE_PRIVATE_WEBSTORE_PRIVATE_API_H
_ |
| OLD | NEW |