| // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "chrome/browser/tab_contents/navigation_metrics_recorder.h" |
| |
| #include "build/build_config.h" |
| #include "components/navigation_metrics/navigation_metrics.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.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" |
| #include "url/gurl.h" |
| #include "url/origin.h" |
| |
| #if defined(OS_WIN) |
| #include "base/win/windows_version.h" |
| #endif |
| |
| NavigationMetricsRecorder::NavigationMetricsRecorder( |
| content::WebContents* web_contents) |
| : content::WebContentsObserver(web_contents) {} |
| |
| NavigationMetricsRecorder::~NavigationMetricsRecorder() { |
| } |
| |
| void NavigationMetricsRecorder::DidFinishNavigation( |
| content::NavigationHandle* navigation_handle) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| if (!navigation_handle->HasCommitted() || !navigation_handle->IsInMainFrame()) |
| return; |
| |
| content::BrowserContext* context = web_contents()->GetBrowserContext(); |
| content::NavigationEntry* last_committed_entry = |
| web_contents()->GetController().GetLastCommittedEntry(); |
| |
| navigation_metrics::RecordMainFrameNavigation( |
| last_committed_entry->GetVirtualURL(), |
| navigation_handle->IsSameDocument(), context->IsOffTheRecord()); |
| } |