OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/net/predictor_tab_helper.h" | |
6 | |
7 #include "chrome/browser/net/predictor.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "content/public/common/frame_navigate_params.h" | |
10 | |
11 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper); | |
12 | |
13 namespace { | |
14 | |
15 bool IsUserLinkNavigationRequest(content::PageTransition page_transition) { | |
16 bool isLink = (content::PageTransitionStripQualifier(page_transition) == | |
17 content::PAGE_TRANSITION_LINK); | |
18 bool isForwardBack = (page_transition & | |
19 content::PAGE_TRANSITION_FORWARD_BACK); | |
20 bool isPrerender = (page_transition & | |
21 content::PAGE_TRANSITION_PRERENDER); | |
22 // tracking navigation session including client-side redirect | |
23 // 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.
| |
24 bool isClientRedirect = (page_transition & | |
25 content::PAGE_TRANSITION_CLIENT_REDIRECT); | |
26 return isLink && !isForwardBack && !isPrerender && !isClientRedirect; | |
27 } | |
28 | |
29 } // namespace | |
30 | |
31 namespace chrome_browser_net { | |
32 | |
33 PredictorTabHelper::PredictorTabHelper( | |
34 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.
| |
35 : content::WebContentsObserver(web_contents) { | |
36 } | |
37 | |
38 PredictorTabHelper::~PredictorTabHelper() { | |
39 } | |
40 | |
41 void PredictorTabHelper::DidNavigateMainFrame( | |
42 const content::LoadCommittedDetails& details, | |
43 const content::FrameNavigateParams& params) { | |
44 if (!IsUserLinkNavigationRequest(params.transition) || | |
45 !(params.url.SchemeIs("http") || params.url.SchemeIs("https"))) | |
46 return; | |
47 | |
48 Profile* profile = Profile::FromBrowserContext( | |
49 web_contents()->GetBrowserContext()); | |
50 profile->GetNetworkPredictor()->RecordLinkNavigation(params.url); | |
51 } | |
52 | |
53 } // namespace chrome_browser_net | |
OLD | NEW |