| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 Profile* profile, | 52 Profile* profile, |
| 53 const GURL& url, | 53 const GURL& url, |
| 54 const Referrer& referrer, | 54 const Referrer& referrer, |
| 55 Origin origin, | 55 Origin origin, |
| 56 bool call_did_finish_load, | 56 bool call_did_finish_load, |
| 57 const content::SessionStorageNamespaceMap& session_storage_namespace_map); | 57 const content::SessionStorageNamespaceMap& session_storage_namespace_map); |
| 58 | 58 |
| 59 virtual void StartPrerendering( | 59 virtual void StartPrerendering( |
| 60 int ALLOW_UNUSED creator_child_id, | 60 int ALLOW_UNUSED creator_child_id, |
| 61 const gfx::Size& ALLOW_UNUSED size, | 61 const gfx::Size& ALLOW_UNUSED size, |
| 62 content::SessionStorageNamespace* session_storage_namespace) OVERRIDE; | 62 content::SessionStorageNamespace* session_storage_namespace, |
| 63 net::URLRequestContextGetter* request_context) OVERRIDE; |
| 63 virtual bool GetChildId(int* child_id) const OVERRIDE; | 64 virtual bool GetChildId(int* child_id) const OVERRIDE; |
| 64 virtual bool GetRouteId(int* route_id) const OVERRIDE; | 65 virtual bool GetRouteId(int* route_id) const OVERRIDE; |
| 65 | 66 |
| 66 private: | 67 private: |
| 67 Profile* profile_; | 68 Profile* profile_; |
| 68 const GURL url_; | 69 const GURL url_; |
| 69 bool call_did_finish_load_; | 70 bool call_did_finish_load_; |
| 70 content::SessionStorageNamespaceMap session_storage_namespace_map_; | 71 content::SessionStorageNamespaceMap session_storage_namespace_map_; |
| 71 | 72 |
| 72 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents); | 73 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 PrerenderManager::kNoExperiment), | 109 PrerenderManager::kNoExperiment), |
| 109 profile_(profile), | 110 profile_(profile), |
| 110 url_(url), | 111 url_(url), |
| 111 call_did_finish_load_(call_did_finish_load), | 112 call_did_finish_load_(call_did_finish_load), |
| 112 session_storage_namespace_map_(session_storage_namespace_map) { | 113 session_storage_namespace_map_(session_storage_namespace_map) { |
| 113 } | 114 } |
| 114 | 115 |
| 115 void DummyPrerenderContents::StartPrerendering( | 116 void DummyPrerenderContents::StartPrerendering( |
| 116 int ALLOW_UNUSED creator_child_id, | 117 int ALLOW_UNUSED creator_child_id, |
| 117 const gfx::Size& ALLOW_UNUSED size, | 118 const gfx::Size& ALLOW_UNUSED size, |
| 118 content::SessionStorageNamespace* session_storage_namespace) { | 119 content::SessionStorageNamespace* session_storage_namespace, |
| 120 net::URLRequestContextGetter* request_context) { |
| 119 prerender_contents_.reset(content::WebContents::CreateWithSessionStorage( | 121 prerender_contents_.reset(content::WebContents::CreateWithSessionStorage( |
| 120 content::WebContents::CreateParams(profile_), | 122 content::WebContents::CreateParams(profile_), |
| 121 session_storage_namespace_map_)); | 123 session_storage_namespace_map_)); |
| 122 PrerenderTabHelper::CreateForWebContentsWithPasswordManager( | 124 PrerenderTabHelper::CreateForWebContentsWithPasswordManager( |
| 123 prerender_contents_.get(), NULL); | 125 prerender_contents_.get(), NULL); |
| 124 content::NavigationController::LoadURLParams params(url_); | 126 content::NavigationController::LoadURLParams params(url_); |
| 125 prerender_contents_->GetController().LoadURLWithParams(params); | 127 prerender_contents_->GetController().LoadURLWithParams(params); |
| 126 SearchTabHelper::CreateForWebContents(prerender_contents_.get()); | 128 SearchTabHelper::CreateForWebContents(prerender_contents_.get()); |
| 127 | 129 |
| 128 prerendering_has_started_ = true; | 130 prerendering_has_started_ = true; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 AddTab(browser(), GURL(content::kAboutBlankURL)); | 176 AddTab(browser(), GURL(content::kAboutBlankURL)); |
| 175 | 177 |
| 176 content::SessionStorageNamespaceMap session_storage_namespace_map; | 178 content::SessionStorageNamespaceMap session_storage_namespace_map; |
| 177 session_storage_namespace_map[std::string()] = | 179 session_storage_namespace_map[std::string()] = |
| 178 GetActiveWebContents()->GetController(). | 180 GetActiveWebContents()->GetController(). |
| 179 GetDefaultSessionStorageNamespace(); | 181 GetDefaultSessionStorageNamespace(); |
| 180 PrerenderManagerFactory::GetForProfile(browser()->profile())-> | 182 PrerenderManagerFactory::GetForProfile(browser()->profile())-> |
| 181 SetPrerenderContentsFactory( | 183 SetPrerenderContentsFactory( |
| 182 new DummyPrerenderContentsFactory(call_did_finish_load, | 184 new DummyPrerenderContentsFactory(call_did_finish_load, |
| 183 session_storage_namespace_map)); | 185 session_storage_namespace_map)); |
| 184 | 186 PrerenderManagerFactory::GetForProfile(browser()->profile())-> |
| 187 OnCookieStoreLoaded(); |
| 185 if (prerender_search_results_base_page) { | 188 if (prerender_search_results_base_page) { |
| 186 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer(); | 189 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer(); |
| 187 prerenderer->Init(session_storage_namespace_map, gfx::Size(640, 480)); | 190 prerenderer->Init(session_storage_namespace_map, gfx::Size(640, 480)); |
| 188 EXPECT_NE(static_cast<PrerenderHandle*>(NULL), prerender_handle()); | 191 EXPECT_NE(static_cast<PrerenderHandle*>(NULL), prerender_handle()); |
| 189 } | 192 } |
| 190 } | 193 } |
| 191 | 194 |
| 192 InstantSearchPrerenderer* GetInstantSearchPrerenderer() { | 195 InstantSearchPrerenderer* GetInstantSearchPrerenderer() { |
| 193 return instant_service_->instant_search_prerenderer(); | 196 return instant_service_->instant_search_prerenderer(); |
| 194 } | 197 } |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL | 474 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL |
| 472 // and uses the prerendered page contents. | 475 // and uses the prerendered page contents. |
| 473 GURL url("https://www.google.com/alt#quux=foo"); | 476 GURL url("https://www.google.com/alt#quux=foo"); |
| 474 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB, | 477 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB, |
| 475 content::PAGE_TRANSITION_TYPED, | 478 content::PAGE_TRANSITION_TYPED, |
| 476 false)); | 479 false)); |
| 477 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL()); | 480 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL()); |
| 478 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle()); | 481 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle()); |
| 479 } | 482 } |
| 480 #endif | 483 #endif |
| OLD | NEW |