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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
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"
17 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/signin/ubertoken_fetcher.h" 18 #include "chrome/browser/signin/ubertoken_fetcher.h"
20 #include "chrome/browser/ui/sync/sync_promo_ui.h" 19 #include "chrome/browser/ui/sync/sync_promo_ui.h"
21 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
23 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
24 #include "content/public/browser/navigation_controller.h" 23 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
26 #include "content/public/browser/notification_observer.h" 25 #include "content/public/browser/notification_observer.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 120 }
122 121
123 } // namespace 122 } // namespace
124 123
125 124
126 // AutoLoginInfoBarDelegate --------------------------------------------------- 125 // AutoLoginInfoBarDelegate ---------------------------------------------------
127 126
128 // static 127 // static
129 void AutoLoginInfoBarDelegate::Create(InfoBarService* infobar_service, 128 void AutoLoginInfoBarDelegate::Create(InfoBarService* infobar_service,
130 const Params& params) { 129 const Params& params) {
131 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 130 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
132 scoped_ptr<ConfirmInfoBarDelegate>(
133 #if defined(OS_ANDROID) 131 #if defined(OS_ANDROID)
134 new AutoLoginInfoBarDelegateAndroid(params) 132 new AutoLoginInfoBarDelegateAndroid(infobar_service, params)
135 #else 133 #else
136 new AutoLoginInfoBarDelegate(params) 134 new AutoLoginInfoBarDelegate(infobar_service, params)
137 #endif 135 #endif
138 ))); 136 ));
139 } 137 }
140 138
141 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(const Params& params) 139 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
142 : ConfirmInfoBarDelegate(), 140 InfoBarService* owner,
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 infobar()->RemoveSelf(); 207 // owner() can be NULL when InfoBarService removes us. See
208 // |InfoBarDelegate::clear_owner|.
209 if (owner())
210 owner()->RemoveInfoBar(this);
208 } 211 }
209 212
210 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) { 213 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) {
211 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, 214 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action,
212 HISTOGRAM_BOUNDING_VALUE); 215 HISTOGRAM_BOUNDING_VALUE);
213 } 216 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698