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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/sync/one_click_signin_helper.h" 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 static_cast<const void* const>( 225 static_cast<const void* const>(
226 &OneClickSigninRequestUserData::kUserDataKey); 226 &OneClickSigninRequestUserData::kUserDataKey);
227 227
228 } // namespace 228 } // namespace
229 229
230 // The infobar asking the user if they want to use one-click sign in. 230 // The infobar asking the user if they want to use one-click sign in.
231 // TODO(rogerta): once we move to a web-based sign in flow, we can get rid 231 // TODO(rogerta): once we move to a web-based sign in flow, we can get rid
232 // of this infobar. 232 // of this infobar.
233 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { 233 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate {
234 public: 234 public:
235 // Creates a one click signin delegate and adds it to |infobar_service|.
236 static void Create(InfoBarService* infobar_service,
237 const std::string& session_index,
238 const std::string& email,
239 const std::string& password);
240
241 private:
235 OneClickInfoBarDelegateImpl(InfoBarService* owner, 242 OneClickInfoBarDelegateImpl(InfoBarService* owner,
236 const std::string& session_index, 243 const std::string& session_index,
237 const std::string& email, 244 const std::string& email,
238 const std::string& password); 245 const std::string& password);
239 virtual ~OneClickInfoBarDelegateImpl(); 246 virtual ~OneClickInfoBarDelegateImpl();
240 247
241 private:
242 // InfoBarDelegate overrides. 248 // InfoBarDelegate overrides.
243 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE; 249 virtual InfoBarAutomationType GetInfoBarAutomationType() const OVERRIDE;
244 virtual void InfoBarDismissed() OVERRIDE; 250 virtual void InfoBarDismissed() OVERRIDE;
245 virtual gfx::Image* GetIcon() const OVERRIDE; 251 virtual gfx::Image* GetIcon() const OVERRIDE;
246 virtual Type GetInfoBarType() const OVERRIDE; 252 virtual Type GetInfoBarType() const OVERRIDE;
247 virtual string16 GetMessageText() const OVERRIDE; 253 virtual string16 GetMessageText() const OVERRIDE;
248 254
249 // ConfirmInfoBarDelegate overrides. 255 // ConfirmInfoBarDelegate overrides.
250 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; 256 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
251 virtual bool Accept() OVERRIDE; 257 virtual bool Accept() OVERRIDE;
(...skipping 11 matching lines...) Expand all
263 std::string session_index_; 269 std::string session_index_;
264 std::string email_; 270 std::string email_;
265 std::string password_; 271 std::string password_;
266 272
267 // Whether any UI controls in the infobar were pressed or not. 273 // Whether any UI controls in the infobar were pressed or not.
268 bool button_pressed_; 274 bool button_pressed_;
269 275
270 DISALLOW_COPY_AND_ASSIGN(OneClickInfoBarDelegateImpl); 276 DISALLOW_COPY_AND_ASSIGN(OneClickInfoBarDelegateImpl);
271 }; 277 };
272 278
279 // static
280 void OneClickInfoBarDelegateImpl::Create(InfoBarService* infobar_service,
281 const std::string& session_index,
282 const std::string& email,
283 const std::string& password) {
284 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
285 new OneClickInfoBarDelegateImpl(infobar_service, session_index, email,
286 password)));
287 }
288
273 OneClickInfoBarDelegateImpl::OneClickInfoBarDelegateImpl( 289 OneClickInfoBarDelegateImpl::OneClickInfoBarDelegateImpl(
274 InfoBarService* owner, 290 InfoBarService* owner,
275 const std::string& session_index, 291 const std::string& session_index,
276 const std::string& email, 292 const std::string& email,
277 const std::string& password) 293 const std::string& password)
278 : OneClickSigninInfoBarDelegate(owner), 294 : OneClickSigninInfoBarDelegate(owner),
279 session_index_(session_index), 295 session_index_(session_index),
280 email_(email), 296 email_(email),
281 password_(password), 297 password_(password),
282 button_pressed_(false) { 298 button_pressed_(false) {
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 if (source == SyncPromoUI::SOURCE_SETTINGS) { 876 if (source == SyncPromoUI::SOURCE_SETTINGS) {
861 source_ = SyncPromoUI::SOURCE_SETTINGS; 877 source_ = SyncPromoUI::SOURCE_SETTINGS;
862 last_minute_source_change = true; 878 last_minute_source_change = true;
863 } 879 }
864 } 880 }
865 } 881 }
866 882
867 Browser* browser = chrome::FindBrowserWithWebContents(contents); 883 Browser* browser = chrome::FindBrowserWithWebContents(contents);
868 Profile* profile = 884 Profile* profile =
869 Profile::FromBrowserContext(contents->GetBrowserContext()); 885 Profile::FromBrowserContext(contents->GetBrowserContext());
870 InfoBarService* infobar_tab_helper =
871 InfoBarService::FromWebContents(contents);
872 886
873 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." 887 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go."
874 << " auto_accept=" << auto_accept_ 888 << " auto_accept=" << auto_accept_
875 << " source=" << source_; 889 << " source=" << source_;
876 890
877 switch (auto_accept_) { 891 switch (auto_accept_) {
878 case AUTO_ACCEPT_NONE: 892 case AUTO_ACCEPT_NONE:
879 if (SyncPromoUI::UseWebBasedSigninFlow()) { 893 if (SyncPromoUI::UseWebBasedSigninFlow()) {
880 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", 894 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse",
881 one_click_signin::HISTOGRAM_DISMISSED, 895 one_click_signin::HISTOGRAM_DISMISSED,
882 one_click_signin::HISTOGRAM_MAX); 896 one_click_signin::HISTOGRAM_MAX);
883 } else { 897 } else {
884 infobar_tab_helper->AddInfoBar( 898 OneClickInfoBarDelegateImpl::Create(
885 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, 899 InfoBarService::FromWebContents(contents), session_index_, email_,
886 email_, password_)); 900 password_);
887 } 901 }
888 break; 902 break;
889 case AUTO_ACCEPT_ACCEPTED: 903 case AUTO_ACCEPT_ACCEPTED:
890 SigninManager::DisableOneClickSignIn(profile); 904 SigninManager::DisableOneClickSignIn(profile);
891 browser->window()->ShowOneClickSigninBubble( 905 browser->window()->ShowOneClickSigninBubble(
892 base::Bind(&StartSync, browser, auto_accept_, session_index_, 906 base::Bind(&StartSync, browser, auto_accept_, session_index_,
893 email_, password_)); 907 email_, password_));
894 break; 908 break;
895 case AUTO_ACCEPT_CONFIGURE: 909 case AUTO_ACCEPT_CONFIGURE:
896 SigninManager::DisableOneClickSignIn(profile); 910 SigninManager::DisableOneClickSignIn(profile);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 break; 970 break;
957 } 971 }
958 } 972 }
959 973
960 RedirectToNTP(); 974 RedirectToNTP();
961 } 975 }
962 976
963 void OneClickSigninHelper::SigninSuccess() { 977 void OneClickSigninHelper::SigninSuccess() {
964 RedirectToNTP(); 978 RedirectToNTP();
965 } 979 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/startup_browser_creator_impl.cc ('k') | chrome/browser/ui/sync/one_click_signin_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698