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 | 4 |
5 #include "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 9 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/signin/account_reconcilor.h" | 11 #include "chrome/browser/signin/account_reconcilor.h" |
12 #include "chrome/browser/signin/google_auto_login_helper.h" | 12 #include "chrome/browser/signin/google_auto_login_helper.h" |
13 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
15 #include "chrome/browser/signin/signin_manager.h" | 15 #include "chrome/browser/signin/signin_manager.h" |
16 #include "chrome/browser/signin/signin_manager_factory.h" | 16 #include "chrome/browser/signin/signin_manager_factory.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
19 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
20 #include "google_apis/gaia/gaia_auth_fetcher.h" | 20 #include "google_apis/gaia/gaia_auth_fetcher.h" |
21 #include "google_apis/gaia/gaia_constants.h" | 21 #include "google_apis/gaia/gaia_constants.h" |
22 | 22 |
23 AccountReconcilor::AccountReconcilor(Profile* profile) | 23 AccountReconcilor::AccountReconcilor(Profile* profile) |
24 : profile_(profile), | 24 : profile_(profile), |
25 are_gaia_accounts_set_(false), | 25 are_gaia_accounts_set_(false), |
26 requests_(NULL) { | 26 requests_(NULL) { |
| 27 DVLOG(1) << "AccountReconcilor::AccountReconcilor"; |
27 RegisterWithSigninManager(); | 28 RegisterWithSigninManager(); |
28 RegisterWithCookieMonster(); | 29 RegisterWithCookieMonster(); |
29 | 30 |
30 // If this profile is not connected, the reconcilor should do nothing but | 31 // If this profile is not connected, the reconcilor should do nothing but |
31 // wait for the connection. | 32 // wait for the connection. |
32 if (IsProfileConnected()) { | 33 if (IsProfileConnected()) { |
33 RegisterWithTokenService(); | 34 RegisterWithTokenService(); |
34 StartPeriodicReconciliation(); | 35 StartPeriodicReconciliation(); |
35 } | 36 } |
36 } | 37 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 74 } |
74 | 75 |
75 void AccountReconcilor::UnregisterWithSigninManager() { | 76 void AccountReconcilor::UnregisterWithSigninManager() { |
76 content::Source<Profile> source(profile_); | 77 content::Source<Profile> source(profile_); |
77 registrar_.Remove( | 78 registrar_.Remove( |
78 this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, source); | 79 this, chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, source); |
79 registrar_.Remove(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, source); | 80 registrar_.Remove(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, source); |
80 } | 81 } |
81 | 82 |
82 void AccountReconcilor::RegisterWithTokenService() { | 83 void AccountReconcilor::RegisterWithTokenService() { |
| 84 DVLOG(1) << "AccountReconcilor::RegisterWithTokenService"; |
83 ProfileOAuth2TokenService* token_service = | 85 ProfileOAuth2TokenService* token_service = |
84 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 86 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
85 token_service->AddObserver(this); | 87 token_service->AddObserver(this); |
86 } | 88 } |
87 | 89 |
88 void AccountReconcilor::UnregisterWithTokenService() { | 90 void AccountReconcilor::UnregisterWithTokenService() { |
89 ProfileOAuth2TokenService* token_service = | 91 ProfileOAuth2TokenService* token_service = |
90 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 92 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
91 token_service->RemoveObserver(this); | 93 token_service->RemoveObserver(this); |
92 } | 94 } |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 have_same_accounts = false; | 315 have_same_accounts = false; |
314 break; | 316 break; |
315 } | 317 } |
316 } | 318 } |
317 } | 319 } |
318 | 320 |
319 if (!are_primaries_equal || !have_same_accounts) { | 321 if (!are_primaries_equal || !have_same_accounts) { |
320 // TODO(rogerta): fix things up. | 322 // TODO(rogerta): fix things up. |
321 } | 323 } |
322 } | 324 } |
OLD | NEW |