| 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/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.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 | 197 |
| 198 string16 AutoLoginInfoBarDelegate::GetButtonLabel( | 198 string16 AutoLoginInfoBarDelegate::GetButtonLabel( |
| 199 InfoBarButton button) const { | 199 InfoBarButton button) const { |
| 200 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 200 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 201 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); | 201 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); |
| 202 } | 202 } |
| 203 | 203 |
| 204 bool AutoLoginInfoBarDelegate::Accept() { | 204 bool AutoLoginInfoBarDelegate::Accept() { |
| 205 // AutoLoginRedirector deletes itself. | 205 // AutoLoginRedirector deletes itself. |
| 206 new AutoLoginRedirector(&owner()->GetWebContents()->GetController(), | 206 new AutoLoginRedirector(&owner()->web_contents()->GetController(), |
| 207 params_.header.args); | 207 params_.header.args); |
| 208 RecordHistogramAction(HISTOGRAM_ACCEPTED); | 208 RecordHistogramAction(HISTOGRAM_ACCEPTED); |
| 209 button_pressed_ = true; | 209 button_pressed_ = true; |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 | 212 |
| 213 bool AutoLoginInfoBarDelegate::Cancel() { | 213 bool AutoLoginInfoBarDelegate::Cancel() { |
| 214 Profile* profile = Profile::FromBrowserContext( | 214 Profile* profile = Profile::FromBrowserContext( |
| 215 owner()->GetWebContents()->GetBrowserContext()); | 215 owner()->web_contents()->GetBrowserContext()); |
| 216 PrefService* pref_service = profile->GetPrefs(); | 216 PrefService* pref_service = profile->GetPrefs(); |
| 217 pref_service->SetBoolean(prefs::kAutologinEnabled, false); | 217 pref_service->SetBoolean(prefs::kAutologinEnabled, false); |
| 218 RecordHistogramAction(HISTOGRAM_REJECTED); | 218 RecordHistogramAction(HISTOGRAM_REJECTED); |
| 219 button_pressed_ = true; | 219 button_pressed_ = true; |
| 220 return true; | 220 return true; |
| 221 } | 221 } |
| 222 | 222 |
| 223 string16 AutoLoginInfoBarDelegate::GetMessageText( | 223 string16 AutoLoginInfoBarDelegate::GetMessageText( |
| 224 const std::string& username) const { | 224 const std::string& username) const { |
| 225 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE, | 225 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE, |
| 226 UTF8ToUTF16(username)); | 226 UTF8ToUTF16(username)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( | 229 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( |
| 230 InfoBarService* owner, | 230 InfoBarService* owner, |
| 231 const Params& params) | 231 const Params& params) |
| 232 : ConfirmInfoBarDelegate(owner), | 232 : ConfirmInfoBarDelegate(owner), |
| 233 params_(params), | 233 params_(params), |
| 234 button_pressed_(false) { | 234 button_pressed_(false) { |
| 235 RecordHistogramAction(HISTOGRAM_SHOWN); | 235 RecordHistogramAction(HISTOGRAM_SHOWN); |
| 236 registrar_.Add(this, | 236 registrar_.Add(this, |
| 237 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 237 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
| 238 content::Source<Profile>(Profile::FromBrowserContext( | 238 content::Source<Profile>(Profile::FromBrowserContext( |
| 239 owner->GetWebContents()->GetBrowserContext()))); | 239 owner->web_contents()->GetBrowserContext()))); |
| 240 } | 240 } |
| 241 | 241 |
| 242 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { | 242 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { |
| 243 if (!button_pressed_) | 243 if (!button_pressed_) |
| 244 RecordHistogramAction(HISTOGRAM_IGNORED); | 244 RecordHistogramAction(HISTOGRAM_IGNORED); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) { | 247 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) { |
| 248 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX); | 248 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void AutoLoginInfoBarDelegate::Observe(int type, | 251 void AutoLoginInfoBarDelegate::Observe(int type, |
| 252 const NotificationSource& source, | 252 const NotificationSource& source, |
| 253 const NotificationDetails& details) { | 253 const NotificationDetails& details) { |
| 254 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type); | 254 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type); |
| 255 // owner() can be NULL when InfoBarService removes us. See | 255 // owner() can be NULL when InfoBarService removes us. See |
| 256 // |InfoBarDelegate::clear_owner|. | 256 // |InfoBarDelegate::clear_owner|. |
| 257 if (owner()) | 257 if (owner()) |
| 258 owner()->RemoveInfoBar(this); | 258 owner()->RemoveInfoBar(this); |
| 259 } | 259 } |
| OLD | NEW |