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

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

Issue 11414286: Remove unneeded TabContents::FromWebContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 8 years 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/sessions/tab_restore_service_helper.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"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
15 #include "chrome/browser/infobars/infobar_tab_helper.h" 15 #include "chrome/browser/infobars/infobar_tab_helper.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/ubertoken_fetcher.h" 18 #include "chrome/browser/signin/ubertoken_fetcher.h"
19 #include "chrome/browser/ui/tab_contents/tab_contents.h"
20 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 19 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
21 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
25 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
26 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
27 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
28 #include "content/public/browser/notification_registrar.h" 27 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/browser/notification_source.h" 28 #include "content/public/browser/notification_source.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 bool AutoLoginInfoBarDelegate::Accept() { 215 bool AutoLoginInfoBarDelegate::Accept() {
217 // AutoLoginRedirector deletes itself. 216 // AutoLoginRedirector deletes itself.
218 new AutoLoginRedirector(&owner()->GetWebContents()->GetController(), 217 new AutoLoginRedirector(&owner()->GetWebContents()->GetController(),
219 params_.args); 218 params_.args);
220 RecordHistogramAction(HISTOGRAM_ACCEPTED); 219 RecordHistogramAction(HISTOGRAM_ACCEPTED);
221 button_pressed_ = true; 220 button_pressed_ = true;
222 return true; 221 return true;
223 } 222 }
224 223
225 bool AutoLoginInfoBarDelegate::Cancel() { 224 bool AutoLoginInfoBarDelegate::Cancel() {
226 PrefService* pref_service = TabContents::FromWebContents( 225 Profile* profile = Profile::FromBrowserContext(
227 owner()->GetWebContents())->profile()->GetPrefs(); 226 owner()->GetWebContents()->GetBrowserContext());
227 PrefService* pref_service = 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/sessions/tab_restore_service_helper.cc ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698