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/omnibox/omnibox_current_page_delegate_impl.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_current_page_delegate_impl.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete_match.h" | 8 #include "chrome/browser/autocomplete/autocomplete_match.h" |
9 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 9 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
10 #include "chrome/browser/predictors/autocomplete_action_predictor.h" | 10 #include "chrome/browser/predictors/autocomplete_action_predictor.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 void OmniboxCurrentPageDelegateImpl::OnInputStateChanged() { | 84 void OmniboxCurrentPageDelegateImpl::OnInputStateChanged() { |
85 if (!controller_->GetWebContents()) | 85 if (!controller_->GetWebContents()) |
86 return; | 86 return; |
87 SearchTabHelper::FromWebContents( | 87 SearchTabHelper::FromWebContents( |
88 controller_->GetWebContents())->OmniboxInputStateChanged(); | 88 controller_->GetWebContents())->OmniboxInputStateChanged(); |
89 } | 89 } |
90 | 90 |
91 void OmniboxCurrentPageDelegateImpl::OnFocusChanged( | 91 void OmniboxCurrentPageDelegateImpl::OnFocusChanged( |
92 OmniboxFocusState state, | 92 OmniboxFocusState state, |
93 OmniboxFocusChangeReason reason) { | 93 OmniboxFocusChangeReason reason) { |
94 if (!controller_->GetWebContents()) | 94 content::WebContents* web_contents = controller_->GetWebContents(); |
95 if (!web_contents) | |
95 return; | 96 return; |
96 SearchTabHelper::FromWebContents( | 97 |
97 controller_->GetWebContents())->OmniboxFocusChanged(state, reason); | 98 SearchTabHelper* tab_helper = SearchTabHelper::FromWebContents(web_contents); |
99 tab_helper->OmniboxFocusChanged(state, reason); | |
100 | |
101 if (chrome::ShouldPrerenderInstantUrlOnOmniboxFocus() && | |
102 state == OMNIBOX_FOCUS_VISIBLE) { | |
103 gfx::Rect container_bounds = web_contents->GetContainerBounds(); | |
104 InstantSearchPrerenderer* prerenderer = | |
105 InstantSearchPrerenderer::GetForProfile(profile_); | |
106 if (prerenderer && !tab_helper->IsSearchResultsPage()) { | |
107 prerenderer->Init( | |
108 web_contents->GetController().GetSessionStorageNamespaceMap(), | |
109 container_bounds.size()); | |
kmadhusu
2014/06/17 18:29:35
Let's start with a simple approach.
- When the om
sidharthms
2014/06/17 21:52:24
Done.
| |
110 } | |
111 } | |
98 } | 112 } |
99 | 113 |
100 void OmniboxCurrentPageDelegateImpl::DoPrerender( | 114 void OmniboxCurrentPageDelegateImpl::DoPrerender( |
101 const AutocompleteMatch& match) { | 115 const AutocompleteMatch& match) { |
102 content::WebContents* web_contents = controller_->GetWebContents(); | 116 content::WebContents* web_contents = controller_->GetWebContents(); |
103 gfx::Rect container_bounds = web_contents->GetContainerBounds(); | 117 gfx::Rect container_bounds = web_contents->GetContainerBounds(); |
104 | 118 |
105 InstantSearchPrerenderer* prerenderer = | 119 InstantSearchPrerenderer* prerenderer = |
106 InstantSearchPrerenderer::GetForProfile(profile_); | 120 InstantSearchPrerenderer::GetForProfile(profile_); |
107 if (prerenderer && prerenderer->IsAllowed(match, web_contents)) { | 121 if (prerenderer && prerenderer->IsAllowed(match, web_contents)) { |
(...skipping 20 matching lines...) Expand all Loading... | |
128 SearchTabHelper::FromWebContents(web_contents)-> | 142 SearchTabHelper::FromWebContents(web_contents)-> |
129 SetSuggestionToPrefetch(suggestion); | 143 SetSuggestionToPrefetch(suggestion); |
130 } | 144 } |
131 } else if (chrome::ShouldPrefetchSearchResults()) { | 145 } else if (chrome::ShouldPrefetchSearchResults()) { |
132 InstantSearchPrerenderer* prerenderer = | 146 InstantSearchPrerenderer* prerenderer = |
133 InstantSearchPrerenderer::GetForProfile(profile_); | 147 InstantSearchPrerenderer::GetForProfile(profile_); |
134 if (prerenderer) | 148 if (prerenderer) |
135 prerenderer->Prerender(suggestion); | 149 prerenderer->Prerender(suggestion); |
136 } | 150 } |
137 } | 151 } |
OLD | NEW |