| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 GURL origin = url.GetOrigin(); | 186 GURL origin = url.GetOrigin(); |
| 187 if (origin == GURL("https://accounts.youtube.com") || | 187 if (origin == GURL("https://accounts.youtube.com") || |
| 188 origin == GURL("https://accounts.blogger.com")) | 188 origin == GURL("https://accounts.blogger.com")) |
| 189 return true; | 189 return true; |
| 190 | 190 |
| 191 return false; | 191 return false; |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Constants for the modal dialog / bubble sign in to chrome confirmation |
| 195 // experiment |
| 196 const char kSignInToChromeDialogFieldTrialName[] = "SignInToChromeConfirmation"; |
| 197 const char kSignInConfirmBubbleGroupName[] = "Bubble"; |
| 198 |
| 194 } // namespace | 199 } // namespace |
| 195 | 200 |
| 196 // The infobar asking the user if they want to use one-click sign in. | 201 // The infobar asking the user if they want to use one-click sign in. |
| 197 // TODO(rogerta): once we move to a web-based sign in flow, we can get rid | 202 // TODO(rogerta): once we move to a web-based sign in flow, we can get rid |
| 198 // of this infobar. | 203 // of this infobar. |
| 199 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { | 204 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { |
| 200 public: | 205 public: |
| 201 // Creates a one click signin delegate and adds it to |infobar_service|. | 206 // Creates a one click signin delegate and adds it to |infobar_service|. |
| 202 static void Create(InfoBarService* infobar_service, | 207 static void Create(InfoBarService* infobar_service, |
| 203 const std::string& session_index, | 208 const std::string& session_index, |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 858 } |
| 854 | 859 |
| 855 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 860 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 856 Profile* profile = | 861 Profile* profile = |
| 857 Profile::FromBrowserContext(contents->GetBrowserContext()); | 862 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 858 | 863 |
| 859 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." | 864 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." |
| 860 << " auto_accept=" << auto_accept_ | 865 << " auto_accept=" << auto_accept_ |
| 861 << " source=" << source_; | 866 << " source=" << source_; |
| 862 | 867 |
| 868 BrowserWindow::OneClickSigninBubbleType bubble_type; |
| 869 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) == |
| 870 kSignInConfirmBubbleGroupName) |
| 871 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE; |
| 872 else |
| 873 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG; |
| 874 |
| 863 switch (auto_accept_) { | 875 switch (auto_accept_) { |
| 864 case AUTO_ACCEPT_NONE: | 876 case AUTO_ACCEPT_NONE: |
| 865 if (SyncPromoUI::UseWebBasedSigninFlow()) { | 877 if (SyncPromoUI::UseWebBasedSigninFlow()) { |
| 866 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 878 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", |
| 867 one_click_signin::HISTOGRAM_DISMISSED, | 879 one_click_signin::HISTOGRAM_DISMISSED, |
| 868 one_click_signin::HISTOGRAM_MAX); | 880 one_click_signin::HISTOGRAM_MAX); |
| 869 } else { | 881 } else { |
| 870 OneClickInfoBarDelegateImpl::Create( | 882 OneClickInfoBarDelegateImpl::Create( |
| 871 InfoBarService::FromWebContents(contents), session_index_, email_, | 883 InfoBarService::FromWebContents(contents), session_index_, email_, |
| 872 password_); | 884 password_); |
| 873 } | 885 } |
| 874 break; | 886 break; |
| 875 case AUTO_ACCEPT_ACCEPTED: | 887 case AUTO_ACCEPT_ACCEPTED: |
| 876 SigninManager::DisableOneClickSignIn(profile); | 888 SigninManager::DisableOneClickSignIn(profile); |
| 877 browser->window()->ShowOneClickSigninBubble( | 889 browser->window()->ShowOneClickSigninBubble( |
| 878 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG, | 890 bubble_type, |
| 879 base::Bind(&StartSync, profile, browser, auto_accept_, session_index_, | 891 base::Bind(&StartSync, profile, browser, auto_accept_, session_index_, |
| 880 email_, password_)); | 892 email_, password_)); |
| 881 break; | 893 break; |
| 882 case AUTO_ACCEPT_CONFIGURE: | 894 case AUTO_ACCEPT_CONFIGURE: |
| 883 SigninManager::DisableOneClickSignIn(profile); | 895 SigninManager::DisableOneClickSignIn(profile); |
| 884 StartSync(profile, browser, auto_accept_, session_index_, email_, | 896 StartSync(profile, browser, auto_accept_, session_index_, email_, |
| 885 password_, OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 897 password_, OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 886 break; | 898 break; |
| 887 case AUTO_ACCEPT_EXPLICIT: | 899 case AUTO_ACCEPT_EXPLICIT: |
| 888 StartSync(profile, browser, auto_accept_, session_index_, email_, | 900 StartSync(profile, browser, auto_accept_, session_index_, email_, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 break; | 957 break; |
| 946 } | 958 } |
| 947 } | 959 } |
| 948 | 960 |
| 949 RedirectToNTP(); | 961 RedirectToNTP(); |
| 950 } | 962 } |
| 951 | 963 |
| 952 void OneClickSigninHelper::SigninSuccess() { | 964 void OneClickSigninHelper::SigninSuccess() { |
| 953 RedirectToNTP(); | 965 RedirectToNTP(); |
| 954 } | 966 } |
| OLD | NEW |