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

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

Issue 11418200: Setup from settings should allow configuration first (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict Created 8 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/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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 default: 102 default:
103 NOTREACHED() << "Invalid auto_accept: " << auto_accept; 103 NOTREACHED() << "Invalid auto_accept: " << auto_accept;
104 break; 104 break;
105 } 105 }
106 106
107 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, 107 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action,
108 one_click_signin::HISTOGRAM_MAX); 108 one_click_signin::HISTOGRAM_MAX);
109 } 109 }
110 110
111 bool UseWebBasedSigninFlow() { 111 bool UseWebBasedSigninFlow() {
112 static const bool use_web_based_singin_flow = 112 const bool use_web_based_singin_flow =
113 CommandLine::ForCurrentProcess()->HasSwitch( 113 CommandLine::ForCurrentProcess()->HasSwitch(
114 switches::kUseWebBasedSigninFlow); 114 switches::kUseWebBasedSigninFlow);
Andrew T Wilson (Slow) 2012/12/03 13:19:02 Why do we have a separate variable here?
Roger Tawa OOO till Jul 10th 2012/12/03 19:08:28 No need. Removed.
115 return use_web_based_singin_flow; 115 return use_web_based_singin_flow;
116 } 116 }
117 117
118 // Determines the source of the sign in. Its either one of the known sign in 118 // Determines the source of the sign in. Its either one of the known sign in
119 // access point (first run, NTP, menu, settings) or its an implicit sign in 119 // access point (first run, NTP, menu, settings) or its an implicit sign in
120 // via another Google property. In the former case, "service" is also 120 // via another Google property. In the former case, "service" is also
121 // checked to make sure its "chromiumsync". 121 // checked to make sure its "chromiumsync".
122 SyncPromoUI::Source GetSigninSource(const GURL& url) { 122 SyncPromoUI::Source GetSigninSource(const GURL& url) {
123 std::string value; 123 std::string value;
124 chrome_common_net::GetValueForKeyInQuery(url, "service", &value); 124 chrome_common_net::GetValueForKeyInQuery(url, "service", &value);
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 prefs::kReverseAutologinRejectedEmailList); 434 prefs::kReverseAutologinRejectedEmailList);
435 if (!rejected_emails->empty()) { 435 if (!rejected_emails->empty()) {
436 const scoped_ptr<Value> email_value(new base::StringValue(email)); 436 const scoped_ptr<Value> email_value(new base::StringValue(email));
437 base::ListValue::const_iterator iter = rejected_emails->Find( 437 base::ListValue::const_iterator iter = rejected_emails->Find(
438 *email_value); 438 *email_value);
439 if (iter != rejected_emails->end()) 439 if (iter != rejected_emails->end())
440 return false; 440 return false;
441 } 441 }
442 } 442 }
443 443
444 // If we're about to show a one-click infobar but the user has started 444 if (!UseWebBasedSigninFlow()) {
445 // a concurrent signin flow (perhaps via the promo), we may not have yet 445 // If we're about to show a one-click infobar but the user has started
446 // established an authenticated username but we still shouldn't move 446 // a concurrent signin flow (perhaps via the promo), we may not have yet
447 // forward with two simultaneous signin processes. This is a bit 447 // established an authenticated username but we still shouldn't move
448 // contentious as the one-click flow is a much smoother flow from the user 448 // forward with two simultaneous signin processes. This is a bit
449 // perspective, but it's much more difficult to hijack the other flow from 449 // contentious as the one-click flow is a much smoother flow from the user
450 // here as it is to bail. 450 // perspective, but it's much more difficult to hijack the other flow from
451 ProfileSyncService* service = 451 // here as it is to bail.
452 ProfileSyncServiceFactory::GetForProfile(profile); 452 ProfileSyncService* service =
453 if (!service) 453 ProfileSyncServiceFactory::GetForProfile(profile);
454 return false; 454 if (!service)
455 return false;
455 456
456 if (service->FirstSetupInProgress()) 457 if (service->FirstSetupInProgress())
457 return false; 458 return false;
459 }
458 } 460 }
459 461
460 return true; 462 return true;
461 } 463 }
462 464
463 // static 465 // static
464 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( 466 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread(
465 net::URLRequest* request, 467 net::URLRequest* request,
466 ProfileIOData* io_data) { 468 ProfileIOData* io_data) {
467 return CanOfferOnIOThreadImpl(request->url(), request->referrer(), 469 return CanOfferOnIOThreadImpl(request->url(), request->referrer(),
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 infobar_tab_helper->AddInfoBar( 721 infobar_tab_helper->AddInfoBar(
720 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_, 722 new OneClickInfoBarDelegateImpl(infobar_tab_helper, session_index_,
721 email_, password_)); 723 email_, password_));
722 break; 724 break;
723 case AUTO_ACCEPT_CONFIGURE: 725 case AUTO_ACCEPT_CONFIGURE:
724 StartSync(browser, auto_accept_, session_index_, email_, password_, 726 StartSync(browser, auto_accept_, session_index_, email_, password_,
725 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); 727 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
726 break; 728 break;
727 case AUTO_ACCEPT_EXPLICIT: 729 case AUTO_ACCEPT_EXPLICIT:
728 StartSync(browser, auto_accept_, session_index_, email_, password_, 730 StartSync(browser, auto_accept_, session_index_, email_, password_,
729 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); 731 source_ == SyncPromoUI::SOURCE_SETTINGS ?
732 OneClickSigninSyncStarter::SIGNIN_ONLY :
733 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
730 break; 734 break;
731 case REJECTED_FOR_PROFILE: 735 case REJECTED_FOR_PROFILE:
732 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", 736 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse",
733 one_click_signin::HISTOGRAM_REJECTED, 737 one_click_signin::HISTOGRAM_REJECTED,
734 one_click_signin::HISTOGRAM_MAX); 738 one_click_signin::HISTOGRAM_MAX);
735 break; 739 break;
736 default: 740 default:
737 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; 741 NOTREACHED() << "Invalid auto_accept=" << auto_accept_;
738 break; 742 break;
739 } 743 }
740 744
741 AutoAccept local_auto_accept = auto_accept_; 745 // If this explicit sign in is not from settings page, show the NTP after
742 SyncPromoUI::Source local_source = source_; 746 // sign in completes. In the case of the settings page, it will get closed
747 // by SyncSetupHandler.
748 if (auto_accept_ == AUTO_ACCEPT_EXPLICIT &&
749 source_ != SyncPromoUI::SOURCE_SETTINGS) {
750 Profile* profile =
751 Profile::FromBrowserContext(contents->GetBrowserContext());
752 signin_tracker_.reset(new SigninTracker(profile, this));
753 }
743 754
744 email_.clear(); 755 email_.clear();
745 password_.clear(); 756 password_.clear();
746 auto_accept_ = NO_AUTO_ACCEPT; 757 auto_accept_ = NO_AUTO_ACCEPT;
747 source_ = SyncPromoUI::SOURCE_UNKNOWN; 758 source_ = SyncPromoUI::SOURCE_UNKNOWN;
748
749 // If this is an explicit sign in by the user, then redirect them to the
750 // NTP.
751 if (local_auto_accept == AUTO_ACCEPT_EXPLICIT) {
752 // If this is an explicit sign in from settings page, then close the
753 // tab. Otherwise show the NTP after sign in completes.
754 if (local_source == SyncPromoUI::SOURCE_SETTINGS) {
755 contents->Close();
756 } else {
757 Profile* profile =
758 Profile::FromBrowserContext(contents->GetBrowserContext());
759 signin_tracker_.reset(new SigninTracker(profile, this));
760 }
761 }
762
763 // |this| may have been deleted due to the contents->Close() call above.
764 // No members should be accessed at this point.
765 } 759 }
766 760
767 void OneClickSigninHelper::GaiaCredentialsValid() { 761 void OneClickSigninHelper::GaiaCredentialsValid() {
768 // Redirect to NTP with sign in bubble visible. 762 // Redirect to NTP with sign in bubble visible.
769 content::WebContents* contents = web_contents(); 763 content::WebContents* contents = web_contents();
770 Profile* profile = 764 Profile* profile =
771 Profile::FromBrowserContext(contents->GetBrowserContext()); 765 Profile::FromBrowserContext(contents->GetBrowserContext());
772 PrefService* pref_service = profile->GetPrefs(); 766 PrefService* pref_service = profile->GetPrefs();
773 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); 767 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true);
774 768
775 contents->GetController().LoadURL(GURL(chrome::kChromeUINewTabURL), 769 contents->GetController().LoadURL(GURL(chrome::kChromeUINewTabURL),
776 content::Referrer(), 770 content::Referrer(),
777 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 771 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
778 std::string()); 772 std::string());
779 } 773 }
780 774
781 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { 775 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) {
782 signin_tracker_.reset(); 776 signin_tracker_.reset();
783 } 777 }
784 778
785 void OneClickSigninHelper::SigninSuccess() { 779 void OneClickSigninHelper::SigninSuccess() {
786 signin_tracker_.reset(); 780 signin_tracker_.reset();
787 } 781 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698