Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/ui/auto_login_info_bar_delegate.cc

Issue 10830353: Introduce InfoBarTabService API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments, merge to LKGR Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/android/infobar_stubs.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_info_bar_delegate.h" 5 #include "chrome/browser/ui/auto_login_info_bar_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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 169 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
170 InfoBarTabHelper* owner, 170 InfoBarTabHelper* owner,
171 const Params& params) 171 const Params& params)
172 : ConfirmInfoBarDelegate(owner), 172 : ConfirmInfoBarDelegate(owner),
173 params_(params), 173 params_(params),
174 button_pressed_(false) { 174 button_pressed_(false) {
175 RecordHistogramAction(HISTOGRAM_SHOWN); 175 RecordHistogramAction(HISTOGRAM_SHOWN);
176 registrar_.Add(this, 176 registrar_.Add(this,
177 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 177 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
178 content::Source<Profile>(Profile::FromBrowserContext( 178 content::Source<Profile>(Profile::FromBrowserContext(
179 owner->web_contents()->GetBrowserContext()))); 179 owner->GetWebContents()->GetBrowserContext())));
180 } 180 }
181 181
182 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { 182 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
183 if (!button_pressed_) 183 if (!button_pressed_)
184 RecordHistogramAction(HISTOGRAM_IGNORED); 184 RecordHistogramAction(HISTOGRAM_IGNORED);
185 } 185 }
186 186
187 AutoLoginInfoBarDelegate* 187 AutoLoginInfoBarDelegate*
188 AutoLoginInfoBarDelegate::AsAutoLoginInfoBarDelegate() { 188 AutoLoginInfoBarDelegate::AsAutoLoginInfoBarDelegate() {
189 return this; 189 return this;
(...skipping 18 matching lines...) Expand all
208 } 208 }
209 209
210 string16 AutoLoginInfoBarDelegate::GetButtonLabel( 210 string16 AutoLoginInfoBarDelegate::GetButtonLabel(
211 InfoBarButton button) const { 211 InfoBarButton button) const {
212 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 212 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
213 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); 213 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON);
214 } 214 }
215 215
216 bool AutoLoginInfoBarDelegate::Accept() { 216 bool AutoLoginInfoBarDelegate::Accept() {
217 // AutoLoginRedirector deletes itself. 217 // AutoLoginRedirector deletes itself.
218 new AutoLoginRedirector(&owner()->web_contents()->GetController(), 218 new AutoLoginRedirector(&owner()->GetWebContents()->GetController(),
219 params_.args); 219 params_.args);
220 RecordHistogramAction(HISTOGRAM_ACCEPTED); 220 RecordHistogramAction(HISTOGRAM_ACCEPTED);
221 button_pressed_ = true; 221 button_pressed_ = true;
222 return true; 222 return true;
223 } 223 }
224 224
225 bool AutoLoginInfoBarDelegate::Cancel() { 225 bool AutoLoginInfoBarDelegate::Cancel() {
226 PrefService* pref_service = TabContents::FromWebContents( 226 PrefService* pref_service = TabContents::FromWebContents(
227 owner()->web_contents())->profile()->GetPrefs(); 227 owner()->GetWebContents())->profile()->GetPrefs();
228 pref_service->SetBoolean(prefs::kAutologinEnabled, false); 228 pref_service->SetBoolean(prefs::kAutologinEnabled, false);
229 RecordHistogramAction(HISTOGRAM_REJECTED); 229 RecordHistogramAction(HISTOGRAM_REJECTED);
230 button_pressed_ = true; 230 button_pressed_ = true;
231 return true; 231 return true;
232 } 232 }
233 233
234 string16 AutoLoginInfoBarDelegate::GetMessageText( 234 string16 AutoLoginInfoBarDelegate::GetMessageText(
235 const std::string& username) const { 235 const std::string& username) const {
236 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE, 236 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE,
237 UTF8ToUTF16(username)); 237 UTF8ToUTF16(username));
238 } 238 }
239 239
240 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) { 240 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) {
241 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX); 241 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX);
242 } 242 }
243 243
244 void AutoLoginInfoBarDelegate::Observe(int type, 244 void AutoLoginInfoBarDelegate::Observe(int type,
245 const NotificationSource& source, 245 const NotificationSource& source,
246 const NotificationDetails& details) { 246 const NotificationDetails& details) {
247 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type); 247 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type);
248 // owner() can be NULL when InfoBarTabHelper removes us. See 248 // owner() can be NULL when InfoBarTabHelper removes us. See
249 // |InfoBarDelegate::clear_owner|. 249 // |InfoBarDelegate::clear_owner|.
250 if (owner()) 250 if (owner())
251 owner()->RemoveInfoBar(this); 251 owner()->RemoveInfoBar(this);
252 } 252 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobar_stubs.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698