| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 new OneClickSigninSyncStarter(browser, session_index, email, password, | 146 new OneClickSigninSyncStarter(browser, session_index, email, password, |
| 147 start_mode); | 147 start_mode); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace | 150 } // namespace |
| 151 | 151 |
| 152 bool OneClickLoginInfoBarDelegate::Accept() { | 152 bool OneClickLoginInfoBarDelegate::Accept() { |
| 153 // User has accepted one-click sign-in for this account. Never ask again for | 153 // User has accepted one-click sign-in for this account. Never ask again for |
| 154 // this profile. | 154 // this profile. |
| 155 DisableOneClickSignIn(); | 155 DisableOneClickSignIn(); |
| 156 content::WebContents* web_contents = owner()->web_contents(); | 156 content::WebContents* web_contents = owner()->GetWebContents(); |
| 157 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); | 157 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); |
| 158 browser::FindBrowserWithWebContents(web_contents)->window()-> | 158 browser::FindBrowserWithWebContents(web_contents)->window()-> |
| 159 ShowOneClickSigninBubble(base::Bind(&StartSync, web_contents, | 159 ShowOneClickSigninBubble(base::Bind(&StartSync, web_contents, |
| 160 session_index_, email_, password_)); | 160 session_index_, email_, password_)); |
| 161 button_pressed_ = true; | 161 button_pressed_ = true; |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool OneClickLoginInfoBarDelegate::Cancel() { | 165 bool OneClickLoginInfoBarDelegate::Cancel() { |
| 166 AddEmailToOneClickRejectedList(email_); | 166 AddEmailToOneClickRejectedList(email_); |
| 167 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); | 167 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); |
| 168 button_pressed_ = true; | 168 button_pressed_ = true; |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 string16 OneClickLoginInfoBarDelegate::GetLinkText() const { | 172 string16 OneClickLoginInfoBarDelegate::GetLinkText() const { |
| 173 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 173 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool OneClickLoginInfoBarDelegate::LinkClicked( | 176 bool OneClickLoginInfoBarDelegate::LinkClicked( |
| 177 WindowOpenDisposition disposition) { | 177 WindowOpenDisposition disposition) { |
| 178 RecordHistogramAction(one_click_signin::HISTOGRAM_LEARN_MORE); | 178 RecordHistogramAction(one_click_signin::HISTOGRAM_LEARN_MORE); |
| 179 content::OpenURLParams params( | 179 content::OpenURLParams params( |
| 180 GURL(chrome::kChromeSyncLearnMoreURL), content::Referrer(), disposition, | 180 GURL(chrome::kChromeSyncLearnMoreURL), content::Referrer(), disposition, |
| 181 content::PAGE_TRANSITION_LINK, false); | 181 content::PAGE_TRANSITION_LINK, false); |
| 182 owner()->web_contents()->OpenURL(params); | 182 owner()->GetWebContents()->OpenURL(params); |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 | 185 |
| 186 | 186 |
| 187 InfoBarDelegate::InfoBarAutomationType | 187 InfoBarDelegate::InfoBarAutomationType |
| 188 OneClickLoginInfoBarDelegate::GetInfoBarAutomationType() const { | 188 OneClickLoginInfoBarDelegate::GetInfoBarAutomationType() const { |
| 189 return ONE_CLICK_LOGIN_INFOBAR; | 189 return ONE_CLICK_LOGIN_INFOBAR; |
| 190 } | 190 } |
| 191 | 191 |
| 192 void OneClickLoginInfoBarDelegate::DisableOneClickSignIn() { | 192 void OneClickLoginInfoBarDelegate::DisableOneClickSignIn() { |
| 193 PrefService* pref_service = | 193 PrefService* pref_service = |
| 194 TabContents::FromWebContents(owner()->web_contents())-> | 194 TabContents::FromWebContents(owner()->GetWebContents())-> |
| 195 profile()->GetPrefs(); | 195 profile()->GetPrefs(); |
| 196 pref_service->SetBoolean(prefs::kReverseAutologinEnabled, false); | 196 pref_service->SetBoolean(prefs::kReverseAutologinEnabled, false); |
| 197 } | 197 } |
| 198 | 198 |
| 199 void OneClickLoginInfoBarDelegate::AddEmailToOneClickRejectedList( | 199 void OneClickLoginInfoBarDelegate::AddEmailToOneClickRejectedList( |
| 200 const std::string& email) { | 200 const std::string& email) { |
| 201 PrefService* pref_service = | 201 PrefService* pref_service = |
| 202 TabContents::FromWebContents(owner()->web_contents())-> | 202 TabContents::FromWebContents(owner()->GetWebContents())-> |
| 203 profile()->GetPrefs(); | 203 profile()->GetPrefs(); |
| 204 ListPrefUpdate updater(pref_service, | 204 ListPrefUpdate updater(pref_service, |
| 205 prefs::kReverseAutologinRejectedEmailList); | 205 prefs::kReverseAutologinRejectedEmailList); |
| 206 updater->AppendIfNotPresent(base::Value::CreateStringValue(email)); | 206 updater->AppendIfNotPresent(base::Value::CreateStringValue(email)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void OneClickLoginInfoBarDelegate::RecordHistogramAction(int action) { | 209 void OneClickLoginInfoBarDelegate::RecordHistogramAction(int action) { |
| 210 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 210 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, |
| 211 one_click_signin::HISTOGRAM_MAX); | 211 one_click_signin::HISTOGRAM_MAX); |
| 212 } | 212 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 session_index_ = session_index; | 378 session_index_ = session_index; |
| 379 email_ = email; | 379 email_ = email; |
| 380 } | 380 } |
| 381 | 381 |
| 382 void OneClickSigninHelper::SavePassword(const std::string& password) { | 382 void OneClickSigninHelper::SavePassword(const std::string& password) { |
| 383 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of | 383 // TODO(rogerta): in the case of a 2-factor or captcha or some other type of |
| 384 // challenge, its possible for the user to never complete the signin. | 384 // challenge, its possible for the user to never complete the signin. |
| 385 // Should have a way to detect this and clear the password member. | 385 // Should have a way to detect this and clear the password member. |
| 386 password_ = password; | 386 password_ = password; |
| 387 } | 387 } |
| OLD | NEW |