| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 if (!prerender_contents()) | 97 if (!prerender_contents()) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 last_instant_suggestion_ = suggestion; | 100 last_instant_suggestion_ = suggestion; |
| 101 SearchTabHelper::FromWebContents(prerender_contents())-> | 101 SearchTabHelper::FromWebContents(prerender_contents())-> |
| 102 SetSuggestionToPrefetch(suggestion); | 102 SetSuggestionToPrefetch(suggestion); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void InstantSearchPrerenderer::Commit( | 105 void InstantSearchPrerenderer::Commit( |
| 106 const base::string16& query, | |
| 107 const EmbeddedSearchRequestParams& params) { | 106 const EmbeddedSearchRequestParams& params) { |
| 108 DCHECK(prerender_handle_); | 107 DCHECK(prerender_handle_); |
| 109 DCHECK(prerender_contents()); | 108 DCHECK(prerender_contents()); |
| 110 SearchTabHelper::FromWebContents(prerender_contents())->Submit(query, params); | 109 SearchTabHelper::FromWebContents(prerender_contents())->Submit(params); |
| 111 } | 110 } |
| 112 | 111 |
| 113 bool InstantSearchPrerenderer::CanCommitQuery( | 112 bool InstantSearchPrerenderer::CanCommitQuery( |
| 114 content::WebContents* source, | 113 content::WebContents* source, |
| 115 const base::string16& query) const { | 114 const base::string16& query) const { |
| 116 if (!source || query.empty() || !prerender_handle_ || | 115 if (!source || query.empty() || !prerender_handle_ || |
| 117 !prerender_handle_->IsFinishedLoading() || !prerender_contents()) { | 116 !prerender_handle_->IsFinishedLoading() || !prerender_contents()) { |
| 118 return false; | 117 return false; |
| 119 } | 118 } |
| 120 | 119 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // This handles the by-far-the-most-common cases while still being simple and | 172 // This handles the by-far-the-most-common cases while still being simple and |
| 174 // maintainable. | 173 // maintainable. |
| 175 return source && AutocompleteMatch::IsSearchType(match.type) && | 174 return source && AutocompleteMatch::IsSearchType(match.type) && |
| 176 MatchIsFromDefaultSearchProvider(match, profile_); | 175 MatchIsFromDefaultSearchProvider(match, profile_); |
| 177 } | 176 } |
| 178 | 177 |
| 179 content::WebContents* InstantSearchPrerenderer::prerender_contents() const { | 178 content::WebContents* InstantSearchPrerenderer::prerender_contents() const { |
| 180 return (prerender_handle_ && prerender_handle_->contents()) ? | 179 return (prerender_handle_ && prerender_handle_->contents()) ? |
| 181 prerender_handle_->contents()->prerender_contents() : NULL; | 180 prerender_handle_->contents()->prerender_contents() : NULL; |
| 182 } | 181 } |
| OLD | NEW |