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

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: Address feedback Created 4 years, 11 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 (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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h" 34 #include "chrome/browser/ui/sync/one_click_signin_sync_observer.h"
35 #include "chrome/browser/ui/tab_dialogs.h" 35 #include "chrome/browser/ui/tab_dialogs.h"
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" 36 #include "chrome/browser/ui/tabs/tab_strip_model.h"
37 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 37 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "chrome/grit/chromium_strings.h" 39 #include "chrome/grit/chromium_strings.h"
40 #include "chrome/grit/generated_resources.h" 40 #include "chrome/grit/generated_resources.h"
41 #include "components/browser_sync/browser/profile_sync_service.h" 41 #include "components/browser_sync/browser/profile_sync_service.h"
42 #include "components/signin/core/browser/signin_manager.h" 42 #include "components/signin/core/browser/signin_manager.h"
43 #include "components/signin/core/browser/signin_metrics.h" 43 #include "components/signin/core/browser/signin_metrics.h"
44 #include "components/signin/core/common/profile_management_switches.h"
44 #include "components/sync_driver/sync_prefs.h" 45 #include "components/sync_driver/sync_prefs.h"
45 #include "content/public/browser/user_metrics.h" 46 #include "content/public/browser/user_metrics.h"
46 #include "net/base/url_util.h" 47 #include "net/base/url_util.h"
47 #include "net/url_request/url_request_context_getter.h" 48 #include "net/url_request/url_request_context_getter.h"
48 #include "ui/base/l10n/l10n_util.h" 49 #include "ui/base/l10n/l10n_util.h"
49 50
50 namespace { 51 namespace {
51 52
52 // UMA histogram for tracking what users do when presented with the signin 53 // UMA histogram for tracking what users do when presented with the signin
53 // screen. 54 // screen.
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 start_mode_ = response; 403 start_mode_ = response;
403 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST) 404 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST)
404 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS; 405 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS;
405 406
406 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 407 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
407 signin->CompletePendingSignin(); 408 signin->CompletePendingSignin();
408 } 409 }
409 } 410 }
410 411
411 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed( 412 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed(
412 bool configure_sync_first) { 413 LoginUIService::SyncConfirmationUIClosedResults results) {
413 if (configure_sync_first) { 414 switch (results) {
414 content::RecordAction( 415 case LoginUIService::CONFIGURE_SYNC_FIRST:
415 base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings")); 416 content::RecordAction(
416 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); 417 base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings"));
417 } else { 418 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
418 content::RecordAction( 419 break;
419 base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings")); 420 case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS: {
420 ProfileSyncService* profile_sync_service = GetProfileSyncService(); 421 content::RecordAction(
421 if (profile_sync_service) 422 base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings"));
422 profile_sync_service->SetSyncSetupCompleted(); 423 ProfileSyncService* profile_sync_service = GetProfileSyncService();
423 FinishProfileSyncServiceSetup(); 424 if (profile_sync_service)
425 profile_sync_service->SetSyncSetupCompleted();
426 FinishProfileSyncServiceSetup();
427 break;
428 }
429 case LoginUIService::ABORT_SIGNIN:
430 break;
424 } 431 }
425 432
426 delete this; 433 delete this;
427 } 434 }
428 435
429 void OneClickSigninSyncStarter::SigninFailed( 436 void OneClickSigninSyncStarter::SigninFailed(
430 const GoogleServiceAuthError& error) { 437 const GoogleServiceAuthError& error) {
431 if (!sync_setup_completed_callback_.is_null()) 438 if (!sync_setup_completed_callback_.is_null())
432 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); 439 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE);
433 440
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 if (!profile_sync_service) { 487 if (!profile_sync_service) {
481 // Sync is disabled by policy. 488 // Sync is disabled by policy.
482 message = l10n_util::GetStringUTF16( 489 message = l10n_util::GetStringUTF16(
483 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); 490 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE);
484 } 491 }
485 DisplayFinalConfirmationBubble(message); 492 DisplayFinalConfirmationBubble(message);
486 } 493 }
487 break; 494 break;
488 } 495 }
489 case CONFIRM_SYNC_SETTINGS_FIRST: 496 case CONFIRM_SYNC_SETTINGS_FIRST:
490 // Blocks sync until the sync settings confirmation UI is closed. 497 if (switches::UsePasswordSeparatedSigninFlow()) {
491 DisplayFinalConfirmationBubble(base::string16()); 498 DisplayModalSyncConfirmationWindow();
499 } else {
500 // Blocks sync until the sync settings confirmation UI is closed.
501 DisplayFinalConfirmationBubble(base::string16());
502 }
492 return; 503 return;
493 case CONFIGURE_SYNC_FIRST: 504 case CONFIGURE_SYNC_FIRST:
494 ShowSettingsPage(true); // Show sync config UI. 505 ShowSettingsPage(true); // Show sync config UI.
495 break; 506 break;
496 case SHOW_SETTINGS_WITHOUT_CONFIGURE: 507 case SHOW_SETTINGS_WITHOUT_CONFIGURE:
497 ShowSettingsPage(false); // Don't show sync config UI. 508 ShowSettingsPage(false); // Don't show sync config UI.
498 break; 509 break;
499 case UNDO_SYNC: 510 case UNDO_SYNC:
500 NOTREACHED(); 511 NOTREACHED();
501 } 512 }
502 513
503 // Navigate to the |continue_url_| if one is set, unless the user first needs 514 // Navigate to the |continue_url_| if one is set, unless the user first needs
504 // to configure Sync. 515 // to configure Sync.
505 if (web_contents() && !continue_url_.is_empty() && 516 if (web_contents() && !continue_url_.is_empty() &&
506 start_mode_ != CONFIGURE_SYNC_FIRST) { 517 start_mode_ != CONFIGURE_SYNC_FIRST) {
507 LoadContinueUrl(); 518 LoadContinueUrl();
508 } 519 }
509 520
510 delete this; 521 delete this;
511 } 522 }
512 523
513 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble( 524 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble(
514 const base::string16& custom_message) { 525 const base::string16& custom_message) {
515 browser_ = EnsureBrowser(browser_, profile_, desktop_type_); 526 browser_ = EnsureBrowser(browser_, profile_, desktop_type_);
516 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 527 LoginUIServiceFactory::GetForProfile(browser_->profile())->
517 DisplayLoginResult(browser_, custom_message); 528 DisplayLoginResult(browser_, custom_message);
518 } 529 }
519 530
531 void OneClickSigninSyncStarter::DisplayModalSyncConfirmationWindow() {
532 browser_ = EnsureBrowser(browser_, profile_, desktop_type_);
533 browser_->window()->ShowModalSyncConfirmationWindow();
534 }
535
520 // static 536 // static
521 Browser* OneClickSigninSyncStarter::EnsureBrowser( 537 Browser* OneClickSigninSyncStarter::EnsureBrowser(
522 Browser* browser, 538 Browser* browser,
523 Profile* profile, 539 Profile* profile,
524 chrome::HostDesktopType desktop_type) { 540 chrome::HostDesktopType desktop_type) {
525 if (!browser) { 541 if (!browser) {
526 // The user just created a new profile or has closed the browser that 542 // The user just created a new profile or has closed the browser that
527 // we used previously. Grab the most recently active browser or else 543 // we used previously. Grab the most recently active browser or else
528 // create a new one. 544 // create a new one.
529 browser = chrome::FindLastActiveWithProfile(profile, desktop_type); 545 browser = chrome::FindLastActiveWithProfile(profile, desktop_type);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 false /* user_gesture */); 652 false /* user_gesture */);
637 } 653 }
638 654
639 void OneClickSigninSyncStarter::LoadContinueUrl() { 655 void OneClickSigninSyncStarter::LoadContinueUrl() {
640 web_contents()->GetController().LoadURL( 656 web_contents()->GetController().LoadURL(
641 continue_url_, 657 continue_url_,
642 content::Referrer(), 658 content::Referrer(),
643 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 659 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
644 std::string()); 660 std::string());
645 } 661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698