| 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" | |
| 12 #include "chrome/browser/extensions/extension_function.h" | 11 #include "chrome/browser/extensions/extension_function.h" |
| 13 #include "chrome/browser/extensions/extension_install_ui.h" | 12 #include "chrome/browser/extensions/extension_install_ui.h" |
| 14 #include "chrome/browser/extensions/webstore_install_helper.h" | 13 #include "chrome/browser/extensions/webstore_install_helper.h" |
| 15 #include "chrome/common/net/gaia/google_service_auth_error.h" | 14 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 16 #include "content/common/notification_observer.h" | 15 #include "content/common/notification_observer.h" |
| 17 #include "content/common/notification_registrar.h" | 16 #include "content/common/notification_registrar.h" |
| 18 | 17 |
| 19 class ProfileSyncService; | 18 class ProfileSyncService; |
| 20 | 19 |
| 21 class WebstorePrivateApi { | 20 class WebstorePrivateApi { |
| 22 public: | 21 public: |
| 23 // Allows you to set the ProfileSyncService the function will use for | 22 // Allows you to set the ProfileSyncService the function will use for |
| 24 // testing purposes. | 23 // testing purposes. |
| 25 static void SetTestingProfileSyncService(ProfileSyncService* service); | 24 static void SetTestingProfileSyncService(ProfileSyncService* service); |
| 26 | |
| 27 // Allows you to set the BrowserSignin the function will use for | |
| 28 // testing purposes. | |
| 29 static void SetTestingBrowserSignin(BrowserSignin* signin); | |
| 30 }; | 25 }; |
| 31 | 26 |
| 32 // TODO(asargent): this is being deprecated in favor of | 27 // TODO(asargent): this is being deprecated in favor of |
| 33 // BeginInstallWithManifestFunction. See crbug.com/75821 for details. | 28 // BeginInstallWithManifestFunction. See crbug.com/75821 for details. |
| 34 class BeginInstallFunction : public SyncExtensionFunction { | 29 class BeginInstallFunction : public SyncExtensionFunction { |
| 35 public: | 30 public: |
| 36 // For use only in tests - sets a flag that can cause this function to ignore | 31 // For use only in tests - sets a flag that can cause this function to ignore |
| 37 // the normal requirement that it is called during a user gesture. | 32 // the normal requirement that it is called during a user gesture. |
| 38 static void SetIgnoreUserGestureForTests(bool ignore); | 33 static void SetIgnoreUserGestureForTests(bool ignore); |
| 39 protected: | 34 protected: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 class GetStoreLoginFunction : public SyncExtensionFunction { | 134 class GetStoreLoginFunction : public SyncExtensionFunction { |
| 140 virtual bool RunImpl(); | 135 virtual bool RunImpl(); |
| 141 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getStoreLogin"); | 136 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.getStoreLogin"); |
| 142 }; | 137 }; |
| 143 | 138 |
| 144 class SetStoreLoginFunction : public SyncExtensionFunction { | 139 class SetStoreLoginFunction : public SyncExtensionFunction { |
| 145 virtual bool RunImpl(); | 140 virtual bool RunImpl(); |
| 146 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.setStoreLogin"); | 141 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.setStoreLogin"); |
| 147 }; | 142 }; |
| 148 | 143 |
| 149 class PromptBrowserLoginFunction : public AsyncExtensionFunction, | |
| 150 public NotificationObserver, | |
| 151 public BrowserSignin::SigninDelegate { | |
| 152 public: | |
| 153 PromptBrowserLoginFunction(); | |
| 154 // Implements BrowserSignin::SigninDelegate interface. | |
| 155 virtual void OnLoginSuccess(); | |
| 156 virtual void OnLoginFailure(const GoogleServiceAuthError& error); | |
| 157 | |
| 158 // Implements the NotificationObserver interface. | |
| 159 virtual void Observe(int type, | |
| 160 const NotificationSource& source, | |
| 161 const NotificationDetails& details); | |
| 162 | |
| 163 protected: | |
| 164 virtual ~PromptBrowserLoginFunction(); | |
| 165 virtual bool RunImpl(); | |
| 166 | |
| 167 private: | |
| 168 // Creates the message for signing in. | |
| 169 virtual string16 GetLoginMessage(); | |
| 170 | |
| 171 // Are we waiting for a token available notification? | |
| 172 bool waiting_for_token_; | |
| 173 | |
| 174 // Used for listening for TokenService notifications. | |
| 175 NotificationRegistrar registrar_; | |
| 176 | |
| 177 DECLARE_EXTENSION_FUNCTION_NAME("webstorePrivate.promptBrowserLogin"); | |
| 178 }; | |
| 179 | |
| 180 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ | 144 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBSTORE_PRIVATE_API_H_ |
| OLD | NEW |