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..3cd71a1de9bf1083ddb2b3d2ff9ef4f41a359828 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" |
@@ -86,6 +87,11 @@ void RecordInternalError(InternalErrorLoadEvent event) { |
"PageLoad.Events.InternalError", event, ERR_LAST_ENTRY); |
} |
+void RecordGoogleCaptchaEvent(GoogleCaptchaEvent event) { |
+ UMA_HISTOGRAM_ENUMERATION( |
+ kHistogramNameGoogleCaptcha, event, GOOGLE_CAPTCHA_EVENT_BOUNDARY); |
+} |
+ |
base::TimeDelta GetFirstContentfulPaint(const PageLoadTiming& timing) { |
if (timing.first_text_paint.is_zero()) |
return timing.first_image_paint; |
@@ -119,6 +125,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 +453,10 @@ void MetricsWebContentsObserver::DidStartNavigation( |
void MetricsWebContentsObserver::DidFinishNavigation( |
content::NavigationHandle* navigation_handle) { |
+ if (IsGoogleCaptcha(navigation_handle->GetURL())) { |
Alexei Svitkine (slow)
2015/11/13 20:17:12
Nit: No {}s
Matt Welsh
2015/11/13 20:26:01
Done.
|
+ RecordGoogleCaptchaEvent(GOOGLE_CAPTCHA_SHOWN); |
+ } |
+ |
if (!navigation_handle->IsInMainFrame()) |
return; |
@@ -481,6 +499,13 @@ void MetricsWebContentsObserver::DidFinishNavigation( |
committed_load_->Commit(navigation_handle); |
} |
+void MetricsWebContentsObserver::DidRedirectNavigation( |
+ content::NavigationHandle* navigation_handle) { |
+ if (IsGoogleCaptcha(navigation_handle->GetReferrer().url)) { |
Alexei Svitkine (slow)
2015/11/13 20:17:12
Nit: No {}s
Matt Welsh
2015/11/13 20:26:01
Done.
|
+ RecordGoogleCaptchaEvent(GOOGLE_CAPTCHA_SOLVED); |
+ } |
+} |
+ |
void MetricsWebContentsObserver::WasShown() { |
in_foreground_ = true; |
if (committed_load_) |