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..34a91246783576b442663487a16ff69b5ea757a3 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,8 @@ |
#include "base/location.h" |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
+#include "base/metrics/user_metrics.h" |
+#include "base/metrics/user_metrics_action.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" |
@@ -119,6 +121,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 +449,10 @@ void MetricsWebContentsObserver::DidStartNavigation( |
void MetricsWebContentsObserver::DidFinishNavigation( |
content::NavigationHandle* navigation_handle) { |
+ if (IsGoogleCaptcha(navigation_handle->GetURL())) { |
+ RecordAction(base::UserMetricsAction("GoogleCaptchaShown")); |
+ } |
+ |
if (!navigation_handle->IsInMainFrame()) |
return; |
@@ -481,6 +495,13 @@ void MetricsWebContentsObserver::DidFinishNavigation( |
committed_load_->Commit(navigation_handle); |
} |
+void MetricsWebContentsObserver::DidRedirectNavigation( |
+ content::NavigationHandle* navigation_handle) { |
+ if (IsGoogleCaptcha(navigation_handle->GetReferrer().url)) { |
+ RecordAction(base::UserMetricsAction("GoogleCaptchaSolved")); |
+ } |
+} |
+ |
void MetricsWebContentsObserver::WasShown() { |
in_foreground_ = true; |
if (committed_load_) |