| 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/browser_signin.h" | 11 #include "chrome/browser/browser_signin.h" |
| 12 #include "chrome/browser/extensions/extension_function.h" | 12 #include "chrome/browser/extensions/extension_function.h" |
| 13 #include "chrome/browser/extensions/extension_install_ui.h" | 13 #include "chrome/browser/extensions/extension_install_ui.h" |
| 14 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 14 #include "chrome/common/net/gaia/google_service_auth_error.h" | 15 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 15 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
| 16 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
| 17 | 18 |
| 18 class ProfileSyncService; | 19 class ProfileSyncService; |
| 19 | 20 |
| 20 class WebstorePrivateApi { | 21 class WebstorePrivateApi { |
| 21 public: | 22 public: |
| 22 // Allows you to set the ProfileSyncService the function will use for | 23 // Allows you to set the ProfileSyncService the function will use for |
| 23 // testing purposes. | 24 // testing purposes. |
| 24 static void SetTestingProfileSyncService(ProfileSyncService* service); | 25 static void SetTestingProfileSyncService(ProfileSyncService* service); |
| 25 | 26 |
| 26 // Allows you to set the BrowserSignin the function will use for | 27 // Allows you to set the BrowserSignin the function will use for |
| 27 // testing purposes. | 28 // testing purposes. |
| 28 static void SetTestingBrowserSignin(BrowserSignin* signin); | 29 static void SetTestingBrowserSignin(BrowserSignin* signin); |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 // TODO(asargent): this is being deprecated in favor of | 32 // TODO(asargent): this is being deprecated in favor of |
| 32 // BeginInstallWithManifestFunction. See crbug.com/75821 for details. | 33 // BeginInstallWithManifestFunction. See crbug.com/75821 for details. |
| 33 class BeginInstallFunction : public SyncExtensionFunction { | 34 class BeginInstallFunction : public SyncExtensionFunction { |
| 34 public: | 35 public: |
| 35 // For use only in tests - sets a flag that can cause this function to ignore | 36 // For use only in tests - sets a flag that can cause this function to ignore |
| 36 // the normal requirement that it is called during a user gesture. | 37 // the normal requirement that it is called during a user gesture. |
| 37 static void SetIgnoreUserGestureForTests(bool ignore); | 38 static void SetIgnoreUserGestureForTests(bool ignore); |
| 38 protected: | 39 protected: |
| 39 virtual bool RunImpl(); | 40 virtual bool RunImpl(); |
| 40 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.beginInstall"); | 41 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.beginInstall"); |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 class BeginInstallWithManifestFunction : public AsyncExtensionFunction, | 44 class BeginInstallWithManifestFunction |
| 44 public ExtensionInstallUI::Delegate { | 45 : public AsyncExtensionFunction, |
| 46 public ExtensionInstallUI::Delegate, |
| 47 public WebstoreInstallHelper::Delegate { |
| 45 public: | 48 public: |
| 46 BeginInstallWithManifestFunction(); | 49 BeginInstallWithManifestFunction(); |
| 47 | 50 |
| 48 // Result codes for the return value. If you change this, make sure to | 51 // Result codes for the return value. If you change this, make sure to |
| 49 // update the description for the beginInstallWithManifest callback in | 52 // update the description for the beginInstallWithManifest callback in |
| 50 // extension_api.json. | 53 // extension_api.json. |
| 51 enum ResultCode { | 54 enum ResultCode { |
| 52 ERROR_NONE = 0, | 55 ERROR_NONE = 0, |
| 53 | 56 |
| 54 // An unspecified error occurred. | 57 // An unspecified error occurred. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 78 | 81 |
| 79 // For use only in tests - sets a flag that can cause this function to ignore | 82 // For use only in tests - sets a flag that can cause this function to ignore |
| 80 // the normal requirement that it is called during a user gesture. | 83 // the normal requirement that it is called during a user gesture. |
| 81 static void SetIgnoreUserGestureForTests(bool ignore); | 84 static void SetIgnoreUserGestureForTests(bool ignore); |
| 82 | 85 |
| 83 // For use only in tests - sets a flag that makes invocations of | 86 // For use only in tests - sets a flag that makes invocations of |
| 84 // beginInstallWithManifest skip putting up a real dialog, and instead act | 87 // beginInstallWithManifest skip putting up a real dialog, and instead act |
| 85 // as if the dialog choice was to proceed or abort. | 88 // as if the dialog choice was to proceed or abort. |
| 86 static void SetAutoConfirmForTests(bool should_proceed); | 89 static void SetAutoConfirmForTests(bool should_proceed); |
| 87 | 90 |
| 88 // Called when we've successfully parsed the manifest and decoded the icon in | 91 // Implementing WebstoreInstallHelper::Delegate interface. |
| 89 // the utility process. Ownership of parsed_manifest is transferred. | 92 virtual void OnWebstoreParseSuccess( |
| 90 void OnParseSuccess(const SkBitmap& icon, | 93 const SkBitmap& icon, |
| 91 base::DictionaryValue* parsed_manifest); | 94 base::DictionaryValue* parsed_manifest) OVERRIDE; |
| 92 | 95 virtual void OnWebstoreParseFailure( |
| 93 // Called to indicate a parse failure. The |result_code| parameter should | 96 InstallHelperResultCode result_code, |
| 94 // indicate whether the problem was with the manifest or icon. | 97 const std::string& error_message) OVERRIDE; |
| 95 void OnParseFailure(ResultCode result_code, const std::string& error_message); | |
| 96 | 98 |
| 97 // Implementing ExtensionInstallUI::Delegate interface. | 99 // Implementing ExtensionInstallUI::Delegate interface. |
| 98 virtual void InstallUIProceed() OVERRIDE; | 100 virtual void InstallUIProceed() OVERRIDE; |
| 99 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; | 101 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
| 100 | 102 |
| 101 protected: | 103 protected: |
| 102 virtual ~BeginInstallWithManifestFunction(); | 104 virtual ~BeginInstallWithManifestFunction(); |
| 103 virtual bool RunImpl(); | 105 virtual bool RunImpl(); |
| 104 | 106 |
| 105 // Sets the result_ as a string based on |code|. | 107 // Sets the result_ as a string based on |code|. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // Are we waiting for a token available notification? | 171 // Are we waiting for a token available notification? |
| 170 bool waiting_for_token_; | 172 bool waiting_for_token_; |
| 171 | 173 |
| 172 // Used for listening for TokenService notifications. | 174 // Used for listening for TokenService notifications. |
| 173 NotificationRegistrar registrar_; | 175 NotificationRegistrar registrar_; |
| 174 | 176 |
| 175 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.promptBrowserLogin"); | 177 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.promptBrowserLogin"); |
| 176 }; | 178 }; |
| 177 | 179 |
| 178 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ | 180 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ |
| OLD | NEW |