Chromium Code Reviews| Index: components/page_load_metrics/browser/metrics_web_contents_observer.cc |
| diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.cc b/components/page_load_metrics/browser/metrics_web_contents_observer.cc |
| index c8bd56ac526e7eb390799443b470c1957289b9f3..f8040d4043ae2dfdeb3ed9a649423c08c509574b 100644 |
| --- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc |
| +++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/location.h" |
| #include "base/logging.h" |
| #include "base/metrics/histogram.h" |
| +#include "base/metrics/user_metrics.h" |
| #include "components/page_load_metrics/browser/page_load_metrics_macros.h" |
| #include "components/page_load_metrics/common/page_load_metrics_messages.h" |
| #include "components/page_load_metrics/common/page_load_timing.h" |
| @@ -27,6 +28,9 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY( |
| namespace page_load_metrics { |
| +const char kUMAGoogleCaptchaHistogram[] = |
| + "GoogleCaptcha.Event"; |
| + |
| namespace { |
| // The url we see from the renderer side is not always the same as what |
| @@ -119,6 +123,14 @@ uint64_t RapporHistogramBucketIndex(const base::TimeDelta& time) { |
| } // namespace |
| +bool IsGoogleCaptcha(const GURL& url) { |
| + return (base::StartsWith(url.host(), "ipv4.google.", |
| + base::CompareCase::SENSITIVE) |
| + || base::StartsWith(url.host(), "ipv6.google.", |
| + base::CompareCase::SENSITIVE)) |
| + && base::StartsWith(url.path(), "/sorry", base::CompareCase::SENSITIVE); |
| +} |
| + |
| PageLoadTracker::PageLoadTracker( |
| bool in_foreground, |
| rappor::RapporService* const rappor_service, |
| @@ -439,6 +451,11 @@ void MetricsWebContentsObserver::DidStartNavigation( |
| void MetricsWebContentsObserver::DidFinishNavigation( |
| content::NavigationHandle* navigation_handle) { |
| + if (IsGoogleCaptcha(navigation_handle->GetURL())) { |
| + UMA_HISTOGRAM_ENUMERATION(kUMAGoogleCaptchaHistogram, GOOGLE_CAPTCHA_SHOWN, |
|
Alexei Svitkine (slow)
2015/11/13 19:41:57
Nit: Can you make a helper function to log this hi
Matt Welsh
2015/11/13 20:15:19
Done.
|
| + GOOGLE_CAPTCHA_EVENT_BOUNDARY); |
| + } |
| + |
| if (!navigation_handle->IsInMainFrame()) |
| return; |
| @@ -481,6 +498,14 @@ void MetricsWebContentsObserver::DidFinishNavigation( |
| committed_load_->Commit(navigation_handle); |
| } |
| +void MetricsWebContentsObserver::DidRedirectNavigation( |
| + content::NavigationHandle* navigation_handle) { |
| + if (IsGoogleCaptcha(navigation_handle->GetReferrer().url)) { |
| + UMA_HISTOGRAM_ENUMERATION(kUMAGoogleCaptchaHistogram, GOOGLE_CAPTCHA_SOLVED, |
| + GOOGLE_CAPTCHA_EVENT_BOUNDARY); |
| + } |
| +} |
| + |
| void MetricsWebContentsObserver::WasShown() { |
| in_foreground_ = true; |
| if (committed_load_) |