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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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
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_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"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/google/google_util.h" 15 #include "chrome/browser/google/google_util.h"
16 #include "chrome/browser/infobars/infobar.h"
16 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/ubertoken_fetcher.h" 19 #include "chrome/browser/signin/ubertoken_fetcher.h"
19 #include "chrome/browser/ui/sync/sync_promo_ui.h" 20 #include "chrome/browser/ui/sync/sync_promo_ui.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
24 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_observer.h" 26 #include "content/public/browser/notification_observer.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 137
137 } // namespace 138 } // namespace
138 139
139 140
140 141
141 // AutoLoginInfoBarDelegate --------------------------------------------------- 142 // AutoLoginInfoBarDelegate ---------------------------------------------------
142 143
143 // static 144 // static
144 void AutoLoginInfoBarDelegate::Create(InfoBarService* infobar_service, 145 void AutoLoginInfoBarDelegate::Create(InfoBarService* infobar_service,
145 const Params& params) { 146 const Params& params) {
146 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 147 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
148 scoped_ptr<ConfirmInfoBarDelegate>(
147 #if defined(OS_ANDROID) 149 #if defined(OS_ANDROID)
148 new AutoLoginInfoBarDelegateAndroid(infobar_service, params) 150 new AutoLoginInfoBarDelegateAndroid(params)
149 #else 151 #else
150 new AutoLoginInfoBarDelegate(infobar_service, params) 152 new AutoLoginInfoBarDelegate(params)
151 #endif 153 #endif
152 )); 154 )));
153 } 155 }
154 156
155 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 157 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(const Params& params)
156 InfoBarService* owner, 158 : ConfirmInfoBarDelegate(),
157 const Params& params)
158 : ConfirmInfoBarDelegate(owner),
159 params_(params), 159 params_(params),
160 button_pressed_(false) { 160 button_pressed_(false) {
161 RecordHistogramAction(SHOWN); 161 RecordHistogramAction(SHOWN);
162 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 162 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
163 content::Source<Profile>(Profile::FromBrowserContext( 163 content::Source<Profile>(Profile::FromBrowserContext(
164 web_contents()->GetBrowserContext()))); 164 web_contents()->GetBrowserContext())));
165 } 165 }
166 166
167 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { 167 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
168 if (!button_pressed_) 168 if (!button_pressed_)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 pref_service->SetBoolean(prefs::kAutologinEnabled, false); 213 pref_service->SetBoolean(prefs::kAutologinEnabled, false);
214 RecordHistogramAction(REJECTED); 214 RecordHistogramAction(REJECTED);
215 button_pressed_ = true; 215 button_pressed_ = true;
216 return true; 216 return true;
217 } 217 }
218 218
219 void AutoLoginInfoBarDelegate::Observe(int type, 219 void AutoLoginInfoBarDelegate::Observe(int type,
220 const NotificationSource& source, 220 const NotificationSource& source,
221 const NotificationDetails& details) { 221 const NotificationDetails& details) {
222 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type); 222 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type);
223 // owner() can be NULL when InfoBarService removes us. See 223 infobar()->RemoveSelf();
224 // |InfoBarDelegate::clear_owner|.
225 if (owner())
226 owner()->RemoveInfoBar(this);
227 } 224 }
228 225
229 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) { 226 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) {
230 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, 227 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action,
231 HISTOGRAM_BOUNDING_VALUE); 228 HISTOGRAM_BOUNDING_VALUE);
232 } 229 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698