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

Side by Side Diff: chrome/browser/sync/sync_setup_flow.cc

Issue 4980005: Allow sync with 2-factor StrongAuth accounts in ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored 2-factor error passing Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sync/sync_setup_flow.h" 5 #include "chrome/browser/sync/sync_setup_flow.h"
6 6
7 #include "app/gfx/font_util.h" 7 #include "app/gfx/font_util.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/browser.h" 15 #include "chrome/browser/browser.h"
16 #include "chrome/browser/browser_list.h" 16 #include "chrome/browser/browser_list.h"
17 #if defined(OS_CHROMEOS)
18 #include "chrome/browser/chromeos/login/user_manager.h"
19 #endif
20 #if defined(OS_MACOSX) 17 #if defined(OS_MACOSX)
21 #include "chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h" 18 #include "chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h"
22 #endif 19 #endif
23 #include "chrome/browser/dom_ui/dom_ui_util.h" 20 #include "chrome/browser/dom_ui/dom_ui_util.h"
24 #include "chrome/browser/platform_util.h" 21 #include "chrome/browser/platform_util.h"
25 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
26 #include "chrome/browser/profile.h" 23 #include "chrome/browser/profile.h"
27 #include "chrome/browser/renderer_host/render_view_host.h" 24 #include "chrome/browser/renderer_host/render_view_host.h"
28 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
29 #include "chrome/browser/tab_contents/tab_contents.h" 26 #include "chrome/browser/tab_contents/tab_contents.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 // static 388 // static
392 void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service, 389 void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service,
393 DictionaryValue* args) { 390 DictionaryValue* args) {
394 args->SetString("iframeToShow", "login"); 391 args->SetString("iframeToShow", "login");
395 const GoogleServiceAuthError& error = service->GetAuthError(); 392 const GoogleServiceAuthError& error = service->GetAuthError();
396 if (!service->last_attempted_user_email().empty()) { 393 if (!service->last_attempted_user_email().empty()) {
397 args->SetString("user", service->last_attempted_user_email()); 394 args->SetString("user", service->last_attempted_user_email());
398 args->SetInteger("error", error.state()); 395 args->SetInteger("error", error.state());
399 args->SetBoolean("editable_user", true); 396 args->SetBoolean("editable_user", true);
400 } else { 397 } else {
401 string16 user(service->GetAuthenticatedUsername()); 398 string16 user;
402 #if defined(OS_CHROMEOS) 399 if (!service->cros_user().empty())
403 if (user.empty()) { 400 user = UTF8ToUTF16(service->cros_user());
404 std::string email = 401 else
405 chromeos::UserManager::Get()->logged_in_user().email(); 402 user = service->GetAuthenticatedUsername();
406 user = UTF8ToUTF16(email);
407 }
408 #endif
409 args->SetString("user", user); 403 args->SetString("user", user);
410 args->SetInteger("error", 0); 404 args->SetInteger("error", 0);
411 args->SetBoolean("editable_user", user.empty()); 405 args->SetBoolean("editable_user", user.empty());
412 } 406 }
413 407
414 args->SetString("captchaUrl", error.captcha().image_url.spec()); 408 args->SetString("captchaUrl", error.captcha().image_url.spec());
415 } 409 }
416 410
417 // static 411 // static
418 void SyncSetupFlow::GetArgsForEnterPassphrase( 412 void SyncSetupFlow::GetArgsForEnterPassphrase(
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 const std::string& mode) { 689 const std::string& mode) {
696 if (current_state_ == SyncSetupWizard::ENTER_PASSPHRASE) { 690 if (current_state_ == SyncSetupWizard::ENTER_PASSPHRASE) {
697 service_->SetPassphrase(passphrase, mode == std::string("enter")); 691 service_->SetPassphrase(passphrase, mode == std::string("enter"));
698 Advance(SyncSetupWizard::SETTING_UP); 692 Advance(SyncSetupWizard::SETTING_UP);
699 } else if (configuration_pending_) { 693 } else if (configuration_pending_) {
700 DCHECK_EQ(SyncSetupWizard::CREATE_PASSPHRASE, current_state_); 694 DCHECK_EQ(SyncSetupWizard::CREATE_PASSPHRASE, current_state_);
701 configuration_.secondary_passphrase = passphrase; 695 configuration_.secondary_passphrase = passphrase;
702 OnConfigurationComplete(); 696 OnConfigurationComplete();
703 } 697 }
704 } 698 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698