Chromium Code Reviews| Index: chrome/browser/ui/sync/one_click_signin_helper.cc |
| diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc |
| index 7a898bad89ee47a1e4956eb38230e2c40297c99f..c4823abc804f33c4252ac37adf190664adc9a16f 100644 |
| --- a/chrome/browser/ui/sync/one_click_signin_helper.cc |
| +++ b/chrome/browser/ui/sync/one_click_signin_helper.cc |
| @@ -327,6 +327,63 @@ ConfirmEmailDialogDelegate::ConfirmEmailDialogDelegate( |
| callback_(callback) { |
| } |
| +// Tells when we are in the process of showing either the signin to chrome page |
| +// or the one click sign in to chrome page. |
| +bool AreWeShowingSignin(GURL url, SyncPromoUI::Source source, |
| + std::string email) { |
| + GURL::Replacements replacements; |
| + replacements.ClearQuery(); |
| + GURL clean_login_url = |
| + GURL(GaiaUrls::GetInstance()->service_login_url()).ReplaceComponents( |
| + replacements); |
| + |
| + return (url.ReplaceComponents(replacements) == clean_login_url && |
| + source != SyncPromoUI::SOURCE_UNKNOWN) || !email.empty(); |
| +} |
| + |
| +void LogHistogramValue(SyncPromoUI::Source source, int action) { |
| + std::string histogram_prefix; |
|
Roger Tawa OOO till Jul 10th
2013/02/28 16:32:26
var not needed.
jwd
2013/02/28 19:16:05
Done.
|
| + switch (source) { |
| + case SyncPromoUI::SOURCE_START_PAGE: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.StartPageActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_NTP_LINK: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.NTPLinkActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_MENU: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.MenuActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_SETTINGS: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_EXTENSION_INSTALL_BUBBLE: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_WEBSTORE_INSTALL: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.WebstoreInstallActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_APP_LAUNCHER: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + case SyncPromoUI::SOURCE_UNKNOWN: |
| + UMA_HISTOGRAM_ENUMERATION("Signin.OneClickActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| + break; |
| + default: |
| + NOTREACHED() << "Invalid Source"; |
| + return; |
| + } |
| + UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
| + one_click_signin::HISTOGRAM_MAX); |
| +} |
| + |
| } // namespace |
| // The infobar asking the user if they want to use one-click sign in. |
| @@ -502,6 +559,7 @@ void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { |
| OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
| : content::WebContentsObserver(web_contents), |
| + showing_signin_(false), |
| auto_accept_(AUTO_ACCEPT_NONE), |
| source_(SyncPromoUI::SOURCE_UNKNOWN) { |
| } |
| @@ -840,15 +898,6 @@ void OneClickSigninHelper::ShowInfoBarUIThread( |
| if (!helper) |
| return; |
| - // Save the email in the one-click signin manager. The manager may |
| - // not exist if the contents is incognito or if the profile is already |
| - // connected to a Google account. |
| - if (!session_index.empty()) |
| - helper->session_index_ = session_index; |
| - |
| - if (!email.empty()) |
| - helper->email_ = email; |
| - |
| if (auto_accept != AUTO_ACCEPT_NONE) { |
| helper->auto_accept_ = auto_accept; |
| helper->source_ = source; |
| @@ -869,6 +918,15 @@ void OneClickSigninHelper::ShowInfoBarUIThread( |
| return; |
| } |
| + // Save the email in the one-click signin manager. The manager may |
| + // not exist if the contents is incognito or if the profile is already |
| + // connected to a Google account. |
| + if (!session_index.empty()) |
| + helper->session_index_ = session_index; |
| + |
| + if (!email.empty()) |
| + helper->email_ = email; |
| + |
| if (continue_url.is_valid()) |
| helper->continue_url_ = continue_url; |
| } |
| @@ -916,6 +974,7 @@ void OneClickSigninHelper::RedirectToSignin() { |
| void OneClickSigninHelper::CleanTransientState() { |
| VLOG(1) << "OneClickSigninHelper::CleanTransientState"; |
| + showing_signin_ = false; |
| email_.clear(); |
| password_.clear(); |
| auto_accept_ = AUTO_ACCEPT_NONE; |
| @@ -973,6 +1032,12 @@ void OneClickSigninHelper::DidStopLoading( |
| return; |
| } |
| + if (AreWeShowingSignin(url, source_, email_)) { |
| + if (!showing_signin_) |
| + LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); |
| + showing_signin_ = true; |
| + } |
| + |
| // When Gaia finally redirects to the continue URL, Gaia will add some |
| // extra query parameters. So ignore the parameters when checking to see |
| // if the user has continued. |
| @@ -986,6 +1051,7 @@ void OneClickSigninHelper::DidStopLoading( |
| // If there is no valid email or password yet, there is nothing to do. |
| if (email_.empty() || password_.empty()) { |
| + VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do"; |
| if (continue_url_match_accept) |
| RedirectToSignin(); |
| std::string unused_value; |