1 // Copyright 2013 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.
5 #include "chrome/browser/net/predictor_tab_helper.h"
7 #include "base/command_line.h"
8 #include "chrome/browser/net/predictor.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/url_constants.h"
13 DEFINE_WEB_CONTENTS_USER_DATA_KEY(chrome_browser_net::PredictorTabHelper
);
15 namespace chrome_browser_net
{
17 PredictorTabHelper::PredictorTabHelper(content::WebContents
* web_contents
)
18 : content::WebContentsObserver(web_contents
) {
21 PredictorTabHelper::~PredictorTabHelper() {
24 void PredictorTabHelper::DidStartNavigationToPendingEntry(
26 content::NavigationController::ReloadType reload_type
) {
28 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
29 chrome_browser_net::Predictor
* predictor
= profile
->GetNetworkPredictor();
32 if (url
.SchemeIs(url::kHttpScheme
) || url
.SchemeIs(url::kHttpsScheme
))
33 predictor
->PreconnectUrlAndSubresources(url
, GURL());
36 } // namespace chrome_browser_net