Index: chrome/browser/net/predictor_tab_helper.cc |
diff --git a/chrome/browser/net/predictor_tab_helper.cc b/chrome/browser/net/predictor_tab_helper.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2db28ca61f60032a905792bb2e99dfa648d8a263 |
--- /dev/null |
+++ b/chrome/browser/net/predictor_tab_helper.cc |
@@ -0,0 +1,53 @@ |
+// 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/net/predictor_tab_helper.h" |
+ |
+#include "chrome/browser/net/predictor.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "content/public/common/frame_navigate_params.h" |
+ |
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper); |
+ |
+namespace { |
+ |
+bool IsUserLinkNavigationRequest(content::PageTransition page_transition) { |
+ bool isLink = (content::PageTransitionStripQualifier(page_transition) == |
+ content::PAGE_TRANSITION_LINK); |
+ bool isForwardBack = (page_transition & |
+ content::PAGE_TRANSITION_FORWARD_BACK); |
+ bool isPrerender = (page_transition & |
+ content::PAGE_TRANSITION_PRERENDER); |
+ // tracking navigation session including client-side redirect |
+ // is currently not supported |
jar (doing other things)
2013/08/01 22:56:47
nit: Start with upper case letter... and with peri
kouhei (in TOK)
2013/08/02 06:18:03
Done.
|
+ bool isClientRedirect = (page_transition & |
+ content::PAGE_TRANSITION_CLIENT_REDIRECT); |
+ return isLink && !isForwardBack && !isPrerender && !isClientRedirect; |
+} |
+ |
+} // namespace |
+ |
+namespace chrome_browser_net { |
+ |
+PredictorTabHelper::PredictorTabHelper( |
+ content::WebContents* web_contents) |
jar (doing other things)
2013/08/01 22:56:47
nit: no need to wrap
kouhei (in TOK)
2013/08/02 06:18:03
Done.
|
+ : content::WebContentsObserver(web_contents) { |
+} |
+ |
+PredictorTabHelper::~PredictorTabHelper() { |
+} |
+ |
+void PredictorTabHelper::DidNavigateMainFrame( |
+ const content::LoadCommittedDetails& details, |
+ const content::FrameNavigateParams& params) { |
+ if (!IsUserLinkNavigationRequest(params.transition) || |
+ !(params.url.SchemeIs("http") || params.url.SchemeIs("https"))) |
+ return; |
+ |
+ Profile* profile = Profile::FromBrowserContext( |
+ web_contents()->GetBrowserContext()); |
+ profile->GetNetworkPredictor()->RecordLinkNavigation(params.url); |
+} |
+ |
+} // namespace chrome_browser_net |