Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 338633003: Prerender Instant search base url on omnibox focus event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Omnibox check added Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/history/most_visited_tiles_experiment.h" 14 #include "chrome/browser/history/most_visited_tiles_experiment.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/search/instant_service.h" 16 #include "chrome/browser/search/instant_service.h"
17 #include "chrome/browser/search/instant_service_factory.h" 17 #include "chrome/browser/search/instant_service_factory.h"
18 #include "chrome/browser/search/search.h" 18 #include "chrome/browser/search/search.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/ui/app_list/app_list_util.h" 20 #include "chrome/browser/ui/app_list/app_list_util.h"
21 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/omnibox/location_bar.h" 23 #include "chrome/browser/ui/omnibox/location_bar.h"
24 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 24 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
25 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" 25 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
26 #include "chrome/browser/ui/omnibox/omnibox_view.h" 26 #include "chrome/browser/ui/omnibox/omnibox_view.h"
27 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
27 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h" 28 #include "chrome/browser/ui/search/search_ipc_router_policy_impl.h"
28 #include "chrome/browser/ui/search/search_tab_helper_delegate.h" 29 #include "chrome/browser/ui/search/search_tab_helper_delegate.h"
29 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 30 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
30 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h" 31 #include "chrome/browser/ui/webui/ntp/ntp_user_data_logger.h"
31 #include "chrome/common/url_constants.h" 32 #include "chrome/common/url_constants.h"
32 #include "components/signin/core/browser/signin_manager.h" 33 #include "components/signin/core/browser/signin_manager.h"
33 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
34 #include "content/public/browser/navigation_details.h" 35 #include "content/public/browser/navigation_details.h"
35 #include "content/public/browser/navigation_entry.h" 36 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/navigation_type.h" 37 #include "content/public/browser/navigation_type.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 content::NotificationService::NoDetails()); 166 content::NotificationService::NoDetails());
166 167
167 ipc_router_.OmniboxFocusChanged(state, reason); 168 ipc_router_.OmniboxFocusChanged(state, reason);
168 169
169 // Don't send oninputstart/oninputend updates in response to focus changes 170 // Don't send oninputstart/oninputend updates in response to focus changes
170 // if there's a navigation in progress. This prevents Chrome from sending 171 // if there's a navigation in progress. This prevents Chrome from sending
171 // a spurious oninputend when the user accepts a match in the omnibox. 172 // a spurious oninputend when the user accepts a match in the omnibox.
172 if (web_contents_->GetController().GetPendingEntry() == NULL) { 173 if (web_contents_->GetController().GetPendingEntry() == NULL) {
173 ipc_router_.SetInputInProgress(IsInputInProgress()); 174 ipc_router_.SetInputInProgress(IsInputInProgress());
174 } 175 }
176
177 if (chrome::ShouldPrerenderInstantUrlOnOmniboxFocus()) {
178 InstantSearchPrerenderer* prerenderer =
179 InstantSearchPrerenderer::GetForProfile(profile());
180 if (!prerenderer)
181 return;
kmadhusu 2014/06/19 20:44:54 style nit: Add a new line after this.
sidharthms 2014/06/19 20:57:16 Done.
182 if (state == OMNIBOX_FOCUS_NONE) {
183 prerenderer->Cancel();
184 return;
185 }
kmadhusu 2014/06/19 20:44:55 style nit: Add a new line after this.
sidharthms 2014/06/19 20:57:16 Done.
186 if (!IsSearchResultsPage())
kmadhusu 2014/06/19 20:44:54 style nit: Add curly braces here.
sidharthms 2014/06/19 20:57:16 Done.
187 prerenderer->Init(
188 web_contents_->GetController().GetSessionStorageNamespaceMap(),
189 web_contents_->GetContainerBounds().size());
190 }
175 } 191 }
176 192
177 void SearchTabHelper::NavigationEntryUpdated() { 193 void SearchTabHelper::NavigationEntryUpdated() {
178 if (!is_search_enabled_) 194 if (!is_search_enabled_)
179 return; 195 return;
180 196
181 UpdateMode(false, false); 197 UpdateMode(false, false);
182 } 198 }
183 199
184 void SearchTabHelper::InstantSupportChanged(bool instant_support) { 200 void SearchTabHelper::InstantSupportChanged(bool instant_support) {
(...skipping 22 matching lines...) Expand all
207 const InstantSuggestion& suggestion) { 223 const InstantSuggestion& suggestion) {
208 ipc_router_.SetSuggestionToPrefetch(suggestion); 224 ipc_router_.SetSuggestionToPrefetch(suggestion);
209 } 225 }
210 226
211 void SearchTabHelper::Submit(const base::string16& text) { 227 void SearchTabHelper::Submit(const base::string16& text) {
212 ipc_router_.Submit(text); 228 ipc_router_.Submit(text);
213 } 229 }
214 230
215 void SearchTabHelper::OnTabActivated() { 231 void SearchTabHelper::OnTabActivated() {
216 ipc_router_.OnTabActivated(); 232 ipc_router_.OnTabActivated();
233
234 OmniboxView* omnibox_view = GetOmniboxView();
235 if (chrome::ShouldPrerenderInstantUrlOnOmniboxFocus() && omnibox_view &&
236 omnibox_view->model()->has_focus()) {
237 InstantSearchPrerenderer* prerenderer =
238 InstantSearchPrerenderer::GetForProfile(profile());
239 if (prerenderer && !IsSearchResultsPage()) {
240 prerenderer->Init(
241 web_contents_->GetController().GetSessionStorageNamespaceMap(),
242 web_contents_->GetContainerBounds().size());
243 }
244 }
217 } 245 }
218 246
219 void SearchTabHelper::OnTabDeactivated() { 247 void SearchTabHelper::OnTabDeactivated() {
220 ipc_router_.OnTabDeactivated(); 248 ipc_router_.OnTabDeactivated();
221 } 249 }
222 250
223 void SearchTabHelper::ToggleVoiceSearch() { 251 void SearchTabHelper::ToggleVoiceSearch() {
224 ipc_router_.ToggleVoiceSearch(); 252 ipc_router_.ToggleVoiceSearch();
225 } 253 }
226 254
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 615
588 bool SearchTabHelper::IsInputInProgress() const { 616 bool SearchTabHelper::IsInputInProgress() const {
589 OmniboxView* omnibox = GetOmniboxView(); 617 OmniboxView* omnibox = GetOmniboxView();
590 return !model_.mode().is_ntp() && omnibox && 618 return !model_.mode().is_ntp() && omnibox &&
591 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; 619 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE;
592 } 620 }
593 621
594 OmniboxView* SearchTabHelper::GetOmniboxView() const { 622 OmniboxView* SearchTabHelper::GetOmniboxView() const {
595 return delegate_ ? delegate_->GetOmniboxView() : NULL; 623 return delegate_ ? delegate_->GetOmniboxView() : NULL;
596 } 624 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698