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

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

Issue 12362002: Expanding signin histogram coverage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors); 495 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors);
496 } 496 }
497 497
498 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { 498 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) {
499 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, 499 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action,
500 one_click_signin::HISTOGRAM_MAX); 500 one_click_signin::HISTOGRAM_MAX);
501 } 501 }
502 502
503 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) 503 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents)
504 : content::WebContentsObserver(web_contents), 504 : content::WebContentsObserver(web_contents),
505 showing_signin_(false),
505 auto_accept_(AUTO_ACCEPT_NONE), 506 auto_accept_(AUTO_ACCEPT_NONE),
506 source_(SyncPromoUI::SOURCE_UNKNOWN) { 507 source_(SyncPromoUI::SOURCE_UNKNOWN) {
507 } 508 }
508 509
509 OneClickSigninHelper::~OneClickSigninHelper() { 510 OneClickSigninHelper::~OneClickSigninHelper() {
510 content::WebContents* contents = web_contents(); 511 content::WebContents* contents = web_contents();
511 if (contents) { 512 if (contents) {
512 Profile* profile = 513 Profile* profile =
513 Profile::FromBrowserContext(contents->GetBrowserContext()); 514 Profile::FromBrowserContext(contents->GetBrowserContext());
514 ProfileSyncService* sync_service = 515 ProfileSyncService* sync_service =
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, 834 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id,
834 route_id); 835 route_id);
835 836
836 // TODO(mathp): The appearance of this infobar should be tested using a 837 // TODO(mathp): The appearance of this infobar should be tested using a
837 // browser_test. 838 // browser_test.
838 OneClickSigninHelper* helper = 839 OneClickSigninHelper* helper =
839 OneClickSigninHelper::FromWebContents(web_contents); 840 OneClickSigninHelper::FromWebContents(web_contents);
840 if (!helper) 841 if (!helper)
841 return; 842 return;
842 843
843 // Save the email in the one-click signin manager. The manager may
844 // not exist if the contents is incognito or if the profile is already
845 // connected to a Google account.
846 if (!session_index.empty())
847 helper->session_index_ = session_index;
848
849 if (!email.empty())
850 helper->email_ = email;
851
852 if (auto_accept != AUTO_ACCEPT_NONE) { 844 if (auto_accept != AUTO_ACCEPT_NONE) {
853 helper->auto_accept_ = auto_accept; 845 helper->auto_accept_ = auto_accept;
854 helper->source_ = source; 846 helper->source_ = source;
855 } 847 }
856 848
857 CanOfferFor can_offer_for = 849 CanOfferFor can_offer_for =
858 (auto_accept != AUTO_ACCEPT_EXPLICIT && 850 (auto_accept != AUTO_ACCEPT_EXPLICIT &&
859 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? 851 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ?
860 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; 852 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL;
861 std::string error_message; 853 std::string error_message;
862 854
863 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, 855 if (!web_contents || !CanOffer(web_contents, can_offer_for, email,
864 &error_message)) { 856 &error_message)) {
865 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; 857 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering";
866 if (helper && helper->error_message_.empty() && !error_message.empty()) 858 if (helper && helper->error_message_.empty() && !error_message.empty())
867 helper->error_message_ = error_message; 859 helper->error_message_ = error_message;
868 860
869 return; 861 return;
870 } 862 }
871 863
864 // Save the email in the one-click signin manager. The manager may
865 // not exist if the contents is incognito or if the profile is already
866 // connected to a Google account.
867 if (!session_index.empty())
868 helper->session_index_ = session_index;
869
870 if (!email.empty())
871 helper->email_ = email;
872
872 if (continue_url.is_valid()) 873 if (continue_url.is_valid())
873 helper->continue_url_ = continue_url; 874 helper->continue_url_ = continue_url;
874 } 875 }
875 876
876 void OneClickSigninHelper::RedirectToNTP(bool show_bubble) { 877 void OneClickSigninHelper::RedirectToNTP(bool show_bubble) {
877 VLOG(1) << "OneClickSigninHelper::RedirectToNTP"; 878 VLOG(1) << "OneClickSigninHelper::RedirectToNTP";
878 879
879 // Redirect to NTP with sign in bubble visible. 880 // Redirect to NTP with sign in bubble visible.
880 content::WebContents* contents = web_contents(); 881 content::WebContents* contents = web_contents();
881 Profile* profile = 882 Profile* profile =
(...skipping 27 matching lines...) Expand all
909 910
910 content::WebContents* contents = web_contents(); 911 content::WebContents* contents = web_contents();
911 contents->GetController().LoadURL(page, 912 contents->GetController().LoadURL(page,
912 content::Referrer(), 913 content::Referrer(),
913 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 914 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
914 std::string()); 915 std::string());
915 } 916 }
916 917
917 void OneClickSigninHelper::CleanTransientState() { 918 void OneClickSigninHelper::CleanTransientState() {
918 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; 919 VLOG(1) << "OneClickSigninHelper::CleanTransientState";
920 showing_signin_ = false;
919 email_.clear(); 921 email_.clear();
920 password_.clear(); 922 password_.clear();
921 auto_accept_ = AUTO_ACCEPT_NONE; 923 auto_accept_ = AUTO_ACCEPT_NONE;
922 source_ = SyncPromoUI::SOURCE_UNKNOWN; 924 source_ = SyncPromoUI::SOURCE_UNKNOWN;
923 continue_url_ = GURL(); 925 continue_url_ = GURL();
924 926
925 // Post to IO thread to clear pending email. 927 // Post to IO thread to clear pending email.
926 Profile* profile = 928 Profile* profile =
927 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 929 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
928 content::BrowserThread::PostTask( 930 content::BrowserThread::PostTask(
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 968
967 // If an error has already occured during the sign in flow, make sure to 969 // If an error has already occured during the sign in flow, make sure to
968 // display it to the user and abort the process. Do this only for 970 // display it to the user and abort the process. Do this only for
969 // explicit sign ins. 971 // explicit sign ins.
970 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { 972 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) {
971 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; 973 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_;
972 RedirectToNTP(true); 974 RedirectToNTP(true);
973 return; 975 return;
974 } 976 }
975 977
978 if ((StartsWithASCII(url.spec(), GaiaUrls::GetInstance()->service_login_url(),
979 false) &&
980 source_ != SyncPromoUI::SOURCE_UNKNOWN) ||
981 !email_.empty()) {
982 if (!showing_signin_)
983 LOG(INFO) << "OneClickSigninHelper::DidStopLoading: doing da login";
984 showing_signin_ = true;
985 }
Roger Tawa OOO till Jul 10th 2013/02/27 20:43:22 To compare the urls, it might be better to do the
jwd 2013/02/28 15:55:45 Done.
986
976 // When Gaia finally redirects to the continue URL, Gaia will add some 987 // When Gaia finally redirects to the continue URL, Gaia will add some
977 // extra query parameters. So ignore the parameters when checking to see 988 // extra query parameters. So ignore the parameters when checking to see
978 // if the user has continued. 989 // if the user has continued.
979 GURL::Replacements replacements; 990 GURL::Replacements replacements;
980 replacements.ClearQuery(); 991 replacements.ClearQuery();
981 const bool continue_url_match_accept = ( 992 const bool continue_url_match_accept = (
982 auto_accept_ == AUTO_ACCEPT_EXPLICIT && 993 auto_accept_ == AUTO_ACCEPT_EXPLICIT &&
983 continue_url_.is_valid() && 994 continue_url_.is_valid() &&
984 url.ReplaceComponents(replacements) == 995 url.ReplaceComponents(replacements) ==
985 continue_url_.ReplaceComponents(replacements)); 996 continue_url_.ReplaceComponents(replacements));
986 997
987 // If there is no valid email or password yet, there is nothing to do. 998 // If there is no valid email or password yet, there is nothing to do.
988 if (email_.empty() || password_.empty()) { 999 if (email_.empty() || password_.empty()) {
1000 VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do";
989 if (continue_url_match_accept) 1001 if (continue_url_match_accept)
990 RedirectToSignin(); 1002 RedirectToSignin();
991 std::string unused_value; 1003 std::string unused_value;
992 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) 1004 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value))
993 RedirectToNTP(false); 1005 RedirectToNTP(false);
994 return; 1006 return;
995 } 1007 }
996 1008
997 // When the user uses the first-run, ntp, or hotdog menu to sign in, then have 1009 // When the user uses the first-run, ntp, or hotdog menu to sign in, then have
998 // the option of checking the the box "Let me choose what to sync". When the 1010 // the option of checking the the box "Let me choose what to sync". When the
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 } 1215 }
1204 } 1216 }
1205 1217
1206 RedirectToNTP(true); 1218 RedirectToNTP(true);
1207 signin_tracker_.reset(); 1219 signin_tracker_.reset();
1208 } 1220 }
1209 1221
1210 void OneClickSigninHelper::SigninSuccess() { 1222 void OneClickSigninHelper::SigninSuccess() {
1211 signin_tracker_.reset(); 1223 signin_tracker_.reset();
1212 } 1224 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698