 Chromium Code Reviews
 Chromium Code Reviews Issue 1473543002:
  Implement newly designed sign-in related histograms for desktop platorms.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1473543002:
  Implement newly designed sign-in related histograms for desktop platorms.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: chrome/browser/signin/signin_promo.cc | 
| diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc | 
| index 1377d70564f02a2d40db29ba534d689a17b31f3c..d3e708284f7616da7416d0318e04a76a8b1d1d5f 100644 | 
| --- a/chrome/browser/signin/signin_promo.cc | 
| +++ b/chrome/browser/signin/signin_promo.cc | 
| @@ -165,25 +165,47 @@ void SetUserSkippedPromo(Profile* profile) { | 
| profile->GetPrefs()->SetBoolean(prefs::kSignInPromoUserSkipped, true); | 
| } | 
| -GURL GetLandingURL(const char* option, int value) { | 
| - std::string url = base::StringPrintf("%s/success.html?%s=%d", | 
| - extensions::kGaiaAuthExtensionOrigin, | 
| - option, | 
| - value); | 
| +GURL GetLandingURL(signin_metrics::AccessPoint access_point) { | 
| + std::string url = base::StringPrintf( | 
| + "%s/success.html?%s=%d", extensions::kGaiaAuthExtensionOrigin, | 
| + kSignInPromoQueryKeyAccessPoint, access_point); | 
| + | 
| + // TODO(gogerald): right now, gaia server needs to distinguish the source from | 
| + // signin_metrics::SOURCE_START_PAGE, signin_metrics::SOURCE_SETTINGS and | 
| + // the others to show advanced sync settings, remove them after | 
| + // switching to Minute Maid sign in flow. | 
| + if (access_point == signin_metrics::ACCESS_POINT_START_PAGE) { | 
| + base::StringAppendF(&url, "&%s=%d", kSignInPromoQueryKeySource, | 
| + signin_metrics::SOURCE_START_PAGE); | 
| + } else if (access_point == signin_metrics::ACCESS_POINT_SETTINGS) { | 
| + base::StringAppendF(&url, "&%s=%d", kSignInPromoQueryKeySource, | 
| + signin_metrics::SOURCE_SETTINGS); | 
| + } else { | 
| + base::StringAppendF(&url, "&%s=%d", kSignInPromoQueryKeySource, | 
| + signin_metrics::SOURCE_OTHERS); | 
| + } | 
| + | 
| return GURL(url); | 
| } | 
| -GURL GetPromoURL(signin_metrics::Source source, bool auto_close) { | 
| - return GetPromoURL(source, auto_close, false /* is_constrained */); | 
| +GURL GetPromoURL(signin_metrics::AccessPoint access_point, | 
| + signin_metrics::Reason reason, | 
| + bool auto_close) { | 
| + return GetPromoURL(access_point, reason, auto_close, | 
| + false /* is_constrained */); | 
| } | 
| -GURL GetPromoURL(signin_metrics::Source source, | 
| +GURL GetPromoURL(signin_metrics::AccessPoint access_point, | 
| + signin_metrics::Reason reason, | 
| bool auto_close, | 
| bool is_constrained) { | 
| - DCHECK_NE(signin_metrics::SOURCE_UNKNOWN, source); | 
| + CHECK(access_point < signin_metrics::ACCESS_POINT_MAX); | 
| 
Bernhard Bauer
2015/12/04 11:06:24
CHECK_LT for slightly nicer error messages.
 
gogerald1
2015/12/04 20:49:09
Done.
 | 
| + CHECK(reason < signin_metrics::REASON_MAX); | 
| std::string url(chrome::kChromeUIChromeSigninURL); | 
| - base::StringAppendF(&url, "?%s=%d", kSignInPromoQueryKeySource, source); | 
| + base::StringAppendF(&url, "?%s=%d", kSignInPromoQueryKeyAccessPoint, | 
| + access_point); | 
| + base::StringAppendF(&url, "&%s=%d", kSignInPromoQueryKeyReason, reason); | 
| if (auto_close) | 
| base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyAutoClose); | 
| if (is_constrained) | 
| @@ -191,16 +213,20 @@ GURL GetPromoURL(signin_metrics::Source source, | 
| return GURL(url); | 
| } | 
| -GURL GetReauthURL(Profile* profile, const std::string& account_id) { | 
| +GURL GetReauthURL(signin_metrics::AccessPoint access_point, | 
| + signin_metrics::Reason reason, | 
| + Profile* profile, | 
| + const std::string& account_id) { | 
| AccountInfo info = AccountTrackerServiceFactory::GetForProfile(profile) | 
| ->GetAccountInfo(account_id); | 
| - return GetReauthURLWithEmail(info.email); | 
| + return GetReauthURLWithEmail(access_point, reason, info.email); | 
| } | 
| -GURL GetReauthURLWithEmail(const std::string& email) { | 
| - GURL url = signin::GetPromoURL( | 
| - signin_metrics::SOURCE_REAUTH, true /* auto_close */, | 
| - true /* is_constrained */); | 
| +GURL GetReauthURLWithEmail(signin_metrics::AccessPoint access_point, | 
| + signin_metrics::Reason reason, | 
| + const std::string& email) { | 
| + GURL url = signin::GetPromoURL(access_point, reason, true /* auto_close */, | 
| + true /* is_constrained */); | 
| url = net::AppendQueryParameter(url, "email", email); | 
| url = net::AppendQueryParameter(url, "validateEmail", "1"); | 
| @@ -223,24 +249,26 @@ GURL GetSigninPartitionURL() { | 
| } | 
| GURL GetSigninURLFromBubbleViewMode(Profile* profile, | 
| - profiles::BubbleViewMode mode) { | 
| + profiles::BubbleViewMode mode, | 
| + signin_metrics::AccessPoint access_point) { | 
| switch (mode) { | 
| case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 
| - return GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_SIGN_IN, | 
| - false /* auto_close */, | 
| - true /* is_constrained */); | 
| + return GetPromoURL(access_point, | 
| + signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, | 
| + false /* auto_close */, true /* is_constrained */); | 
| break; | 
| case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 
| - return GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, | 
| - false /* auto_close */, | 
| - true /* is_constrained */); | 
| + return GetPromoURL(access_point, | 
| + signin_metrics::REASON_ADD_SECONDARY_ACCOUNT, | 
| + false /* auto_close */, true /* is_constrained */); | 
| break; | 
| case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { | 
| const SigninErrorController* error_controller = | 
| SigninErrorControllerFactory::GetForProfile(profile); | 
| CHECK(error_controller); | 
| DCHECK(error_controller->HasError()); | 
| - return GetReauthURL(profile, error_controller->error_account_id()); | 
| + return GetReauthURL(access_point, signin_metrics::REASON_REAUTHENTICATION, | 
| + profile, error_controller->error_account_id()); | 
| break; | 
| } | 
| default: | 
| @@ -249,17 +277,33 @@ GURL GetSigninURLFromBubbleViewMode(Profile* profile, | 
| } | 
| } | 
| -signin_metrics::Source GetSourceForPromoURL(const GURL& url) { | 
| +signin_metrics::AccessPoint GetAccessPointForPromoURL(const GURL& url) { | 
| + std::string value; | 
| + if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeyAccessPoint, | 
| + &value)) { | 
| + int access_point = 0; | 
| + if (base::StringToInt(value, &access_point) && | 
| + access_point >= signin_metrics::ACCESS_POINT_START_PAGE && | 
| + access_point < signin_metrics::ACCESS_POINT_MAX) { | 
| + return static_cast<signin_metrics::AccessPoint>(access_point); | 
| + } | 
| + CHECK(false); | 
| + } | 
| + return signin_metrics::ACCESS_POINT_MAX; | 
| +} | 
| + | 
| +signin_metrics::Reason GetSigninReasonForPromoURL(const GURL& url) { | 
| std::string value; | 
| - if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeySource, &value)) { | 
| - int source = 0; | 
| - if (base::StringToInt(value, &source) && | 
| - source >= signin_metrics::SOURCE_START_PAGE && | 
| - source < signin_metrics::SOURCE_UNKNOWN) { | 
| - return static_cast<signin_metrics::Source>(source); | 
| + if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeyReason, &value)) { | 
| + int reason = 0; | 
| + if (base::StringToInt(value, &reason) && | 
| + reason >= signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT && | 
| + reason < signin_metrics::REASON_MAX) { | 
| + return static_cast<signin_metrics::Reason>(reason); | 
| } | 
| + CHECK(false); | 
| 
Bernhard Bauer
2015/12/04 11:06:24
Move the condition into the CHECK? Also, seeing as
 
gogerald1
2015/12/04 20:49:09
Done.
 | 
| } | 
| - return signin_metrics::SOURCE_UNKNOWN; | 
| + return signin_metrics::REASON_MAX; | 
| } | 
| bool IsAutoCloseEnabledInURL(const GURL& url) { |