Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4208)

Unified Diff: chrome/browser/tab_contents/navigation_metrics_recorder.cc

Issue 2400953003: Add browser test for NavigationMetricsRecorder (Closed)
Patch Set: Rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/tab_contents/navigation_metrics_recorder.cc
diff --git a/chrome/browser/tab_contents/navigation_metrics_recorder.cc b/chrome/browser/tab_contents/navigation_metrics_recorder.cc
index 3ab10a49f23e2c525e624959e7895997bbb8696e..b1a568708d77619067e740aa96bdeeb154270ff5 100644
--- a/chrome/browser/tab_contents/navigation_metrics_recorder.cc
+++ b/chrome/browser/tab_contents/navigation_metrics_recorder.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/tab_contents/origins_seen_service_factory.h"
#include "components/navigation_metrics/navigation_metrics.h"
#include "components/navigation_metrics/origins_seen_service.h"
+#include "components/rappor/rappor_service.h"
#include "components/rappor/rappor_utils.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
@@ -30,12 +31,17 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(NavigationMetricsRecorder);
NavigationMetricsRecorder::NavigationMetricsRecorder(
content::WebContents* web_contents)
- : content::WebContentsObserver(web_contents) {
-}
+ : content::WebContentsObserver(web_contents),
+ rappor_service_(g_browser_process->rappor_service()) {}
NavigationMetricsRecorder::~NavigationMetricsRecorder() {
}
+void NavigationMetricsRecorder::set_rappor_service_for_testing(
+ rappor::RapporService* service) {
+ rappor_service_ = service;
+}
+
void NavigationMetricsRecorder::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
@@ -57,8 +63,7 @@ void NavigationMetricsRecorder::DidNavigateMainFrame(
!ui::PageTransitionCoreTypeIs(params.transition,
ui::PAGE_TRANSITION_TYPED) &&
!details.previous_url.is_empty()) {
- rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(),
- "Navigation.Scheme.Data",
- details.previous_url);
+ rappor::SampleDomainAndRegistryFromGURL(
+ rappor_service_, "Navigation.Scheme.Data", details.previous_url);
}
}

Powered by Google App Engine
This is Rietveld 408576698