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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/browser/prerender/prerender_handle.h" | 9 #include "chrome/browser/prerender/prerender_handle.h" |
10 #include "chrome/browser/prerender/prerender_manager.h" | 10 #include "chrome/browser/prerender/prerender_manager.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 bool InstantSearchPrerenderer::UsePrerenderedPage( | 126 bool InstantSearchPrerenderer::UsePrerenderedPage( |
127 const GURL& url, | 127 const GURL& url, |
128 chrome::NavigateParams* params) { | 128 chrome::NavigateParams* params) { |
129 base::string16 search_terms = | 129 base::string16 search_terms = |
130 search::ExtractSearchTermsFromURL(profile_, url); | 130 search::ExtractSearchTermsFromURL(profile_, url); |
131 prerender::PrerenderManager* prerender_manager = | 131 prerender::PrerenderManager* prerender_manager = |
132 prerender::PrerenderManagerFactory::GetForProfile(profile_); | 132 prerender::PrerenderManagerFactory::GetForProfile(profile_); |
133 if (search_terms.empty() || !params->target_contents || | 133 if (search_terms.empty() || !params->target_contents || |
134 !prerender_contents() || !prerender_manager || | 134 !prerender_contents() || !prerender_manager || |
135 !QueryMatchesPrefetch(search_terms) || | 135 !QueryMatchesPrefetch(search_terms) || |
136 params->disposition != CURRENT_TAB) { | 136 params->disposition != WindowOpenDisposition::CURRENT_TAB) { |
137 Cancel(); | 137 Cancel(); |
138 return false; | 138 return false; |
139 } | 139 } |
140 | 140 |
141 // Do not use prerendered page for renderer initiated search requests. | 141 // Do not use prerendered page for renderer initiated search requests. |
142 if (params->is_renderer_initiated && | 142 if (params->is_renderer_initiated && |
143 ui::PageTransitionCoreTypeIs(params->transition, | 143 ui::PageTransitionCoreTypeIs(params->transition, |
144 ui::PAGE_TRANSITION_LINK)) { | 144 ui::PAGE_TRANSITION_LINK)) { |
145 Cancel(); | 145 Cancel(); |
146 return false; | 146 return false; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 content::WebContents* InstantSearchPrerenderer::prerender_contents() const { | 182 content::WebContents* InstantSearchPrerenderer::prerender_contents() const { |
183 return (prerender_handle_ && prerender_handle_->contents()) ? | 183 return (prerender_handle_ && prerender_handle_->contents()) ? |
184 prerender_handle_->contents()->prerender_contents() : NULL; | 184 prerender_handle_->contents()->prerender_contents() : NULL; |
185 } | 185 } |
186 | 186 |
187 bool InstantSearchPrerenderer::QueryMatchesPrefetch( | 187 bool InstantSearchPrerenderer::QueryMatchesPrefetch( |
188 const base::string16& query) const { | 188 const base::string16& query) const { |
189 return search::ShouldReuseInstantSearchBasePage() || | 189 return search::ShouldReuseInstantSearchBasePage() || |
190 last_instant_suggestion_.text == query; | 190 last_instant_suggestion_.text == query; |
191 } | 191 } |
OLD | NEW |