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

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

Issue 1806353002: Enhanced Sync Confirmation modal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 8 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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 start_mode_ = response; 384 start_mode_ = response;
385 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST) 385 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST)
386 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS; 386 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS;
387 387
388 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 388 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
389 signin->CompletePendingSignin(); 389 signin->CompletePendingSignin();
390 } 390 }
391 } 391 }
392 392
393 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed( 393 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed(
394 LoginUIService::SyncConfirmationUIClosedResults results) { 394 LoginUIService::SyncConfirmationUIClosedResult result) {
395 395
396 if (switches::UsePasswordSeparatedSigninFlow()) { 396 if (switches::UsePasswordSeparatedSigninFlow()) {
397 // We didn't run this callback in AccountAddedToCookie so do it now. 397 // We didn't run this callback in AccountAddedToCookie so do it now.
398 if (!sync_setup_completed_callback_.is_null()) 398 if (!sync_setup_completed_callback_.is_null())
399 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); 399 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS);
400 } 400 }
401 401
402 switch (results) { 402 switch (result) {
403 case LoginUIService::CONFIGURE_SYNC_FIRST: 403 case LoginUIService::CONFIGURE_SYNC_FIRST:
404 case LoginUIService::CONFIGURE_FIRST_OPEN_ACTIVITY_CONTROLS_URL:
404 content::RecordAction( 405 content::RecordAction(
405 base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings")); 406 base::UserMetricsAction("Signin_Signin_WithAdvancedSyncSettings"));
406 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); 407 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
408
409 if (result & LoginUIService::OPEN_ACTIVITY_CONTROLS_URL) {
410 // Observer will delete itself
411 new OneClickSigninSyncObserver(
412 web_contents(),
413 profile_,
414 browser_,
415 GURL(chrome::kGoogleAccountActivityControlsURL),
416 continue_url_);
417 }
407 break; 418 break;
408 case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS: { 419 case LoginUIService::SYNC_WITH_DEFAULT_SETTINGS:
420 case LoginUIService::DEFAULT_SETTINGS_OPEN_ACTIVITY_CONTROLS_URL:
409 content::RecordAction( 421 content::RecordAction(
410 base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings")); 422 base::UserMetricsAction("Signin_Signin_WithDefaultSyncSettings"));
411 ProfileSyncService* profile_sync_service = GetProfileSyncService(); 423 SetFirstSetupComplete();
412 if (profile_sync_service)
413 profile_sync_service->SetFirstSetupComplete();
414 FinishProfileSyncServiceSetup(); 424 FinishProfileSyncServiceSetup();
425
426 if (result & LoginUIService::OPEN_ACTIVITY_CONTROLS_URL) {
427 // Open the 'Activity controls' section of the privacy settings page.
428 GURL url = GURL(chrome::kGoogleAccountActivityControlsURL);
429 content::OpenURLParams params(url,
430 content::Referrer(),
431 NEW_FOREGROUND_TAB,
432 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
433 false);
434 browser_->OpenURL(params);
435 }
415 break; 436 break;
416 }
417 case LoginUIService::ABORT_SIGNIN: 437 case LoginUIService::ABORT_SIGNIN:
418 FinishProfileSyncServiceSetup(); 438 FinishProfileSyncServiceSetup();
419 break; 439 break;
440 case LoginUIService::OPEN_ACTIVITY_CONTROLS_URL:
441 NOTREACHED();
442 }
443
444 if (result & LoginUIService::OPEN_ACTIVITY_CONTROLS_URL) {
445 content::RecordAction(
446 base::UserMetricsAction("Signin_Signin_WithActivityControlsCheckbox"));
420 } 447 }
421 448
422 delete this; 449 delete this;
423 } 450 }
424 451
425 void OneClickSigninSyncStarter::SigninFailed( 452 void OneClickSigninSyncStarter::SigninFailed(
426 const GoogleServiceAuthError& error) { 453 const GoogleServiceAuthError& error) {
427 if (!sync_setup_completed_callback_.is_null()) 454 if (!sync_setup_completed_callback_.is_null())
428 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); 455 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE);
429 456
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 DisplayModalSyncConfirmationWindow(); 495 DisplayModalSyncConfirmationWindow();
469 return; 496 return;
470 } 497 }
471 498
472 if (!sync_setup_completed_callback_.is_null()) 499 if (!sync_setup_completed_callback_.is_null())
473 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); 500 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS);
474 501
475 switch (start_mode_) { 502 switch (start_mode_) {
476 case SYNC_WITH_DEFAULT_SETTINGS: { 503 case SYNC_WITH_DEFAULT_SETTINGS: {
477 // Just kick off the sync machine, no need to configure it first. 504 // Just kick off the sync machine, no need to configure it first.
478 ProfileSyncService* profile_sync_service = GetProfileSyncService(); 505 SetFirstSetupComplete();
479 if (profile_sync_service)
480 profile_sync_service->SetFirstSetupComplete();
481 FinishProfileSyncServiceSetup(); 506 FinishProfileSyncServiceSetup();
482 if (confirmation_required_ == CONFIRM_AFTER_SIGNIN) { 507 if (confirmation_required_ == CONFIRM_AFTER_SIGNIN) {
483 base::string16 message; 508 base::string16 message;
484 if (!profile_sync_service) { 509 if (!GetProfileSyncService()) {
485 // Sync is disabled by policy. 510 // Sync is disabled by policy.
486 message = l10n_util::GetStringUTF16( 511 message = l10n_util::GetStringUTF16(
487 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); 512 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE);
488 } 513 }
489 DisplayFinalConfirmationBubble(message); 514 DisplayFinalConfirmationBubble(message);
490 } 515 }
491 break; 516 break;
492 } 517 }
493 case CONFIRM_SYNC_SETTINGS_FIRST: 518 case CONFIRM_SYNC_SETTINGS_FIRST:
494 // Blocks sync until the sync settings confirmation UI is closed. 519 // Blocks sync until the sync settings confirmation UI is closed.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 } 628 }
604 } 629 }
605 630
606 ProfileSyncService* OneClickSigninSyncStarter::GetProfileSyncService() { 631 ProfileSyncService* OneClickSigninSyncStarter::GetProfileSyncService() {
607 ProfileSyncService* service = NULL; 632 ProfileSyncService* service = NULL;
608 if (profile_->IsSyncAllowed()) 633 if (profile_->IsSyncAllowed())
609 service = ProfileSyncServiceFactory::GetForProfile(profile_); 634 service = ProfileSyncServiceFactory::GetForProfile(profile_);
610 return service; 635 return service;
611 } 636 }
612 637
638 void OneClickSigninSyncStarter::SetFirstSetupComplete() {
639 ProfileSyncService* profile_sync_service = GetProfileSyncService();
640 if (profile_sync_service)
641 profile_sync_service->SetFirstSetupComplete();
642 }
643
613 void OneClickSigninSyncStarter::FinishProfileSyncServiceSetup() { 644 void OneClickSigninSyncStarter::FinishProfileSyncServiceSetup() {
614 ProfileSyncService* service = 645 ProfileSyncService* service =
615 ProfileSyncServiceFactory::GetForProfile(profile_); 646 ProfileSyncServiceFactory::GetForProfile(profile_);
616 if (service) 647 if (service)
617 service->SetSetupInProgress(false); 648 service->SetSetupInProgress(false);
618 } 649 }
619 650
620 void OneClickSigninSyncStarter::ShowSettingsPageInWebContents( 651 void OneClickSigninSyncStarter::ShowSettingsPageInWebContents(
621 content::WebContents* contents, 652 content::WebContents* contents,
622 const std::string& sub_page) { 653 const std::string& sub_page) {
623 if (!continue_url_.is_empty()) { 654 if (!continue_url_.is_empty()) {
624 // The observer deletes itself once it's done. 655 // The observer deletes itself once it's done.
625 DCHECK(!sub_page.empty()); 656 DCHECK(!sub_page.empty());
626 new OneClickSigninSyncObserver(contents, continue_url_); 657 new OneClickSigninSyncObserver(contents, profile_, browser_,
658 GURL::EmptyGURL(), continue_url_);
627 } 659 }
628 660
629 GURL url = chrome::GetSettingsUrl(sub_page); 661 GURL url = chrome::GetSettingsUrl(sub_page);
630 content::OpenURLParams params(url, 662 content::OpenURLParams params(url,
631 content::Referrer(), 663 content::Referrer(),
632 CURRENT_TAB, 664 CURRENT_TAB,
633 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 665 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
634 false); 666 false);
635 contents->OpenURL(params); 667 contents->OpenURL(params);
636 668
637 // Activate the tab. 669 // Activate the tab.
638 Browser* browser = chrome::FindBrowserWithWebContents(contents); 670 Browser* browser = chrome::FindBrowserWithWebContents(contents);
639 int content_index = 671 int content_index =
640 browser->tab_strip_model()->GetIndexOfWebContents(contents); 672 browser->tab_strip_model()->GetIndexOfWebContents(contents);
641 browser->tab_strip_model()->ActivateTabAt(content_index, 673 browser->tab_strip_model()->ActivateTabAt(content_index,
642 false /* user_gesture */); 674 false /* user_gesture */);
643 } 675 }
644 676
645 void OneClickSigninSyncStarter::LoadContinueUrl() { 677 void OneClickSigninSyncStarter::LoadContinueUrl() {
646 web_contents()->GetController().LoadURL( 678 web_contents()->GetController().LoadURL(
647 continue_url_, 679 continue_url_,
648 content::Referrer(), 680 content::Referrer(),
649 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 681 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
650 std::string()); 682 std::string());
651 } 683 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698