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

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: Fix Mac/ChromeOS builds and iOS tests. Created 4 years, 10 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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 start_mode_ = response; 405 start_mode_ = response;
405 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST) 406 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST)
406 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS; 407 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS;
407 408
408 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 409 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
409 signin->CompletePendingSignin(); 410 signin->CompletePendingSignin();
410 } 411 }
411 } 412 }
412 413
413 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed( 414 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed(
414 bool configure_sync_first) { 415 LoginUIService::SyncConfirmationUIClosedResults results) {
415 if (configure_sync_first) { 416 switch (results) {
416 content::RecordAction( 417 case LoginUIService::CONFIGURE_SYNC_FIRST:
417 base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings")); 418 content::RecordAction(
418 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); 419 base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings"));
419 } else { 420 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
420 content::RecordAction( 421 break;
421 base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings")); 422 case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS: {
422 ProfileSyncService* profile_sync_service = GetProfileSyncService(); 423 content::RecordAction(
423 if (profile_sync_service) { 424 base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings"));
424 profile_sync_service->SetFirstSetupComplete(); 425 ProfileSyncService* profile_sync_service = GetProfileSyncService();
425 profile_sync_service->RequestStart(); 426 if (profile_sync_service)
427 profile_sync_service->SetFirstSetupComplete();
428 FinishProfileSyncServiceSetup();
429 break;
426 } 430 }
427 FinishProfileSyncServiceSetup(); 431 case LoginUIService::ABORT_SIGNIN:
432 FinishProfileSyncServiceSetup();
433 break;
428 } 434 }
429 435
430 delete this; 436 delete this;
431 } 437 }
432 438
433 void OneClickSigninSyncStarter::SigninFailed( 439 void OneClickSigninSyncStarter::SigninFailed(
434 const GoogleServiceAuthError& error) { 440 const GoogleServiceAuthError& error) {
435 if (!sync_setup_completed_callback_.is_null()) 441 if (!sync_setup_completed_callback_.is_null())
436 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); 442 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE);
437 443
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 if (!profile_sync_service) { 490 if (!profile_sync_service) {
485 // Sync is disabled by policy. 491 // Sync is disabled by policy.
486 message = l10n_util::GetStringUTF16( 492 message = l10n_util::GetStringUTF16(
487 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); 493 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE);
488 } 494 }
489 DisplayFinalConfirmationBubble(message); 495 DisplayFinalConfirmationBubble(message);
490 } 496 }
491 break; 497 break;
492 } 498 }
493 case CONFIRM_SYNC_SETTINGS_FIRST: 499 case CONFIRM_SYNC_SETTINGS_FIRST:
494 // Blocks sync until the sync settings confirmation UI is closed. 500 if (switches::UsePasswordSeparatedSigninFlow()) {
495 DisplayFinalConfirmationBubble(base::string16()); 501 DisplayModalSyncConfirmationWindow();
502 } else {
503 // Blocks sync until the sync settings confirmation UI is closed.
504 DisplayFinalConfirmationBubble(base::string16());
505 }
496 return; 506 return;
497 case CONFIGURE_SYNC_FIRST: 507 case CONFIGURE_SYNC_FIRST:
498 ShowSettingsPage(true); // Show sync config UI. 508 ShowSettingsPage(true); // Show sync config UI.
499 break; 509 break;
500 case SHOW_SETTINGS_WITHOUT_CONFIGURE: 510 case SHOW_SETTINGS_WITHOUT_CONFIGURE:
501 ShowSettingsPage(false); // Don't show sync config UI. 511 ShowSettingsPage(false); // Don't show sync config UI.
502 break; 512 break;
503 case UNDO_SYNC: 513 case UNDO_SYNC:
504 NOTREACHED(); 514 NOTREACHED();
505 } 515 }
506 516
507 // Navigate to the |continue_url_| if one is set, unless the user first needs 517 // Navigate to the |continue_url_| if one is set, unless the user first needs
508 // to configure Sync. 518 // to configure Sync.
509 if (web_contents() && !continue_url_.is_empty() && 519 if (web_contents() && !continue_url_.is_empty() &&
510 start_mode_ != CONFIGURE_SYNC_FIRST) { 520 start_mode_ != CONFIGURE_SYNC_FIRST) {
511 LoadContinueUrl(); 521 LoadContinueUrl();
512 } 522 }
513 523
514 delete this; 524 delete this;
515 } 525 }
516 526
517 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble( 527 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble(
518 const base::string16& custom_message) { 528 const base::string16& custom_message) {
519 browser_ = EnsureBrowser(browser_, profile_, desktop_type_); 529 browser_ = EnsureBrowser(browser_, profile_, desktop_type_);
520 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 530 LoginUIServiceFactory::GetForProfile(browser_->profile())->
521 DisplayLoginResult(browser_, custom_message); 531 DisplayLoginResult(browser_, custom_message);
522 } 532 }
523 533
534 void OneClickSigninSyncStarter::DisplayModalSyncConfirmationWindow() {
535 browser_ = EnsureBrowser(browser_, profile_, desktop_type_);
536 browser_->window()->ShowModalSyncConfirmationWindow();
537 }
538
524 // static 539 // static
525 Browser* OneClickSigninSyncStarter::EnsureBrowser( 540 Browser* OneClickSigninSyncStarter::EnsureBrowser(
526 Browser* browser, 541 Browser* browser,
527 Profile* profile, 542 Profile* profile,
528 chrome::HostDesktopType desktop_type) { 543 chrome::HostDesktopType desktop_type) {
529 if (!browser) { 544 if (!browser) {
530 // The user just created a new profile or has closed the browser that 545 // The user just created a new profile or has closed the browser that
531 // we used previously. Grab the most recently active browser or else 546 // we used previously. Grab the most recently active browser or else
532 // create a new one. 547 // create a new one.
533 browser = chrome::FindLastActiveWithProfile(profile, desktop_type); 548 browser = chrome::FindLastActiveWithProfile(profile, desktop_type);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 false /* user_gesture */); 655 false /* user_gesture */);
641 } 656 }
642 657
643 void OneClickSigninSyncStarter::LoadContinueUrl() { 658 void OneClickSigninSyncStarter::LoadContinueUrl() {
644 web_contents()->GetController().LoadURL( 659 web_contents()->GetController().LoadURL(
645 continue_url_, 660 continue_url_,
646 content::Referrer(), 661 content::Referrer(),
647 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 662 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
648 std::string()); 663 std::string());
649 } 664 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_sync_starter.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698