| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/oauth2_login_manager.h" | 5 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" |
| 6 | 6 |
| 7 #include <utility> |
| 7 #include <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 11 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 << " connection_error: " << connection_error; | 286 << " connection_error: " << connection_error; |
| 286 RecordSessionRestoreOutcome(SESSION_RESTORE_MERGE_SESSION_FAILED, | 287 RecordSessionRestoreOutcome(SESSION_RESTORE_MERGE_SESSION_FAILED, |
| 287 connection_error ? | 288 connection_error ? |
| 288 SESSION_RESTORE_CONNECTION_FAILED : | 289 SESSION_RESTORE_CONNECTION_FAILED : |
| 289 SESSION_RESTORE_FAILED); | 290 SESSION_RESTORE_FAILED); |
| 290 } | 291 } |
| 291 | 292 |
| 292 void OAuth2LoginManager::OnListAccountsSuccess(const std::string& data) { | 293 void OAuth2LoginManager::OnListAccountsSuccess(const std::string& data) { |
| 293 MergeVerificationOutcome outcome = POST_MERGE_SUCCESS; | 294 MergeVerificationOutcome outcome = POST_MERGE_SUCCESS; |
| 294 // Let's analyze which accounts we see logged in here: | 295 // Let's analyze which accounts we see logged in here: |
| 295 std::vector<std::string> accounts; | 296 std::vector<std::pair<std::string, bool> > accounts; |
| 296 gaia::ParseListAccountsData(data, &accounts); | 297 gaia::ParseListAccountsData(data, &accounts); |
| 297 std::string user_email = gaia::CanonicalizeEmail(GetPrimaryAccountId()); | 298 std::string user_email = gaia::CanonicalizeEmail(GetPrimaryAccountId()); |
| 298 if (!accounts.empty()) { | 299 if (!accounts.empty()) { |
| 299 bool found = false; | 300 bool found = false; |
| 300 bool first = true; | 301 bool first = true; |
| 301 for (std::vector<std::string>::const_iterator iter = accounts.begin(); | 302 for (std::vector<std::pair<std::string, bool> >::const_iterator iter = |
| 303 accounts.begin(); |
| 302 iter != accounts.end(); ++iter) { | 304 iter != accounts.end(); ++iter) { |
| 303 if (gaia::CanonicalizeEmail(*iter) == user_email) { | 305 if (gaia::CanonicalizeEmail(iter->first) == user_email) { |
| 304 found = true; | 306 found = true; |
| 305 break; | 307 break; |
| 306 } | 308 } |
| 307 | 309 |
| 308 first = false; | 310 first = false; |
| 309 } | 311 } |
| 310 | 312 |
| 311 if (!found) | 313 if (!found) |
| 312 outcome = POST_MERGE_MISSING_PRIMARY_ACCOUNT; | 314 outcome = POST_MERGE_MISSING_PRIMARY_ACCOUNT; |
| 313 else if (!first) | 315 else if (!first) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 FOR_EACH_OBSERVER(Observer, observer_list_, | 394 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 393 OnSessionRestoreStateChanged(user_profile_, state_)); | 395 OnSessionRestoreStateChanged(user_profile_, state_)); |
| 394 } | 396 } |
| 395 | 397 |
| 396 void OAuth2LoginManager::SetSessionRestoreStartForTesting( | 398 void OAuth2LoginManager::SetSessionRestoreStartForTesting( |
| 397 const base::Time& time) { | 399 const base::Time& time) { |
| 398 session_restore_start_ = time; | 400 session_restore_start_ = time; |
| 399 } | 401 } |
| 400 | 402 |
| 401 } // namespace chromeos | 403 } // namespace chromeos |
| OLD | NEW |