OLD | NEW |
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" | |
19 #include "google_apis/gaia/gaia_auth_util.h" | 18 #include "google_apis/gaia/gaia_auth_util.h" |
20 | 19 |
21 class Profile; | 20 class Profile; |
22 | 21 |
23 namespace browser_sync { | 22 namespace browser_sync { |
24 class ProfileSyncService; | 23 class ProfileSyncService; |
25 } // namespace browser_sync | 24 } // namespace browser_sync |
26 | 25 |
27 namespace chromeos { | 26 namespace chromeos { |
28 | 27 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 RecordReauthReason(account_id, ReauthReason::SYNC_FAILED); | 71 RecordReauthReason(account_id, ReauthReason::SYNC_FAILED); |
73 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED && | 72 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED && |
74 old_status != user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) { | 73 old_status != user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) { |
75 // Attempt to restore token from file. | 74 // Attempt to restore token from file. |
76 ChromeUserManager::Get() | 75 ChromeUserManager::Get() |
77 ->GetSupervisedUserManager() | 76 ->GetSupervisedUserManager() |
78 ->LoadSupervisedUserToken( | 77 ->LoadSupervisedUserToken( |
79 profile_, | 78 profile_, |
80 base::Bind(&AuthSyncObserver::OnSupervisedTokenLoaded, | 79 base::Bind(&AuthSyncObserver::OnSupervisedTokenLoaded, |
81 base::Unretained(this))); | 80 base::Unretained(this))); |
82 content::RecordAction( | 81 base::RecordAction( |
83 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Invalidated")); | 82 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Invalidated")); |
84 } | 83 } |
85 } else if (state == GoogleServiceAuthError::NONE) { | 84 } else if (state == GoogleServiceAuthError::NONE) { |
86 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED && | 85 if (user->GetType() == user_manager::USER_TYPE_SUPERVISED && |
87 user->oauth_token_status() == | 86 user->oauth_token_status() == |
88 user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) { | 87 user_manager::User::OAUTH2_TOKEN_STATUS_INVALID) { |
89 LOG(ERROR) << | 88 LOG(ERROR) << |
90 "Got an incorrectly invalidated token case, restoring token status."; | 89 "Got an incorrectly invalidated token case, restoring token status."; |
91 user_manager::UserManager::Get()->SaveUserOAuthStatus( | 90 user_manager::UserManager::Get()->SaveUserOAuthStatus( |
92 user->GetAccountId(), user_manager::User::OAUTH2_TOKEN_STATUS_VALID); | 91 user->GetAccountId(), user_manager::User::OAUTH2_TOKEN_STATUS_VALID); |
93 content::RecordAction( | 92 base::RecordAction( |
94 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Recovered")); | 93 base::UserMetricsAction("ManagedUsers_Chromeos_Sync_Recovered")); |
95 } | 94 } |
96 } | 95 } |
97 } | 96 } |
98 | 97 |
99 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) { | 98 void AuthSyncObserver::OnSupervisedTokenLoaded(const std::string& token) { |
100 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( | 99 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( |
101 profile_, token); | 100 profile_, token); |
102 } | 101 } |
103 | 102 |
104 } // namespace chromeos | 103 } // namespace chromeos |
OLD | NEW |