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()); | |
110 return; | |
Jered
2014/06/16 22:43:13
Omit this statement since it will happen anyway.
sidharthms
2014/06/17 03:58:46
Done.
| |
111 } | |
112 } | |
98 } | 113 } |
99 | 114 |
100 void OmniboxCurrentPageDelegateImpl::DoPrerender( | 115 void OmniboxCurrentPageDelegateImpl::DoPrerender( |
101 const AutocompleteMatch& match) { | 116 const AutocompleteMatch& match) { |
102 content::WebContents* web_contents = controller_->GetWebContents(); | 117 content::WebContents* web_contents = controller_->GetWebContents(); |
103 gfx::Rect container_bounds = web_contents->GetContainerBounds(); | 118 gfx::Rect container_bounds = web_contents->GetContainerBounds(); |
104 | 119 |
105 InstantSearchPrerenderer* prerenderer = | 120 InstantSearchPrerenderer* prerenderer = |
106 InstantSearchPrerenderer::GetForProfile(profile_); | 121 InstantSearchPrerenderer::GetForProfile(profile_); |
107 if (prerenderer && prerenderer->IsAllowed(match, web_contents)) { | 122 if (prerenderer && prerenderer->IsAllowed(match, web_contents)) { |
(...skipping 20 matching lines...) Expand all Loading... | |
128 SearchTabHelper::FromWebContents(web_contents)-> | 143 SearchTabHelper::FromWebContents(web_contents)-> |
129 SetSuggestionToPrefetch(suggestion); | 144 SetSuggestionToPrefetch(suggestion); |
130 } | 145 } |
131 } else if (chrome::ShouldPrefetchSearchResults()) { | 146 } else if (chrome::ShouldPrefetchSearchResults()) { |
132 InstantSearchPrerenderer* prerenderer = | 147 InstantSearchPrerenderer* prerenderer = |
133 InstantSearchPrerenderer::GetForProfile(profile_); | 148 InstantSearchPrerenderer::GetForProfile(profile_); |
134 if (prerenderer) | 149 if (prerenderer) |
135 prerenderer->Prerender(suggestion); | 150 prerenderer->Prerender(suggestion); |
136 } | 151 } |
137 } | 152 } |
OLD | NEW |