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

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 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 121 }
121 122
122 } // namespace 123 } // namespace
123 124
124 125
125 // AutoLoginInfoBarDelegate --------------------------------------------------- 126 // AutoLoginInfoBarDelegate ---------------------------------------------------
126 127
127 // static 128 // static
128 void AutoLoginInfoBarDelegate::Create(InfoBarService* infobar_service, 129 void AutoLoginInfoBarDelegate::Create(InfoBarService* infobar_service,
129 const Params& params) { 130 const Params& params) {
130 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 131 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
132 scoped_ptr<ConfirmInfoBarDelegate>(
131 #if defined(OS_ANDROID) 133 #if defined(OS_ANDROID)
132 new AutoLoginInfoBarDelegateAndroid(infobar_service, params) 134 new AutoLoginInfoBarDelegateAndroid(params)
133 #else 135 #else
134 new AutoLoginInfoBarDelegate(infobar_service, params) 136 new AutoLoginInfoBarDelegate(params)
135 #endif 137 #endif
136 )); 138 )));
137 } 139 }
138 140
139 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 141 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(const Params& params)
140 InfoBarService* owner, 142 : ConfirmInfoBarDelegate(),
141 const Params& params)
142 : ConfirmInfoBarDelegate(owner),
143 params_(params), 143 params_(params),
144 button_pressed_(false) { 144 button_pressed_(false) {
145 RecordHistogramAction(SHOWN); 145 RecordHistogramAction(SHOWN);
146 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 146 registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
147 content::Source<Profile>(Profile::FromBrowserContext( 147 content::Source<Profile>(Profile::FromBrowserContext(
148 web_contents()->GetBrowserContext()))); 148 web_contents()->GetBrowserContext())));
149 } 149 }
150 150
151 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { 151 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
152 if (!button_pressed_) 152 if (!button_pressed_)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 RecordHistogramAction(REJECTED); 197 RecordHistogramAction(REJECTED);
198 button_pressed_ = true; 198 button_pressed_ = true;
199 return true; 199 return true;
200 } 200 }
201 201
202 void AutoLoginInfoBarDelegate::Observe( 202 void AutoLoginInfoBarDelegate::Observe(
203 int type, 203 int type,
204 const content::NotificationSource& source, 204 const content::NotificationSource& source,
205 const content::NotificationDetails& details) { 205 const content::NotificationDetails& details) {
206 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type); 206 DCHECK_EQ(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, type);
207 // owner() can be NULL when InfoBarService removes us. See 207 infobar()->RemoveSelf();
208 // |InfoBarDelegate::clear_owner|.
209 if (owner())
210 owner()->RemoveInfoBar(this);
211 } 208 }
212 209
213 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) { 210 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) {
214 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, 211 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action,
215 HISTOGRAM_BOUNDING_VALUE); 212 HISTOGRAM_BOUNDING_VALUE);
216 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/auto_login_infobar_delegate.h ('k') | chrome/browser/ui/cocoa/infobars/alternate_nav_infobar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698