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

Side by Side Diff: chrome/browser/chromeos/login/signin/auth_sync_observer.cc

Issue 2354613002: [Sync] Fix namespaces for the browser_sync component. (Closed)
Patch Set: Address comments. Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/login/signin/auth_sync_observer.h" 5 #include "chrome/browser/chromeos/login/signin/auth_sync_observer.h"
6 6
7 #include "base/metrics/user_metrics.h" 7 #include "base/metrics/user_metrics.h"
8 #include "base/metrics/user_metrics_action.h" 8 #include "base/metrics/user_metrics_action.h"
9 #include "chrome/browser/chromeos/login/reauth_stats.h" 9 #include "chrome/browser/chromeos/login/reauth_stats.h"
10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
11 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 11 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
12 #include "chrome/browser/chromeos/profiles/profile_helper.h" 12 #include "chrome/browser/chromeos/profiles/profile_helper.h"
13 #include "chrome/browser/sync/profile_sync_service_factory.h" 13 #include "chrome/browser/sync/profile_sync_service_factory.h"
14 #include "components/browser_sync/profile_sync_service.h" 14 #include "components/browser_sync/profile_sync_service.h"
15 #include "components/prefs/pref_service.h" 15 #include "components/prefs/pref_service.h"
16 #include "components/user_manager/user_manager.h" 16 #include "components/user_manager/user_manager.h"
17 #include "components/user_manager/user_type.h" 17 #include "components/user_manager/user_type.h"
18 #include "content/public/browser/user_metrics.h" 18 #include "content/public/browser/user_metrics.h"
19 #include "google_apis/gaia/gaia_auth_util.h" 19 #include "google_apis/gaia/gaia_auth_util.h"
20 20
21 class Profile; 21 class Profile;
22
23 namespace browser_sync {
22 class ProfileSyncService; 24 class ProfileSyncService;
25 } // namespace browser_sync
23 26
24 namespace chromeos { 27 namespace chromeos {
25 28
26 AuthSyncObserver::AuthSyncObserver(Profile* profile) 29 AuthSyncObserver::AuthSyncObserver(Profile* profile)
27 : profile_(profile) { 30 : profile_(profile) {
28 } 31 }
29 32
30 AuthSyncObserver::~AuthSyncObserver() { 33 AuthSyncObserver::~AuthSyncObserver() {
31 } 34 }
32 35
33 void AuthSyncObserver::StartObserving() { 36 void AuthSyncObserver::StartObserving() {
34 ProfileSyncService* sync_service = 37 browser_sync::ProfileSyncService* sync_service =
35 ProfileSyncServiceFactory::GetForProfile(profile_); 38 ProfileSyncServiceFactory::GetForProfile(profile_);
36 if (sync_service) 39 if (sync_service)
37 sync_service->AddObserver(this); 40 sync_service->AddObserver(this);
38 } 41 }
39 42
40 void AuthSyncObserver::Shutdown() { 43 void AuthSyncObserver::Shutdown() {
41 ProfileSyncService* sync_service = 44 browser_sync::ProfileSyncService* sync_service =
42 ProfileSyncServiceFactory::GetForProfile(profile_); 45 ProfileSyncServiceFactory::GetForProfile(profile_);
43 if (sync_service) 46 if (sync_service)
44 sync_service->RemoveObserver(this); 47 sync_service->RemoveObserver(this);
45 } 48 }
46 49
47 void AuthSyncObserver::OnStateChanged() { 50 void AuthSyncObserver::OnStateChanged() {
48 DCHECK(user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount() || 51 DCHECK(user_manager::UserManager::Get()->IsLoggedInAsUserWithGaiaAccount() ||
49 user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser()); 52 user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser());
50 ProfileSyncService* sync_service = 53 browser_sync::ProfileSyncService* sync_service =
51 ProfileSyncServiceFactory::GetForProfile(profile_); 54 ProfileSyncServiceFactory::GetForProfile(profile_);
52 const user_manager::User* user = 55 const user_manager::User* user =
53 ProfileHelper::Get()->GetUserByProfile(profile_); 56 ProfileHelper::Get()->GetUserByProfile(profile_);
54 GoogleServiceAuthError::State state = 57 GoogleServiceAuthError::State state =
55 sync_service->GetAuthError().state(); 58 sync_service->GetAuthError().state();
56 if (state != GoogleServiceAuthError::NONE && 59 if (state != GoogleServiceAuthError::NONE &&
57 state != GoogleServiceAuthError::CONNECTION_FAILED && 60 state != GoogleServiceAuthError::CONNECTION_FAILED &&
58 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE && 61 state != GoogleServiceAuthError::SERVICE_UNAVAILABLE &&
59 state != GoogleServiceAuthError::REQUEST_CANCELED) { 62 state != GoogleServiceAuthError::REQUEST_CANCELED) {
60 // Invalidate OAuth2 refresh token to force Gaia sign-in flow. This is 63 // Invalidate OAuth2 refresh token to force Gaia sign-in flow. This is
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 98 }
96 } 99 }
97 } 100 }
98 101
99 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) { 102 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) {
100 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( 103 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken(
101 profile_, token); 104 profile_, token);
102 } 105 }
103 106
104 } // namespace chromeos 107 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698