| 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_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 infobar_tab_helper->AddInfoBar( | 719 infobar_tab_helper->AddInfoBar( |
| 720 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, | 720 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, |
| 721 email_, password_)); | 721 email_, password_)); |
| 722 break; | 722 break; |
| 723 case AUTO_ACCEPT_CONFIGURE: | 723 case AUTO_ACCEPT_CONFIGURE: |
| 724 StartSync(browser, auto_accept_, session_index_, email_, password_, | 724 StartSync(browser, auto_accept_, session_index_, email_, password_, |
| 725 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 725 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 726 break; | 726 break; |
| 727 case AUTO_ACCEPT_EXPLICIT: | 727 case AUTO_ACCEPT_EXPLICIT: |
| 728 StartSync(browser, auto_accept_, session_index_, email_, password_, | 728 StartSync(browser, auto_accept_, session_index_, email_, password_, |
| 729 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 729 source_ == SyncPromoUI::SOURCE_SETTINGS ? |
| 730 OneClickSigninSyncStarter::SIGNIN_ONLY : |
| 731 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| 730 break; | 732 break; |
| 731 case REJECTED_FOR_PROFILE: | 733 case REJECTED_FOR_PROFILE: |
| 732 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 734 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", |
| 733 one_click_signin::HISTOGRAM_REJECTED, | 735 one_click_signin::HISTOGRAM_REJECTED, |
| 734 one_click_signin::HISTOGRAM_MAX); | 736 one_click_signin::HISTOGRAM_MAX); |
| 735 break; | 737 break; |
| 736 default: | 738 default: |
| 737 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 739 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
| 738 break; | 740 break; |
| 739 } | 741 } |
| 740 | 742 |
| 741 AutoAccept local_auto_accept = auto_accept_; | 743 // If this explicit sign in is not from settings page, show the NTP after |
| 742 SyncPromoUI::Source local_source = source_; | 744 // sign in completes. In the case of the settings page, it will get closed |
| 745 // by SyncSetupHandler. |
| 746 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT && |
| 747 source_ != SyncPromoUI::SOURCE_SETTINGS) { |
| 748 Profile* profile = |
| 749 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 750 signin_tracker_.reset(new SigninTracker(profile, this)); |
| 751 } |
| 743 | 752 |
| 744 email_.clear(); | 753 email_.clear(); |
| 745 password_.clear(); | 754 password_.clear(); |
| 746 auto_accept_ = NO_AUTO_ACCEPT; | 755 auto_accept_ = NO_AUTO_ACCEPT; |
| 747 source_ = SyncPromoUI::SOURCE_UNKNOWN; | 756 source_ = SyncPromoUI::SOURCE_UNKNOWN; |
| 748 | |
| 749 // If this is an explicit sign in by the user, then redirect them to the | |
| 750 // NTP. | |
| 751 if (local_auto_accept == AUTO_ACCEPT_EXPLICIT) { | |
| 752 // If this is an explicit sign in from settings page, then close the | |
| 753 // tab. Otherwise show the NTP after sign in completes. | |
| 754 if (local_source == SyncPromoUI::SOURCE_SETTINGS) { | |
| 755 contents->Close(); | |
| 756 } else { | |
| 757 Profile* profile = | |
| 758 Profile::FromBrowserContext(contents->GetBrowserContext()); | |
| 759 signin_tracker_.reset(new SigninTracker(profile, this)); | |
| 760 } | |
| 761 } | |
| 762 | |
| 763 // |this| may have been deleted due to the contents->Close() call above. | |
| 764 // No members should be accessed at this point. | |
| 765 } | 757 } |
| 766 | 758 |
| 767 void OneClickSigninHelper::GaiaCredentialsValid() { | 759 void OneClickSigninHelper::GaiaCredentialsValid() { |
| 768 // Redirect to NTP with sign in bubble visible. | 760 // Redirect to NTP with sign in bubble visible. |
| 769 content::WebContents* contents = web_contents(); | 761 content::WebContents* contents = web_contents(); |
| 770 Profile* profile = | 762 Profile* profile = |
| 771 Profile::FromBrowserContext(contents->GetBrowserContext()); | 763 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 772 PrefService* pref_service = profile->GetPrefs(); | 764 PrefService* pref_service = profile->GetPrefs(); |
| 773 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); | 765 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); |
| 774 | 766 |
| 775 contents->GetController().LoadURL(GURL(chrome::kChromeUINewTabURL), | 767 contents->GetController().LoadURL(GURL(chrome::kChromeUINewTabURL), |
| 776 content::Referrer(), | 768 content::Referrer(), |
| 777 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 769 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 778 std::string()); | 770 std::string()); |
| 779 } | 771 } |
| 780 | 772 |
| 781 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { | 773 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { |
| 782 signin_tracker_.reset(); | 774 signin_tracker_.reset(); |
| 783 } | 775 } |
| 784 | 776 |
| 785 void OneClickSigninHelper::SigninSuccess() { | 777 void OneClickSigninHelper::SigninSuccess() { |
| 786 signin_tracker_.reset(); | 778 signin_tracker_.reset(); |
| 787 } | 779 } |
| OLD | NEW |