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 "chrome/browser/extensions/api/identity/account_tracker.h" | 5 #include "chrome/browser/extensions/api/identity/account_tracker.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 12 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
14 #include "chrome/browser/signin/signin_manager_base.h" | 14 #include "chrome/browser/signin/signin_manager.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" |
15 #include "content/public/browser/notification_details.h" | 16 #include "content/public/browser/notification_details.h" |
16 #include "extensions/browser/extension_system.h" | 17 #include "extensions/browser/extension_system.h" |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
20 AccountTracker::AccountTracker(Profile* profile) : profile_(profile) { | 21 AccountTracker::AccountTracker(Profile* profile) : profile_(profile) { |
21 registrar_.Add(this, | 22 registrar_.Add(this, |
22 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 23 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
23 content::Source<Profile>(profile_)); | 24 content::Source<Profile>(profile_)); |
24 | 25 |
(...skipping 20 matching lines...) Expand all Loading... |
45 void AccountTracker::AddObserver(Observer* observer) { | 46 void AccountTracker::AddObserver(Observer* observer) { |
46 observer_list_.AddObserver(observer); | 47 observer_list_.AddObserver(observer); |
47 } | 48 } |
48 | 49 |
49 void AccountTracker::RemoveObserver(Observer* observer) { | 50 void AccountTracker::RemoveObserver(Observer* observer) { |
50 observer_list_.RemoveObserver(observer); | 51 observer_list_.RemoveObserver(observer); |
51 } | 52 } |
52 | 53 |
53 void AccountTracker::OnRefreshTokenAvailable(const std::string& account_id) { | 54 void AccountTracker::OnRefreshTokenAvailable(const std::string& account_id) { |
54 // Ignore refresh tokens if there is no primary account ID at all. | 55 // Ignore refresh tokens if there is no primary account ID at all. |
55 ProfileOAuth2TokenService* token_service = | 56 SigninManagerBase* signin_manager = |
56 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 57 SigninManagerFactory::GetForProfile(profile_); |
57 if (token_service->GetPrimaryAccountId().empty()) | 58 if (signin_manager->GetAuthenticatedAccountId().empty()) |
58 return; | 59 return; |
59 | 60 |
60 DVLOG(1) << "AVAILABLE " << account_id; | 61 DVLOG(1) << "AVAILABLE " << account_id; |
61 ClearAuthError(account_id); | 62 ClearAuthError(account_id); |
62 UpdateSignInState(account_id, true); | 63 UpdateSignInState(account_id, true); |
63 } | 64 } |
64 | 65 |
65 void AccountTracker::OnRefreshTokenRevoked(const std::string& account_id) { | 66 void AccountTracker::OnRefreshTokenRevoked(const std::string& account_id) { |
66 DVLOG(1) << "REVOKED " << account_id; | 67 DVLOG(1) << "REVOKED " << account_id; |
67 UpdateSignInState(account_id, false); | 68 UpdateSignInState(account_id, false); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 LOG(ERROR) << "OnOAuthError"; | 248 LOG(ERROR) << "OnOAuthError"; |
248 tracker_->OnUserInfoFetchFailure(this); | 249 tracker_->OnUserInfoFetchFailure(this); |
249 } | 250 } |
250 | 251 |
251 void AccountIdFetcher::OnNetworkError(int response_code) { | 252 void AccountIdFetcher::OnNetworkError(int response_code) { |
252 LOG(ERROR) << "OnNetworkError " << response_code; | 253 LOG(ERROR) << "OnNetworkError " << response_code; |
253 tracker_->OnUserInfoFetchFailure(this); | 254 tracker_->OnUserInfoFetchFailure(this); |
254 } | 255 } |
255 | 256 |
256 } // namespace extensions | 257 } // namespace extensions |
OLD | NEW |