| 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_IDENTITY_IDENTITY_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 const IdentityTokenCacheValue& token_data); | 103 const IdentityTokenCacheValue& token_data); |
| 104 void EraseCachedToken(const std::string& extension_id, | 104 void EraseCachedToken(const std::string& extension_id, |
| 105 const std::string& token); | 105 const std::string& token); |
| 106 void EraseAllCachedTokens(); | 106 void EraseAllCachedTokens(); |
| 107 const IdentityTokenCacheValue& GetCachedToken(const ExtensionTokenKey& key); | 107 const IdentityTokenCacheValue& GetCachedToken(const ExtensionTokenKey& key); |
| 108 | 108 |
| 109 const CachedTokens& GetAllCachedTokens(); | 109 const CachedTokens& GetAllCachedTokens(); |
| 110 | 110 |
| 111 // Account queries. | 111 // Account queries. |
| 112 std::vector<std::string> GetAccounts() const; | 112 std::vector<std::string> GetAccounts() const; |
| 113 std::string FindAccountKeyByGaiaId(const std::string& gaia_id); |
| 113 | 114 |
| 114 // Global error reporting. | 115 // Global error reporting. |
| 115 void ReportAuthError(const GoogleServiceAuthError& error); | 116 void ReportAuthError(const GoogleServiceAuthError& error); |
| 116 GoogleServiceAuthError GetAuthStatusForTest() const; | 117 GoogleServiceAuthError GetAuthStatusForTest() const; |
| 117 | 118 |
| 118 // BrowserContextKeyedAPI implementation. | 119 // BrowserContextKeyedAPI implementation. |
| 119 virtual void Shutdown() OVERRIDE; | 120 virtual void Shutdown() OVERRIDE; |
| 120 static BrowserContextKeyedAPIFactory<IdentityAPI>* GetFactoryInstance(); | 121 static BrowserContextKeyedAPIFactory<IdentityAPI>* GetFactoryInstance(); |
| 121 | 122 |
| 122 // AccountTracker::Observer implementation: | 123 // AccountTracker::Observer implementation: |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 public IdentityAPI::ShutdownObserver { | 188 public IdentityAPI::ShutdownObserver { |
| 188 public: | 189 public: |
| 189 DECLARE_EXTENSION_FUNCTION("identity.getAuthToken", | 190 DECLARE_EXTENSION_FUNCTION("identity.getAuthToken", |
| 190 EXPERIMENTAL_IDENTITY_GETAUTHTOKEN); | 191 EXPERIMENTAL_IDENTITY_GETAUTHTOKEN); |
| 191 | 192 |
| 192 IdentityGetAuthTokenFunction(); | 193 IdentityGetAuthTokenFunction(); |
| 193 | 194 |
| 194 protected: | 195 protected: |
| 195 virtual ~IdentityGetAuthTokenFunction(); | 196 virtual ~IdentityGetAuthTokenFunction(); |
| 196 | 197 |
| 198 // IdentitySigninFlow::Delegate implementation: |
| 199 virtual void SigninSuccess() OVERRIDE; |
| 200 virtual void SigninFailed() OVERRIDE; |
| 201 |
| 202 // GaiaWebAuthFlow::Delegate implementation: |
| 203 virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure, |
| 204 GoogleServiceAuthError service_error, |
| 205 const std::string& oauth_error) OVERRIDE; |
| 206 virtual void OnGaiaFlowCompleted(const std::string& access_token, |
| 207 const std::string& expiration) OVERRIDE; |
| 208 |
| 209 // OAuth2TokenService::Consumer implementation: |
| 210 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 211 const std::string& access_token, |
| 212 const base::Time& expiration_time) OVERRIDE; |
| 213 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 214 const GoogleServiceAuthError& error) OVERRIDE; |
| 215 |
| 216 scoped_ptr<OAuth2TokenService::Request> login_token_request_; |
| 217 |
| 197 private: | 218 private: |
| 198 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, | 219 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, |
| 199 ComponentWithChromeClientId); | 220 ComponentWithChromeClientId); |
| 200 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, | 221 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, |
| 201 ComponentWithNormalClientId); | 222 ComponentWithNormalClientId); |
| 202 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, InteractiveQueueShutdown); | 223 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, InteractiveQueueShutdown); |
| 203 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, NoninteractiveShutdown); | 224 FRIEND_TEST_ALL_PREFIXES(GetAuthTokenFunctionTest, NoninteractiveShutdown); |
| 204 friend class MockGetAuthTokenFunction; | 225 friend class MockGetAuthTokenFunction; |
| 205 | 226 |
| 206 // ExtensionFunction: | 227 // ExtensionFunction: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 221 virtual void StartMintToken(IdentityMintRequestQueue::MintType type) OVERRIDE; | 242 virtual void StartMintToken(IdentityMintRequestQueue::MintType type) OVERRIDE; |
| 222 | 243 |
| 223 // OAuth2MintTokenFlow::Delegate implementation: | 244 // OAuth2MintTokenFlow::Delegate implementation: |
| 224 virtual void OnMintTokenSuccess(const std::string& access_token, | 245 virtual void OnMintTokenSuccess(const std::string& access_token, |
| 225 int time_to_live) OVERRIDE; | 246 int time_to_live) OVERRIDE; |
| 226 virtual void OnMintTokenFailure( | 247 virtual void OnMintTokenFailure( |
| 227 const GoogleServiceAuthError& error) OVERRIDE; | 248 const GoogleServiceAuthError& error) OVERRIDE; |
| 228 virtual void OnIssueAdviceSuccess( | 249 virtual void OnIssueAdviceSuccess( |
| 229 const IssueAdviceInfo& issue_advice) OVERRIDE; | 250 const IssueAdviceInfo& issue_advice) OVERRIDE; |
| 230 | 251 |
| 231 // IdentitySigninFlow::Delegate implementation: | |
| 232 virtual void SigninSuccess() OVERRIDE; | |
| 233 virtual void SigninFailed() OVERRIDE; | |
| 234 | |
| 235 // GaiaWebAuthFlow::Delegate implementation: | |
| 236 virtual void OnGaiaFlowFailure(GaiaWebAuthFlow::Failure failure, | |
| 237 GoogleServiceAuthError service_error, | |
| 238 const std::string& oauth_error) OVERRIDE; | |
| 239 virtual void OnGaiaFlowCompleted(const std::string& access_token, | |
| 240 const std::string& expiration) OVERRIDE; | |
| 241 | |
| 242 // OAuth2TokenService::Consumer implementation: | |
| 243 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
| 244 const std::string& access_token, | |
| 245 const base::Time& expiration_time) OVERRIDE; | |
| 246 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
| 247 const GoogleServiceAuthError& error) OVERRIDE; | |
| 248 | |
| 249 // IdentityAPI::ShutdownObserver implementation: | 252 // IdentityAPI::ShutdownObserver implementation: |
| 250 virtual void OnShutdown() OVERRIDE; | 253 virtual void OnShutdown() OVERRIDE; |
| 251 | 254 |
| 252 // Starts a login access token request. | 255 // Starts a login access token request. |
| 253 virtual void StartLoginAccessTokenRequest(); | 256 virtual void StartLoginAccessTokenRequest(); |
| 254 | 257 |
| 255 #if defined(OS_CHROMEOS) | 258 #if defined(OS_CHROMEOS) |
| 256 // Starts a login access token request for device robot account. This method | 259 // Starts a login access token request for device robot account. This method |
| 257 // will be called only in enterprise kiosk mode in ChromeOS. | 260 // will be called only in enterprise kiosk mode in ChromeOS. |
| 258 virtual void StartDeviceLoginAccessTokenRequest(); | 261 virtual void StartDeviceLoginAccessTokenRequest(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 283 OAuth2MintTokenFlow::Mode gaia_mint_token_mode_; | 286 OAuth2MintTokenFlow::Mode gaia_mint_token_mode_; |
| 284 bool should_prompt_for_signin_; | 287 bool should_prompt_for_signin_; |
| 285 | 288 |
| 286 scoped_ptr<ExtensionTokenKey> token_key_; | 289 scoped_ptr<ExtensionTokenKey> token_key_; |
| 287 std::string oauth2_client_id_; | 290 std::string oauth2_client_id_; |
| 288 // When launched in interactive mode, and if there is no existing grant, | 291 // When launched in interactive mode, and if there is no existing grant, |
| 289 // a permissions prompt will be popped up to the user. | 292 // a permissions prompt will be popped up to the user. |
| 290 IssueAdviceInfo issue_advice_; | 293 IssueAdviceInfo issue_advice_; |
| 291 scoped_ptr<GaiaWebAuthFlow> gaia_web_auth_flow_; | 294 scoped_ptr<GaiaWebAuthFlow> gaia_web_auth_flow_; |
| 292 scoped_ptr<IdentitySigninFlow> signin_flow_; | 295 scoped_ptr<IdentitySigninFlow> signin_flow_; |
| 293 scoped_ptr<OAuth2TokenService::Request> login_token_request_; | |
| 294 }; | 296 }; |
| 295 | 297 |
| 296 class IdentityRemoveCachedAuthTokenFunction | 298 class IdentityRemoveCachedAuthTokenFunction |
| 297 : public ChromeSyncExtensionFunction { | 299 : public ChromeSyncExtensionFunction { |
| 298 public: | 300 public: |
| 299 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", | 301 DECLARE_EXTENSION_FUNCTION("identity.removeCachedAuthToken", |
| 300 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) | 302 EXPERIMENTAL_IDENTITY_REMOVECACHEDAUTHTOKEN) |
| 301 IdentityRemoveCachedAuthTokenFunction(); | 303 IdentityRemoveCachedAuthTokenFunction(); |
| 302 | 304 |
| 303 protected: | 305 protected: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 330 // Helper to initialize final URL prefix. | 332 // Helper to initialize final URL prefix. |
| 331 void InitFinalRedirectURLPrefix(const std::string& extension_id); | 333 void InitFinalRedirectURLPrefix(const std::string& extension_id); |
| 332 | 334 |
| 333 scoped_ptr<WebAuthFlow> auth_flow_; | 335 scoped_ptr<WebAuthFlow> auth_flow_; |
| 334 GURL final_url_prefix_; | 336 GURL final_url_prefix_; |
| 335 }; | 337 }; |
| 336 | 338 |
| 337 } // namespace extensions | 339 } // namespace extensions |
| 338 | 340 |
| 339 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ | 341 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_API_H_ |
| OLD | NEW |