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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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
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/google/google_util.h" 14 #include "chrome/browser/google/google_util.h"
15 #include "chrome/browser/infobars/infobar.h" 15 #include "chrome/browser/infobars/infobar.h"
16 #include "chrome/browser/infobars/infobar_manager.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/profile_oauth2_token_service.h" 19 #include "chrome/browser/signin/profile_oauth2_token_service.h"
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
20 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
21 #include "chrome/browser/ui/sync/sync_promo_ui.h" 22 #include "chrome/browser/ui/sync/sync_promo_ui.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 25 #include "chrome/common/url_constants.h"
25 #include "content/public/browser/navigation_controller.h" 26 #include "content/public/browser/navigation_controller.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 if (!infobar_service) 141 if (!infobar_service)
141 return false; 142 return false;
142 143
143 Profile* profile = 144 Profile* profile =
144 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 145 Profile::FromBrowserContext(web_contents->GetBrowserContext());
145 #if defined(OS_ANDROID) 146 #if defined(OS_ANDROID)
146 typedef AutoLoginInfoBarDelegateAndroid Delegate; 147 typedef AutoLoginInfoBarDelegateAndroid Delegate;
147 #else 148 #else
148 typedef AutoLoginInfoBarDelegate Delegate; 149 typedef AutoLoginInfoBarDelegate Delegate;
149 #endif 150 #endif
150 return !!infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( 151 return !!infobar_service->AddInfoBar(
151 scoped_ptr<ConfirmInfoBarDelegate>(new Delegate(params, profile)))); 152 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
153 new Delegate(web_contents, params, profile))));
152 } 154 }
153 155
154 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(const Params& params, 156 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
155 Profile* profile) 157 content::WebContents* web_contents,
156 : ConfirmInfoBarDelegate(), 158 const Params& params,
159 Profile* profile)
160 : ContentConfirmInfoBarDelegate(web_contents),
157 params_(params), 161 params_(params),
158 profile_(profile), 162 profile_(profile),
159 button_pressed_(false) { 163 button_pressed_(false) {
160 RecordHistogramAction(SHOWN); 164 RecordHistogramAction(SHOWN);
161 SigninManagerFactory::GetInstance()->GetForProfile(profile_)->AddObserver( 165 SigninManagerFactory::GetInstance()->GetForProfile(profile_)->AddObserver(
162 this); 166 this);
163 } 167 }
164 168
165 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { 169 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
166 // The SigninManagerFactory is scoped to the lifetime of the app and the 170 // The SigninManagerFactory is scoped to the lifetime of the app and the
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 225 }
222 226
223 void AutoLoginInfoBarDelegate::GoogleSignedOut(const std::string& username) { 227 void AutoLoginInfoBarDelegate::GoogleSignedOut(const std::string& username) {
224 infobar()->RemoveSelf(); 228 infobar()->RemoveSelf();
225 } 229 }
226 230
227 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) { 231 void AutoLoginInfoBarDelegate::RecordHistogramAction(Actions action) {
228 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, 232 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action,
229 HISTOGRAM_BOUNDING_VALUE); 233 HISTOGRAM_BOUNDING_VALUE);
230 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698