| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ | 4 #ifndef CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ |
| 5 #define CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ | 5 #define CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "chrome/browser/signin/google_auto_login_helper.h" |
| 11 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 12 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 12 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 14 #include "google_apis/gaia/gaia_auth_consumer.h" | 15 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 15 #include "google_apis/gaia/oauth2_token_service.h" | 16 #include "google_apis/gaia/oauth2_token_service.h" |
| 16 | 17 |
| 17 class GaiaAuthFetcher; | 18 class GaiaAuthFetcher; |
| 18 class Profile; | 19 class Profile; |
| 19 struct ChromeCookieDetails; | 20 struct ChromeCookieDetails; |
| 20 | 21 |
| 21 class AccountReconcilor : public BrowserContextKeyedService, | 22 class AccountReconcilor : public BrowserContextKeyedService, |
| 22 content::NotificationObserver, | 23 public content::NotificationObserver, |
| 23 GaiaAuthConsumer, | 24 public GaiaAuthConsumer, |
| 24 OAuth2TokenService::Consumer, | 25 public OAuth2TokenService::Consumer, |
| 25 OAuth2TokenService::Observer { | 26 public OAuth2TokenService::Observer { |
| 26 public: | 27 public: |
| 27 explicit AccountReconcilor(Profile* profile); | 28 explicit AccountReconcilor(Profile* profile); |
| 28 virtual ~AccountReconcilor(); | 29 virtual ~AccountReconcilor(); |
| 29 | 30 |
| 30 // BrowserContextKeyedService implementation. | 31 // BrowserContextKeyedService implementation. |
| 31 virtual void Shutdown() OVERRIDE; | 32 virtual void Shutdown() OVERRIDE; |
| 32 | 33 |
| 34 // Add or remove observers for the merge session notification. |
| 35 void AddMergeSessionObserver(GoogleAutoLoginHelper::Observer* observer); |
| 36 void RemoveMergeSessionObserver(GoogleAutoLoginHelper::Observer* observer); |
| 37 |
| 33 Profile* profile() { return profile_; } | 38 Profile* profile() { return profile_; } |
| 34 | 39 |
| 35 bool IsPeriodicReconciliationRunning() const { | 40 bool IsPeriodicReconciliationRunning() const { |
| 36 return reconciliation_timer_.IsRunning(); | 41 return reconciliation_timer_.IsRunning(); |
| 37 } | 42 } |
| 38 | 43 |
| 39 bool IsRegisteredWithTokenService() const { | 44 bool IsRegisteredWithTokenService() const { |
| 40 return registered_with_token_service_; | 45 return registered_with_token_service_; |
| 41 } | 46 } |
| 42 | 47 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 124 |
| 120 // Overriden from GaiaAuthConsumer. | 125 // Overriden from GaiaAuthConsumer. |
| 121 virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE; | 126 virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE; |
| 122 virtual void OnListAccountsFailure( | 127 virtual void OnListAccountsFailure( |
| 123 const GoogleServiceAuthError& error) OVERRIDE; | 128 const GoogleServiceAuthError& error) OVERRIDE; |
| 124 | 129 |
| 125 // The profile that this reconcilor belongs to. | 130 // The profile that this reconcilor belongs to. |
| 126 Profile* profile_; | 131 Profile* profile_; |
| 127 content::NotificationRegistrar registrar_; | 132 content::NotificationRegistrar registrar_; |
| 128 base::RepeatingTimer<AccountReconcilor> reconciliation_timer_; | 133 base::RepeatingTimer<AccountReconcilor> reconciliation_timer_; |
| 134 GoogleAutoLoginHelper merge_session_helper_; |
| 129 bool registered_with_token_service_; | 135 bool registered_with_token_service_; |
| 130 | 136 |
| 131 // Used during reconcile action. | 137 // Used during reconcile action. |
| 132 // These members are used used to validate the gaia cookie. | 138 // These members are used used to validate the gaia cookie. |
| 133 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; | 139 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; |
| 134 bool are_gaia_accounts_set_; | 140 bool are_gaia_accounts_set_; |
| 135 std::vector<std::string> gaia_accounts_; | 141 std::vector<std::string> gaia_accounts_; |
| 136 | 142 |
| 137 // Used during reconcile action. | 143 // Used during reconcile action. |
| 138 // These members are used to validate the tokens in OAuth2TokenService. | 144 // These members are used to validate the tokens in OAuth2TokenService. |
| 139 std::string primary_account_; | 145 std::string primary_account_; |
| 140 std::vector<std::string> chrome_accounts_; | 146 std::vector<std::string> chrome_accounts_; |
| 141 scoped_ptr<OAuth2TokenService::Request>* requests_; | 147 scoped_ptr<OAuth2TokenService::Request>* requests_; |
| 142 ScopedVector<UserIdFetcher> user_id_fetchers_; | 148 ScopedVector<UserIdFetcher> user_id_fetchers_; |
| 143 std::set<std::string> valid_chrome_accounts_; | 149 std::set<std::string> valid_chrome_accounts_; |
| 144 std::set<std::string> invalid_chrome_accounts_; | 150 std::set<std::string> invalid_chrome_accounts_; |
| 145 | 151 |
| 146 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); | 152 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); |
| 147 }; | 153 }; |
| 148 | 154 |
| 149 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ | 155 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ |
| OLD | NEW |