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

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

Issue 2668883002: Convert NavigationMetricsRecorder to use the new navigation callbacks. (Closed)
Patch Set: merge Created 3 years, 10 months 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 d003129b26a8970349f9fbfb7753acc8be2edc18..8f4d1979e92088854a6a2c2c2058a8b413c11b40 100644
--- a/chrome/browser/tab_contents/navigation_metrics_recorder.cc
+++ b/chrome/browser/tab_contents/navigation_metrics_recorder.cc
@@ -14,8 +14,8 @@
#include "components/rappor/rappor_service_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -70,35 +70,39 @@ void NavigationMetricsRecorder::set_rappor_service_for_testing(
rappor_service_ = service;
}
-void NavigationMetricsRecorder::DidNavigateMainFrame(
- const content::LoadCommittedDetails& details,
- const content::FrameNavigateParams& params) {
+void NavigationMetricsRecorder::DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
+ return;
content::BrowserContext* context = web_contents()->GetBrowserContext();
navigation_metrics::OriginsSeenService* service =
OriginsSeenServiceFactory::GetForBrowserContext(context);
- const url::Origin origin(details.entry->GetVirtualURL());
+ content::NavigationEntry* last_committed_entry =
+ web_contents()->GetController().GetLastCommittedEntry();
+ const url::Origin origin(last_committed_entry->GetVirtualURL());
bool have_already_seen_origin = service->Insert(origin);
navigation_metrics::RecordMainFrameNavigation(
- details.entry->GetVirtualURL(), details.is_in_page,
+ last_committed_entry->GetVirtualURL(), navigation_handle->IsSamePage(),
context->IsOffTheRecord(), have_already_seen_origin);
// Record the domain and registry of the URL that resulted in a navigation to
// a |data:| URL, either by redirects or user clicking a link.
- if (details.entry->GetVirtualURL().SchemeIs(url::kDataScheme) &&
- !ui::PageTransitionCoreTypeIs(params.transition,
+ if (last_committed_entry->GetVirtualURL().SchemeIs(url::kDataScheme) &&
+ !ui::PageTransitionCoreTypeIs(navigation_handle->GetPageTransition(),
ui::PAGE_TRANSITION_TYPED)) {
- if (!details.previous_url.is_empty()) {
+ if (!navigation_handle->GetPreviousURL().is_empty()) {
rappor::SampleDomainAndRegistryFromGURL(
- rappor_service_, "Navigation.Scheme.Data", details.previous_url);
+ rappor_service_, "Navigation.Scheme.Data",
+ navigation_handle->GetPreviousURL());
}
// Also record the mime type of the data: URL.
std::string mime_type;
std::string charset;
- if (net::DataURL::Parse(details.entry->GetVirtualURL(), &mime_type,
+ if (net::DataURL::Parse(last_committed_entry->GetVirtualURL(), &mime_type,
&charset, nullptr)) {
RecordDataURLMimeType(mime_type);
}

Powered by Google App Engine
This is Rietveld 408576698