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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_sync_starter.cc

Issue 1487283005: Implement the new Sync Confirmation dialog on Linux and Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some tests. Created 5 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/sync/one_click_signin_sync_starter.h" 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" 32 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h"
33 #include "chrome/browser/ui/tab_dialogs.h" 33 #include "chrome/browser/ui/tab_dialogs.h"
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" 34 #include "chrome/browser/ui/tabs/tab_strip_model.h"
35 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 35 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
36 #include "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
37 #include "chrome/grit/chromium_strings.h" 37 #include "chrome/grit/chromium_strings.h"
38 #include "chrome/grit/generated_resources.h" 38 #include "chrome/grit/generated_resources.h"
39 #include "components/browser_sync/browser/profile_sync_service.h" 39 #include "components/browser_sync/browser/profile_sync_service.h"
40 #include "components/signin/core/browser/signin_manager.h" 40 #include "components/signin/core/browser/signin_manager.h"
41 #include "components/signin/core/browser/signin_metrics.h" 41 #include "components/signin/core/browser/signin_metrics.h"
42 #include "components/signin/core/common/profile_management_switches.h"
42 #include "components/sync_driver/sync_prefs.h" 43 #include "components/sync_driver/sync_prefs.h"
43 #include "net/url_request/url_request_context_getter.h" 44 #include "net/url_request/url_request_context_getter.h"
44 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
45 46
46 namespace { 47 namespace {
47 48
48 // UMA histogram for tracking what users do when presented with the signin 49 // UMA histogram for tracking what users do when presented with the signin
49 // screen. 50 // screen.
50 // Hence, 51 // Hence,
51 // (a) existing enumerated constants should never be deleted or reordered, and 52 // (a) existing enumerated constants should never be deleted or reordered, and
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 start_mode_ = response; 385 start_mode_ = response;
385 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST) 386 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST)
386 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS; 387 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS;
387 388
388 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 389 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
389 signin->CompletePendingSignin(); 390 signin->CompletePendingSignin();
390 } 391 }
391 } 392 }
392 393
393 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed( 394 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed(
394 bool configure_sync_first) { 395 LoginUIService::SyncConfirmationUIClosedResults results) {
395 if (configure_sync_first) { 396 switch (results) {
396 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); 397 case LoginUIService::CONFIGURE_SYNC_FIRST:
397 } else { 398 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
398 ProfileSyncService* profile_sync_service = GetProfileSyncService(); 399 break;
399 if (profile_sync_service) 400 case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS: {
400 profile_sync_service->SetSyncSetupCompleted(); 401 ProfileSyncService* profile_sync_service = GetProfileSyncService();
401 FinishProfileSyncServiceSetup(); 402 if (profile_sync_service)
403 profile_sync_service->SetSyncSetupCompleted();
404 FinishProfileSyncServiceSetup();
405 break;
406 }
407 case LoginUIService::ABORT_SIGNIN:
408 break;
402 } 409 }
403 410
404 delete this; 411 delete this;
405 } 412 }
406 413
407 void OneClickSigninSyncStarter::SigninFailed( 414 void OneClickSigninSyncStarter::SigninFailed(
408 const GoogleServiceAuthError& error) { 415 const GoogleServiceAuthError& error) {
409 if (!sync_setup_completed_callback_.is_null()) 416 if (!sync_setup_completed_callback_.is_null())
410 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); 417 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE);
411 418
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (!profile_sync_service) { 458 if (!profile_sync_service) {
452 // Sync is disabled by policy. 459 // Sync is disabled by policy.
453 message = l10n_util::GetStringUTF16( 460 message = l10n_util::GetStringUTF16(
454 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); 461 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE);
455 } 462 }
456 DisplayFinalConfirmationBubble(message); 463 DisplayFinalConfirmationBubble(message);
457 } 464 }
458 break; 465 break;
459 } 466 }
460 case CONFIRM_SYNC_SETTINGS_FIRST: 467 case CONFIRM_SYNC_SETTINGS_FIRST:
461 // Blocks sync until the sync settings confirmation UI is closed. 468 if (switches::UsePasswordSeparatedSigninFlow()) {
462 DisplayFinalConfirmationBubble(base::string16()); 469 DisplayModalSyncConfirmationWindow();
470 } else {
471 // Blocks sync until the sync settings confirmation UI is closed.
472 DisplayFinalConfirmationBubble(base::string16());
473 }
463 return; 474 return;
464 case CONFIGURE_SYNC_FIRST: 475 case CONFIGURE_SYNC_FIRST:
465 ShowSettingsPage(true); // Show sync config UI. 476 ShowSettingsPage(true); // Show sync config UI.
466 break; 477 break;
467 case SHOW_SETTINGS_WITHOUT_CONFIGURE: 478 case SHOW_SETTINGS_WITHOUT_CONFIGURE:
468 ShowSettingsPage(false); // Don't show sync config UI. 479 ShowSettingsPage(false); // Don't show sync config UI.
469 break; 480 break;
470 case UNDO_SYNC: 481 case UNDO_SYNC:
471 NOTREACHED(); 482 NOTREACHED();
472 } 483 }
473 484
474 // Navigate to the |continue_url_| if one is set, unless the user first needs 485 // Navigate to the |continue_url_| if one is set, unless the user first needs
475 // to configure Sync. 486 // to configure Sync.
476 if (web_contents() && !continue_url_.is_empty() && 487 if (web_contents() && !continue_url_.is_empty() &&
477 start_mode_ != CONFIGURE_SYNC_FIRST) { 488 start_mode_ != CONFIGURE_SYNC_FIRST) {
478 LoadContinueUrl(); 489 LoadContinueUrl();
479 } 490 }
480 491
481 delete this; 492 delete this;
482 } 493 }
483 494
484 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble( 495 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble(
485 const base::string16& custom_message) { 496 const base::string16& custom_message) {
486 browser_ = EnsureBrowser(browser_, profile_, desktop_type_); 497 browser_ = EnsureBrowser(browser_, profile_, desktop_type_);
487 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 498 LoginUIServiceFactory::GetForProfile(browser_->profile())->
488 DisplayLoginResult(browser_, custom_message); 499 DisplayLoginResult(browser_, custom_message);
489 } 500 }
490 501
502 void OneClickSigninSyncStarter::DisplayModalSyncConfirmationWindow() {
503 browser_ = EnsureBrowser(browser_, profile_, desktop_type_);
504 browser_->window()->ShowModalSyncConfirmationWindow();
505 }
506
491 // static 507 // static
492 Browser* OneClickSigninSyncStarter::EnsureBrowser( 508 Browser* OneClickSigninSyncStarter::EnsureBrowser(
493 Browser* browser, 509 Browser* browser,
494 Profile* profile, 510 Profile* profile,
495 chrome::HostDesktopType desktop_type) { 511 chrome::HostDesktopType desktop_type) {
496 if (!browser) { 512 if (!browser) {
497 // The user just created a new profile or has closed the browser that 513 // The user just created a new profile or has closed the browser that
498 // we used previously. Grab the most recently active browser or else 514 // we used previously. Grab the most recently active browser or else
499 // create a new one. 515 // create a new one.
500 browser = chrome::FindLastActiveWithProfile(profile, desktop_type); 516 browser = chrome::FindLastActiveWithProfile(profile, desktop_type);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 false /* user_gesture */); 621 false /* user_gesture */);
606 } 622 }
607 623
608 void OneClickSigninSyncStarter::LoadContinueUrl() { 624 void OneClickSigninSyncStarter::LoadContinueUrl() {
609 web_contents()->GetController().LoadURL( 625 web_contents()->GetController().LoadURL(
610 continue_url_, 626 continue_url_,
611 content::Referrer(), 627 content::Referrer(),
612 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 628 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
613 std::string()); 629 std::string());
614 } 630 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698