| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/chromeos/login/oauth2_login_verifier.h" | 11 #include "chrome/browser/chromeos/login/oauth2_login_verifier.h" |
| 12 #include "chrome/browser/chromeos/login/oauth2_policy_fetcher.h" | 12 #include "chrome/browser/chromeos/login/oauth2_policy_fetcher.h" |
| 13 #include "chrome/browser/chromeos/login/oauth2_token_fetcher.h" | 13 #include "chrome/browser/chromeos/login/oauth2_token_fetcher.h" |
| 14 #include "chrome/browser/chromeos/login/oauth_login_manager.h" | 14 #include "chrome/browser/chromeos/login/oauth_login_manager.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 | 18 |
| 19 class GoogleServiceAuthError; | 19 class GoogleServiceAuthError; |
| 20 class PrefRegistrySyncable; |
| 20 class Profile; | 21 class Profile; |
| 21 class TokenService; | 22 class TokenService; |
| 22 | 23 |
| 23 namespace chromeos { | 24 namespace chromeos { |
| 24 | 25 |
| 25 // OAuth2 specialization of OAuthLoginManager. | 26 // OAuth2 specialization of OAuthLoginManager. |
| 26 class OAuth2LoginManager : public OAuthLoginManager, | 27 class OAuth2LoginManager : public OAuthLoginManager, |
| 27 public content::NotificationObserver, | 28 public content::NotificationObserver, |
| 28 public OAuth2LoginVerifier::Delegate, | 29 public OAuth2LoginVerifier::Delegate, |
| 29 public OAuth2TokenFetcher::Delegate { | 30 public OAuth2TokenFetcher::Delegate { |
| 30 public: | 31 public: |
| 31 explicit OAuth2LoginManager(OAuthLoginManager::Delegate* delegate); | 32 explicit OAuth2LoginManager(OAuthLoginManager::Delegate* delegate); |
| 32 virtual ~OAuth2LoginManager(); | 33 virtual ~OAuth2LoginManager(); |
| 33 | 34 |
| 35 static void RegisterUserPrefs(PrefRegistrySyncable* registry); |
| 36 |
| 34 // OAuthLoginManager overrides. | 37 // OAuthLoginManager overrides. |
| 35 virtual void RestorePolicyTokens( | 38 virtual void RestorePolicyTokens( |
| 36 net::URLRequestContextGetter* auth_request_context) OVERRIDE; | 39 net::URLRequestContextGetter* auth_request_context) OVERRIDE; |
| 37 virtual void RestoreSession( | 40 virtual void RestoreSession( |
| 38 Profile* user_profile, | 41 Profile* user_profile, |
| 39 net::URLRequestContextGetter* auth_request_context, | 42 net::URLRequestContextGetter* auth_request_context, |
| 40 bool restore_from_auth_cookies) OVERRIDE; | 43 bool restore_from_auth_cookies) OVERRIDE; |
| 41 virtual void ContinueSessionRestore() OVERRIDE; | 44 virtual void ContinueSessionRestore() OVERRIDE; |
| 42 virtual void Stop() OVERRIDE; | 45 virtual void Stop() OVERRIDE; |
| 43 | 46 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 66 | 69 |
| 67 // OAuth2TokenFetcher::Delegate overrides. | 70 // OAuth2TokenFetcher::Delegate overrides. |
| 68 virtual void OnOAuth2TokensAvailable( | 71 virtual void OnOAuth2TokensAvailable( |
| 69 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) OVERRIDE; | 72 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) OVERRIDE; |
| 70 virtual void OnOAuth2TokensFetchFailed() OVERRIDE; | 73 virtual void OnOAuth2TokensFetchFailed() OVERRIDE; |
| 71 | 74 |
| 72 // Retrieves TokenService for |user_profile_| and sets up notification | 75 // Retrieves TokenService for |user_profile_| and sets up notification |
| 73 // observer events. | 76 // observer events. |
| 74 TokenService* SetupTokenService(); | 77 TokenService* SetupTokenService(); |
| 75 | 78 |
| 76 // Removes legacy tokens form OAuth1 flow. | 79 // Removes legacy tokens from OAuth1 flow. |
| 77 void RemoveLegacyTokens(); | 80 void RemoveLegacyTokens(); |
| 78 | 81 |
| 79 // Records OAuth2 tokens fetched through either policy fetcher or cookies-to- | 82 // Records OAuth2 tokens fetched through either policy fetcher or cookies-to- |
| 80 // token exchange into TokenService. | 83 // token exchange into TokenService. |
| 81 void StoreOAuth2Tokens( | 84 void StoreOAuth2Tokens( |
| 82 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens); | 85 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens); |
| 83 | 86 |
| 84 // Loads previously stored OAuth2 tokens and kicks off its validation. | 87 // Loads previously stored OAuth2 tokens and kicks off its validation. |
| 85 void LoadAndVerifyOAuth2Tokens(); | 88 void LoadAndVerifyOAuth2Tokens(); |
| 86 | 89 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 115 scoped_ptr<OAuth2PolicyFetcher> oauth2_policy_fetcher_; | 118 scoped_ptr<OAuth2PolicyFetcher> oauth2_policy_fetcher_; |
| 116 // OAuth2 refresh token. | 119 // OAuth2 refresh token. |
| 117 std::string refresh_token_; | 120 std::string refresh_token_; |
| 118 | 121 |
| 119 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); | 122 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginManager); |
| 120 }; | 123 }; |
| 121 | 124 |
| 122 } // namespace chromeos | 125 } // namespace chromeos |
| 123 | 126 |
| 124 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ | 127 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH2_LOGIN_MANAGER_H_ |
| OLD | NEW |