| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // sign-in, for this profile. | 76 // sign-in, for this profile. |
| 77 void AddEmailToOneClickRejectedList(Profile* profile, | 77 void AddEmailToOneClickRejectedList(Profile* profile, |
| 78 const std::string& email) { | 78 const std::string& email) { |
| 79 PrefService* pref_service = profile->GetPrefs(); | 79 PrefService* pref_service = profile->GetPrefs(); |
| 80 ListPrefUpdate updater(pref_service, | 80 ListPrefUpdate updater(pref_service, |
| 81 prefs::kReverseAutologinRejectedEmailList); | 81 prefs::kReverseAutologinRejectedEmailList); |
| 82 updater->AppendIfNotPresent(new base::StringValue(email)); | 82 updater->AppendIfNotPresent(new base::StringValue(email)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Start syncing with the given user information. | 85 // Start syncing with the given user information. |
| 86 void StartSync(Profile* profile, | 86 void StartSync(Browser* browser, |
| 87 Browser* browser, | |
| 88 OneClickSigninHelper::AutoAccept auto_accept, | 87 OneClickSigninHelper::AutoAccept auto_accept, |
| 89 const std::string& session_index, | 88 const std::string& session_index, |
| 90 const std::string& email, | 89 const std::string& email, |
| 91 const std::string& password, | 90 const std::string& password, |
| 92 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 91 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
| 93 // The starter deletes itself once its done. | 92 // The starter deletes itself once its done. |
| 94 new OneClickSigninSyncStarter(profile, browser, session_index, email, | 93 new OneClickSigninSyncStarter(browser, session_index, email, password, |
| 95 password, start_mode); | 94 start_mode); |
| 96 | 95 |
| 97 int action = one_click_signin::HISTOGRAM_MAX; | 96 int action = one_click_signin::HISTOGRAM_MAX; |
| 98 switch (auto_accept) { | 97 switch (auto_accept) { |
| 99 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 98 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
| 100 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; | 99 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; |
| 101 break; | 100 break; |
| 102 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | 101 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: |
| 103 action = | 102 action = |
| 104 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 103 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
| 105 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : | 104 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 Profile* profile = Profile::FromBrowserContext( | 302 Profile* profile = Profile::FromBrowserContext( |
| 304 web_contents->GetBrowserContext()); | 303 web_contents->GetBrowserContext()); |
| 305 | 304 |
| 306 // User has accepted one-click sign-in for this account. Never ask again for | 305 // User has accepted one-click sign-in for this account. Never ask again for |
| 307 // this profile. | 306 // this profile. |
| 308 SigninManager::DisableOneClickSignIn(profile); | 307 SigninManager::DisableOneClickSignIn(profile); |
| 309 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); | 308 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); |
| 310 chrome::FindBrowserWithWebContents(web_contents)->window()-> | 309 chrome::FindBrowserWithWebContents(web_contents)->window()-> |
| 311 ShowOneClickSigninBubble( | 310 ShowOneClickSigninBubble( |
| 312 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, | 311 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, |
| 313 base::Bind(&StartSync, profile, browser, | 312 base::Bind(&StartSync, browser, |
| 314 OneClickSigninHelper::AUTO_ACCEPT_NONE, session_index_, | 313 OneClickSigninHelper::AUTO_ACCEPT_NONE, session_index_, |
| 315 email_, password_)); | 314 email_, password_)); |
| 316 button_pressed_ = true; | 315 button_pressed_ = true; |
| 317 return true; | 316 return true; |
| 318 } | 317 } |
| 319 | 318 |
| 320 bool OneClickInfoBarDelegateImpl::Cancel() { | 319 bool OneClickInfoBarDelegateImpl::Cancel() { |
| 321 AddEmailToOneClickRejectedList(Profile::FromBrowserContext( | 320 AddEmailToOneClickRejectedList(Profile::FromBrowserContext( |
| 322 owner()->GetWebContents()->GetBrowserContext()), email_); | 321 owner()->GetWebContents()->GetBrowserContext()), email_); |
| 323 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); | 322 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 } else { | 858 } else { |
| 860 OneClickInfoBarDelegateImpl::Create( | 859 OneClickInfoBarDelegateImpl::Create( |
| 861 InfoBarService::FromWebContents(contents), session_index_, email_, | 860 InfoBarService::FromWebContents(contents), session_index_, email_, |
| 862 password_); | 861 password_); |
| 863 } | 862 } |
| 864 break; | 863 break; |
| 865 case AUTO_ACCEPT_ACCEPTED: | 864 case AUTO_ACCEPT_ACCEPTED: |
| 866 SigninManager::DisableOneClickSignIn(profile); | 865 SigninManager::DisableOneClickSignIn(profile); |
| 867 browser->window()->ShowOneClickSigninBubble( | 866 browser->window()->ShowOneClickSigninBubble( |
| 868 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG, | 867 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG, |
| 869 base::Bind(&StartSync, profile, browser, auto_accept_, session_index_, | 868 base::Bind(&StartSync, browser, auto_accept_, session_index_, |
| 870 email_, password_)); | 869 email_, password_)); |
| 871 break; | 870 break; |
| 872 case AUTO_ACCEPT_CONFIGURE: | 871 case AUTO_ACCEPT_CONFIGURE: |
| 873 SigninManager::DisableOneClickSignIn(profile); | 872 SigninManager::DisableOneClickSignIn(profile); |
| 874 StartSync(profile, browser, auto_accept_, session_index_, email_, | 873 StartSync(browser, auto_accept_, session_index_, email_, password_, |
| 875 password_, OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 874 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 876 break; | 875 break; |
| 877 case AUTO_ACCEPT_EXPLICIT: | 876 case AUTO_ACCEPT_EXPLICIT: |
| 878 StartSync(profile, browser, auto_accept_, session_index_, email_, | 877 StartSync(browser, auto_accept_, session_index_, email_, password_, |
| 879 password_, source_ == SyncPromoUI::SOURCE_SETTINGS ? | 878 source_ == SyncPromoUI::SOURCE_SETTINGS ? |
| 880 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 879 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
| 881 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 880 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| 882 | 881 |
| 883 // If this was a last minute switch to the settings page, this means the | 882 // If this was a last minute switch to the settings page, this means the |
| 884 // started with first-run/NTP/wrench menu, and checked the "configure | 883 // started with first-run/NTP/wrench menu, and checked the "configure |
| 885 // first" checkbox. Replace the default blank continue page with an | 884 // first" checkbox. Replace the default blank continue page with an |
| 886 // about:blank page, so that when the settings page is displayed, it | 885 // about:blank page, so that when the settings page is displayed, it |
| 887 // reuses the tab. | 886 // reuses the tab. |
| 888 if (last_minute_source_change) { | 887 if (last_minute_source_change) { |
| 889 contents->GetController().LoadURL( | 888 contents->GetController().LoadURL( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 break; | 932 break; |
| 934 } | 933 } |
| 935 } | 934 } |
| 936 | 935 |
| 937 RedirectToNTP(); | 936 RedirectToNTP(); |
| 938 } | 937 } |
| 939 | 938 |
| 940 void OneClickSigninHelper::SigninSuccess() { | 939 void OneClickSigninHelper::SigninSuccess() { |
| 941 RedirectToNTP(); | 940 RedirectToNTP(); |
| 942 } | 941 } |
| OLD | NEW |