OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 if (results == LoginUIService::CONFIGURE_SYNC_FIRST) { |
396 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); | 397 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); |
397 } else { | 398 } else if (results == LoginUIService::SYNC_WITH_DEFAULT_SETTINGS) { |
398 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 399 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
399 if (profile_sync_service) | 400 if (profile_sync_service) |
400 profile_sync_service->SetSyncSetupCompleted(); | 401 profile_sync_service->SetSyncSetupCompleted(); |
401 FinishProfileSyncServiceSetup(); | 402 FinishProfileSyncServiceSetup(); |
402 } | 403 } |
Roger Tawa OOO till Jul 10th
2015/12/03 20:33:45
Nit: use a switch() statement will all the enum va
anthonyvd
2015/12/03 21:48:03
Done.
| |
403 | 404 |
404 delete this; | 405 delete this; |
405 } | 406 } |
406 | 407 |
407 void OneClickSigninSyncStarter::SigninFailed( | 408 void OneClickSigninSyncStarter::SigninFailed( |
408 const GoogleServiceAuthError& error) { | 409 const GoogleServiceAuthError& error) { |
409 if (!sync_setup_completed_callback_.is_null()) | 410 if (!sync_setup_completed_callback_.is_null()) |
410 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); | 411 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); |
411 | 412 |
412 FinishProfileSyncServiceSetup(); | 413 FinishProfileSyncServiceSetup(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 if (!profile_sync_service) { | 452 if (!profile_sync_service) { |
452 // Sync is disabled by policy. | 453 // Sync is disabled by policy. |
453 message = l10n_util::GetStringUTF16( | 454 message = l10n_util::GetStringUTF16( |
454 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); | 455 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); |
455 } | 456 } |
456 DisplayFinalConfirmationBubble(message); | 457 DisplayFinalConfirmationBubble(message); |
457 } | 458 } |
458 break; | 459 break; |
459 } | 460 } |
460 case CONFIRM_SYNC_SETTINGS_FIRST: | 461 case CONFIRM_SYNC_SETTINGS_FIRST: |
461 // Blocks sync until the sync settings confirmation UI is closed. | 462 if (switches::UsePasswordSeparatedSigninFlow()) { |
462 DisplayFinalConfirmationBubble(base::string16()); | 463 DisplayModalSyncConfirmationWindow(); |
464 } else { | |
465 // Blocks sync until the sync settings confirmation UI is closed. | |
466 DisplayFinalConfirmationBubble(base::string16()); | |
467 } | |
463 return; | 468 return; |
464 case CONFIGURE_SYNC_FIRST: | 469 case CONFIGURE_SYNC_FIRST: |
465 ShowSettingsPage(true); // Show sync config UI. | 470 ShowSettingsPage(true); // Show sync config UI. |
466 break; | 471 break; |
467 case SHOW_SETTINGS_WITHOUT_CONFIGURE: | 472 case SHOW_SETTINGS_WITHOUT_CONFIGURE: |
468 ShowSettingsPage(false); // Don't show sync config UI. | 473 ShowSettingsPage(false); // Don't show sync config UI. |
469 break; | 474 break; |
470 case UNDO_SYNC: | 475 case UNDO_SYNC: |
471 NOTREACHED(); | 476 NOTREACHED(); |
472 } | 477 } |
473 | 478 |
474 // Navigate to the |continue_url_| if one is set, unless the user first needs | 479 // Navigate to the |continue_url_| if one is set, unless the user first needs |
475 // to configure Sync. | 480 // to configure Sync. |
476 if (web_contents() && !continue_url_.is_empty() && | 481 if (web_contents() && !continue_url_.is_empty() && |
477 start_mode_ != CONFIGURE_SYNC_FIRST) { | 482 start_mode_ != CONFIGURE_SYNC_FIRST) { |
478 LoadContinueUrl(); | 483 LoadContinueUrl(); |
479 } | 484 } |
480 | 485 |
481 delete this; | 486 delete this; |
482 } | 487 } |
483 | 488 |
484 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble( | 489 void OneClickSigninSyncStarter::DisplayFinalConfirmationBubble( |
485 const base::string16& custom_message) { | 490 const base::string16& custom_message) { |
486 browser_ = EnsureBrowser(browser_, profile_, desktop_type_); | 491 browser_ = EnsureBrowser(browser_, profile_, desktop_type_); |
487 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 492 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
488 DisplayLoginResult(browser_, custom_message); | 493 DisplayLoginResult(browser_, custom_message); |
489 } | 494 } |
490 | 495 |
496 void OneClickSigninSyncStarter::DisplayModalSyncConfirmationWindow() { | |
497 browser_ = EnsureBrowser(browser_, profile_, desktop_type_); | |
498 browser_->window()->ShowModalSyncConfirmationWindow(); | |
499 } | |
500 | |
491 // static | 501 // static |
492 Browser* OneClickSigninSyncStarter::EnsureBrowser( | 502 Browser* OneClickSigninSyncStarter::EnsureBrowser( |
493 Browser* browser, | 503 Browser* browser, |
494 Profile* profile, | 504 Profile* profile, |
495 chrome::HostDesktopType desktop_type) { | 505 chrome::HostDesktopType desktop_type) { |
496 if (!browser) { | 506 if (!browser) { |
497 // The user just created a new profile or has closed the browser that | 507 // 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 | 508 // we used previously. Grab the most recently active browser or else |
499 // create a new one. | 509 // create a new one. |
500 browser = chrome::FindLastActiveWithProfile(profile, desktop_type); | 510 browser = chrome::FindLastActiveWithProfile(profile, desktop_type); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 false /* user_gesture */); | 615 false /* user_gesture */); |
606 } | 616 } |
607 | 617 |
608 void OneClickSigninSyncStarter::LoadContinueUrl() { | 618 void OneClickSigninSyncStarter::LoadContinueUrl() { |
609 web_contents()->GetController().LoadURL( | 619 web_contents()->GetController().LoadURL( |
610 continue_url_, | 620 continue_url_, |
611 content::Referrer(), | 621 content::Referrer(), |
612 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 622 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
613 std::string()); | 623 std::string()); |
614 } | 624 } |
OLD | NEW |