OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/auto_login_infobar_delegate.h" | 5 #include "chrome/browser/ui/auto_login_infobar_delegate.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 base::string16 AutoLoginInfoBarDelegate::GetButtonLabel( | 205 base::string16 AutoLoginInfoBarDelegate::GetButtonLabel( |
206 InfoBarButton button) const { | 206 InfoBarButton button) const { |
207 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 207 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
208 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); | 208 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); |
209 } | 209 } |
210 | 210 |
211 bool AutoLoginInfoBarDelegate::Accept() { | 211 bool AutoLoginInfoBarDelegate::Accept() { |
212 // AutoLoginRedirector deletes itself. | 212 // AutoLoginRedirector deletes itself. |
213 new AutoLoginRedirector(web_contents(), params_.header.args); | 213 content::WebContents* web_contents = |
| 214 InfoBarService::WebContentsFromInfoBar(infobar()); |
| 215 new AutoLoginRedirector(web_contents, params_.header.args); |
214 RecordHistogramAction(ACCEPTED); | 216 RecordHistogramAction(ACCEPTED); |
215 button_pressed_ = true; | 217 button_pressed_ = true; |
216 return true; | 218 return true; |
217 } | 219 } |
218 | 220 |
219 bool AutoLoginInfoBarDelegate::Cancel() { | 221 bool AutoLoginInfoBarDelegate::Cancel() { |
| 222 content::WebContents* web_contents = |
| 223 InfoBarService::WebContentsFromInfoBar(infobar()); |
220 PrefService* pref_service = Profile::FromBrowserContext( | 224 PrefService* pref_service = Profile::FromBrowserContext( |
221 web_contents()->GetBrowserContext())->GetPrefs(); | 225 web_contents->GetBrowserContext())->GetPrefs(); |
222 pref_service->SetBoolean(prefs::kAutologinEnabled, false); | 226 pref_service->SetBoolean(prefs::kAutologinEnabled, false); |
223 RecordHistogramAction(REJECTED); | 227 RecordHistogramAction(REJECTED); |
224 button_pressed_ = true; | 228 button_pressed_ = true; |
225 return true; | 229 return true; |
226 } | 230 } |
227 | 231 |
228 void AutoLoginInfoBarDelegate::GoogleSignedOut(const std::string& username) { | 232 void AutoLoginInfoBarDelegate::GoogleSignedOut(const std::string& username) { |
229 infobar()->RemoveSelf(); | 233 infobar()->RemoveSelf(); |
230 } | 234 } |
231 | 235 |
232 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) { | 236 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) { |
233 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, | 237 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, |
234 HISTOGRAM_BOUNDING_VALUE); | 238 HISTOGRAM_BOUNDING_VALUE); |
235 } | 239 } |
OLD | NEW |