Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: chrome/browser/signin/account_reconcilor.h

Issue 57363003: Enable account reconcilor when --new-profile-management is used. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unsigned check in tests again Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "components/browser_context_keyed_service/browser_context_keyed_service .h" 10 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
10 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "google_apis/gaia/gaia_auth_consumer.h"
12 #include "google_apis/gaia/oauth2_token_service.h" 14 #include "google_apis/gaia/oauth2_token_service.h"
13 15
16 class GaiaAuthFetcher;
14 class Profile; 17 class Profile;
15 struct ChromeCookieDetails; 18 struct ChromeCookieDetails;
16 19
17 class AccountReconcilor : public BrowserContextKeyedService, 20 class AccountReconcilor : public BrowserContextKeyedService,
18 content::NotificationObserver, 21 content::NotificationObserver,
22 GaiaAuthConsumer,
23 OAuth2TokenService::Consumer,
19 OAuth2TokenService::Observer { 24 OAuth2TokenService::Observer {
20 public: 25 public:
21 explicit AccountReconcilor(Profile* profile); 26 explicit AccountReconcilor(Profile* profile);
22 virtual ~AccountReconcilor(); 27 virtual ~AccountReconcilor();
23 28
24 // BrowserContextKeyedService implementation. 29 // BrowserContextKeyedService implementation.
25 virtual void Shutdown() OVERRIDE; 30 virtual void Shutdown() OVERRIDE;
26 31
27 Profile* profile() { return profile_; } 32 Profile* profile() { return profile_; }
28 33
29 bool IsPeriodicReconciliationRunning() { 34 bool IsPeriodicReconciliationRunning() {
30 return reconciliation_timer_.IsRunning(); 35 return reconciliation_timer_.IsRunning();
31 } 36 }
32 37
33 private: 38 private:
39 class AccountReconcilorTest;
40 FRIEND_TEST_ALL_PREFIXES(AccountReconcilorTest, ParseListAccountsData);
41
34 // Register and unregister with dependent services. 42 // Register and unregister with dependent services.
35 void RegisterWithCookieMonster(); 43 void RegisterWithCookieMonster();
36 void UnregisterWithCookieMonster(); 44 void UnregisterWithCookieMonster();
37 void RegisterWithSigninManager(); 45 void RegisterWithSigninManager();
38 void UnregisterWithSigninManager(); 46 void UnregisterWithSigninManager();
39 void RegisterWithTokenService(); 47 void RegisterWithTokenService();
40 void UnregisterWithTokenService(); 48 void UnregisterWithTokenService();
41 49
50 bool IsProfileConnected();
51
52 void DeleteAccessTokenRequests();
53
54 static std::vector<std::string> ParseListAccountsData(
55 const std::string& data);
56
42 // Start and stop the periodic reconciliation. 57 // Start and stop the periodic reconciliation.
43 void StartPeriodicReconciliation(); 58 void StartPeriodicReconciliation();
44 void StopPeriodicReconciliation(); 59 void StopPeriodicReconciliation();
45 void PeriodicReconciliation(); 60 void PeriodicReconciliation();
46 61
47 // The profile that this reconcilor belongs to.
48 Profile* profile_;
49 content::NotificationRegistrar registrar_;
50 base::RepeatingTimer<AccountReconcilor> reconciliation_timer_;
51
52 void PerformMergeAction(const std::string& account_id); 62 void PerformMergeAction(const std::string& account_id);
53 void PerformRemoveAction(const std::string& account_id); 63 void PerformRemoveAction(const std::string& account_id);
54 void PerformReconcileAction(); 64 void StartReconcileAction();
65 void FinishReconcileAction();
66
67 void GetAccountsFromCookie();
68 void ValidateAccountsFromTokenService();
69
70 void OnCookieChanged(ChromeCookieDetails* details);
55 71
56 // Overriden from content::NotificationObserver 72 // Overriden from content::NotificationObserver
57 virtual void Observe(int type, 73 virtual void Observe(int type,
58 const content::NotificationSource& source, 74 const content::NotificationSource& source,
59 const content::NotificationDetails& details) OVERRIDE; 75 const content::NotificationDetails& details) OVERRIDE;
60 76
61 void OnCookieChanged(ChromeCookieDetails* details); 77 // Overriden from OAuth2TokenService::Consumer
78 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
79 const std::string& access_token,
80 const base::Time& expiration_time) OVERRIDE;
81 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
82 const GoogleServiceAuthError& error) OVERRIDE;
62 83
63 // Overriden from OAuth2TokenService::Observer 84 // Overriden from OAuth2TokenService::Observer
64 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 85 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
65 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 86 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
66 virtual void OnRefreshTokensLoaded() OVERRIDE; 87 virtual void OnRefreshTokensLoaded() OVERRIDE;
67 88
89 // Overriden from GaiaAuthConsumer
90 virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE;
91 virtual void OnListAccountsFailure(
92 const GoogleServiceAuthError& error) OVERRIDE;
93
94 // The profile that this reconcilor belongs to.
95 Profile* profile_;
96 content::NotificationRegistrar registrar_;
97 base::RepeatingTimer<AccountReconcilor> reconciliation_timer_;
98
99 // Used during reconcile action.
100 // These members are used used to validate the gaia cookie.
101 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_;
102 bool are_gaia_accounts_set_;
103 std::vector<std::string> gaia_accounts_;
104
105 // Used during reconcile action.
106 // These members are used to validate the tokens in OAuth2TokenService.
107 std::string primary_account_;
108 std::vector<std::string> chrome_accounts_;
109 scoped_ptr<OAuth2TokenService::Request>* requests_;
110 std::set<std::string> valid_chrome_accounts_;
111 std::set<std::string> invalid_chrome_accounts_;
112
68 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); 113 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor);
69 }; 114 };
70 115
71 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ 116 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698