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 22 matching lines...) Expand all Loading... |
33 #include "chrome/browser/ui/chrome_pages.h" | 33 #include "chrome/browser/ui/chrome_pages.h" |
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/signin/core/browser/signin_manager.h" | 41 #include "components/signin/core/browser/signin_manager.h" |
42 #include "components/signin/core/browser/signin_metrics.h" | 42 #include "components/signin/core/browser/signin_metrics.h" |
43 #include "components/signin/core/common/profile_management_switches.h" | |
44 #include "components/sync_driver/sync_prefs.h" | 43 #include "components/sync_driver/sync_prefs.h" |
45 #include "net/url_request/url_request_context_getter.h" | 44 #include "net/url_request/url_request_context_getter.h" |
46 #include "ui/base/l10n/l10n_util.h" | 45 #include "ui/base/l10n/l10n_util.h" |
47 | 46 |
48 namespace { | 47 namespace { |
49 | 48 |
50 // 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 |
51 // screen. | 50 // screen. |
52 // Hence, | 51 // Hence, |
53 // (a) existing enumerated constants should never be deleted or reordered, and | 52 // (a) existing enumerated constants should never be deleted or reordered, and |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 default: | 422 default: |
424 DisplayFinalConfirmationBubble(l10n_util::GetStringUTF16( | 423 DisplayFinalConfirmationBubble(l10n_util::GetStringUTF16( |
425 IDS_SYNC_ERROR_SIGNING_IN)); | 424 IDS_SYNC_ERROR_SIGNING_IN)); |
426 break; | 425 break; |
427 } | 426 } |
428 } | 427 } |
429 delete this; | 428 delete this; |
430 } | 429 } |
431 | 430 |
432 void OneClickSigninSyncStarter::SigninSuccess() { | 431 void OneClickSigninSyncStarter::SigninSuccess() { |
433 if (switches::IsEnableWebBasedSignin()) | |
434 MergeSessionComplete(GoogleServiceAuthError(GoogleServiceAuthError::NONE)); | |
435 } | 432 } |
436 | 433 |
437 void OneClickSigninSyncStarter::MergeSessionComplete( | 434 void OneClickSigninSyncStarter::MergeSessionComplete( |
438 const GoogleServiceAuthError& error) { | 435 const GoogleServiceAuthError& error) { |
439 // Regardless of whether the merge session completed sucessfully or not, | 436 // Regardless of whether the merge session completed sucessfully or not, |
440 // continue with sync starting. | 437 // continue with sync starting. |
441 | 438 |
442 if (!sync_setup_completed_callback_.is_null()) | 439 if (!sync_setup_completed_callback_.is_null()) |
443 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); | 440 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); |
444 | 441 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // settings UI. | 525 // settings UI. |
529 bool use_same_tab = false; | 526 bool use_same_tab = false; |
530 if (web_contents()) { | 527 if (web_contents()) { |
531 GURL current_url = web_contents()->GetLastCommittedURL(); | 528 GURL current_url = web_contents()->GetLastCommittedURL(); |
532 bool is_chrome_signin_url = | 529 bool is_chrome_signin_url = |
533 current_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL; | 530 current_url.GetOrigin().spec() == chrome::kChromeUIChromeSigninURL; |
534 bool is_same_profile = | 531 bool is_same_profile = |
535 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) == | 532 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) == |
536 profile_; | 533 profile_; |
537 use_same_tab = | 534 use_same_tab = |
538 (is_chrome_signin_url || | 535 is_chrome_signin_url && |
539 signin::IsContinueUrlForWebBasedSigninFlow(current_url)) && | |
540 !signin::IsAutoCloseEnabledInURL(current_url) && | 536 !signin::IsAutoCloseEnabledInURL(current_url) && |
541 is_same_profile; | 537 is_same_profile; |
542 } | 538 } |
543 if (profile_sync_service) { | 539 if (profile_sync_service) { |
544 // Need to navigate to the settings page and display the sync UI. | 540 // Need to navigate to the settings page and display the sync UI. |
545 if (use_same_tab) { | 541 if (use_same_tab) { |
546 ShowSettingsPageInWebContents(web_contents(), | 542 ShowSettingsPageInWebContents(web_contents(), |
547 chrome::kSyncSetupSubPage); | 543 chrome::kSyncSetupSubPage); |
548 } else { | 544 } else { |
549 // If the user is setting up sync for the first time, let them configure | 545 // If the user is setting up sync for the first time, let them configure |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 false /* user_gesture */); | 605 false /* user_gesture */); |
610 } | 606 } |
611 | 607 |
612 void OneClickSigninSyncStarter::LoadContinueUrl() { | 608 void OneClickSigninSyncStarter::LoadContinueUrl() { |
613 web_contents()->GetController().LoadURL( | 609 web_contents()->GetController().LoadURL( |
614 continue_url_, | 610 continue_url_, |
615 content::Referrer(), | 611 content::Referrer(), |
616 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 612 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
617 std::string()); | 613 std::string()); |
618 } | 614 } |
OLD | NEW |