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

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: rebased 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:
34 // Register and unregister with dependent services. 39 // Register and unregister with dependent services.
35 void RegisterWithCookieMonster(); 40 void RegisterWithCookieMonster();
36 void UnregisterWithCookieMonster(); 41 void UnregisterWithCookieMonster();
37 void RegisterWithSigninManager(); 42 void RegisterWithSigninManager();
38 void UnregisterWithSigninManager(); 43 void UnregisterWithSigninManager();
39 void RegisterWithTokenService(); 44 void RegisterWithTokenService();
40 void UnregisterWithTokenService(); 45 void UnregisterWithTokenService();
41 46
47 bool IsProfileConnected();
48
49 void DeleteAccessTokenRequests();
50
51 std::vector<std::string> ParseListAccountsData(const std::string& data);
52
42 // Start and stop the periodic reconciliation. 53 // Start and stop the periodic reconciliation.
43 void StartPeriodicReconciliation(); 54 void StartPeriodicReconciliation();
44 void StopPeriodicReconciliation(); 55 void StopPeriodicReconciliation();
45 void PeriodicReconciliation(); 56 void PeriodicReconciliation();
46 57
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); 58 void PerformMergeAction(const std::string& account_id);
53 void PerformRemoveAction(const std::string& account_id); 59 void PerformRemoveAction(const std::string& account_id);
54 void PerformReconcileAction(); 60 void StartReconcileAction();
61 void FinishReconcileAction();
62
63 void GetAccountsFromCookie();
64 void ValidateAccountsFromTokenService();
65
66 void OnCookieChanged(ChromeCookieDetails* details);
55 67
56 // Overriden from content::NotificationObserver 68 // Overriden from content::NotificationObserver
57 virtual void Observe(int type, 69 virtual void Observe(int type,
58 const content::NotificationSource& source, 70 const content::NotificationSource& source,
59 const content::NotificationDetails& details) OVERRIDE; 71 const content::NotificationDetails& details) OVERRIDE;
60 72
61 void OnCookieChanged(ChromeCookieDetails* details); 73 // Overriden from OAuth2TokenService::Consumer
74 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
75 const std::string& access_token,
76 const base::Time& expiration_time) OVERRIDE;
77 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
78 const GoogleServiceAuthError& error) OVERRIDE;
62 79
63 // Overriden from OAuth2TokenService::Observer 80 // Overriden from OAuth2TokenService::Observer
64 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; 81 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
65 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; 82 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE;
66 virtual void OnRefreshTokensLoaded() OVERRIDE; 83 virtual void OnRefreshTokensLoaded() OVERRIDE;
67 84
85 // Overriden from GaiaAuthConsumer
86 virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE;
87 virtual void OnListAccountsFailure(
88 const GoogleServiceAuthError& error) OVERRIDE;
89
90 // The profile that this reconcilor belongs to.
91 Profile* profile_;
92 content::NotificationRegistrar registrar_;
93 base::RepeatingTimer<AccountReconcilor> reconciliation_timer_;
94
95 // Used during reconcile action.
96 // These members are used used to validate the gaia cookie.
97 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_;
98 bool are_gaia_accounts_set_;
99 std::vector<std::string> gaia_accounts_;
acleung1 2013/11/04 21:19:00 My understanding is that we are going to eventuall
Roger Tawa OOO till Jul 10th 2013/11/04 23:38:42 These members would only be used by one thread, ev
100 // These members are used to validate the tokens in OAuth2TokenService.
acleung1 2013/11/04 21:19:00 May be a new line before this for better readabili
Roger Tawa OOO till Jul 10th 2013/11/04 23:38:42 Done.
101 std::string primary_account_;
102 std::vector<std::string> chrome_accounts_;
103 scoped_ptr<OAuth2TokenService::Request>* requests_;
104 std::set<std::string> valid_chrome_accounts_;
105 std::set<std::string> invalid_chrome_accounts_;
106
68 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor); 107 DISALLOW_COPY_AND_ASSIGN(AccountReconcilor);
69 }; 108 };
70 109
71 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_ 110 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_RECONCILOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698