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

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

Issue 137993020: (Try 2) InstantExtended: remove dead code related to the non-cacheable NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable InstantPolicyTests Created 6 years, 11 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 | Annotate | Revision Log
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/instant_controller.h" 5 #include "chrome/browser/ui/search/instant_controller.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/content_settings_provider.h" 10 #include "chrome/browser/content_settings/content_settings_provider.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } else { 110 } else {
111 if (chrome::ShouldPrefetchSearchResults()) { 111 if (chrome::ShouldPrefetchSearchResults()) {
112 InstantSearchPrerenderer* prerenderer = 112 InstantSearchPrerenderer* prerenderer =
113 InstantSearchPrerenderer::GetForProfile(profile()); 113 InstantSearchPrerenderer::GetForProfile(profile());
114 if (prerenderer) 114 if (prerenderer)
115 prerenderer->Prerender(suggestion); 115 prerenderer->Prerender(suggestion);
116 } 116 }
117 } 117 }
118 } 118 }
119 119
120 void InstantController::InstantPageLoadFailed(content::WebContents* contents) {
121 DCHECK(IsContentsFrom(instant_tab(), contents));
122
123 // Verify we're not already on a local page and that the URL precisely
124 // equals the instant_url (minus the query params, as those will be filled
125 // in by template values). This check is necessary to make sure we don't
126 // inadvertently redirect to the local NTP if someone, say, reloads a SRP
127 // while offline, as a committed results page still counts as an instant
128 // url. We also check to make sure there's no forward history, as if
129 // someone hits the back button a lot when offline and returns to a NTP
130 // we don't want to redirect and nuke their forward history stack.
131 const GURL& current_url = contents->GetURL();
132 GURL instant_url = chrome::GetInstantURL(profile(),
133 chrome::kDisableStartMargin, false);
134 if (instant_tab_->IsLocal() ||
135 !search::MatchesOriginAndPath(instant_url, current_url) ||
136 !current_url.ref().empty() ||
137 contents->GetController().CanGoForward())
138 return;
139 LOG_INSTANT_DEBUG_EVENT(this, "InstantPageLoadFailed: instant_tab");
140 RedirectToLocalNTP(contents);
141 }
142
143 bool InstantController::SubmitQuery(const base::string16& search_terms) { 120 bool InstantController::SubmitQuery(const base::string16& search_terms) {
144 if (instant_tab_ && instant_tab_->supports_instant() && 121 if (instant_tab_ && instant_tab_->supports_instant() &&
145 search_mode_.is_origin_search()) { 122 search_mode_.is_origin_search()) {
146 // Use |instant_tab_| to run the query if we're already on a search results 123 // Use |instant_tab_| to run the query if we're already on a search results
147 // page. (NOTE: in particular, we do not send the query to NTPs.) 124 // page. (NOTE: in particular, we do not send the query to NTPs.)
148 SearchTabHelper::FromWebContents(instant_tab_->contents())->Submit( 125 SearchTabHelper::FromWebContents(instant_tab_->contents())->Submit(
149 search_terms); 126 search_terms);
150 instant_tab_->contents()->GetView()->Focus(); 127 instant_tab_->contents()->GetView()->Focus();
151 EnsureSearchTermsAreSet(instant_tab_->contents(), search_terms); 128 EnsureSearchTermsAreSet(instant_tab_->contents(), search_terms);
152 return true; 129 return true;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 omnibox_focus_change_reason_); 266 omnibox_focus_change_reason_);
290 instant_tab_->sender()->SetInputInProgress(IsInputInProgress()); 267 instant_tab_->sender()->SetInputInProgress(IsInputInProgress());
291 } 268 }
292 } 269 }
293 270
294 bool InstantController::IsInputInProgress() const { 271 bool InstantController::IsInputInProgress() const {
295 return !search_mode_.is_ntp() && 272 return !search_mode_.is_ntp() &&
296 omnibox_focus_state_ == OMNIBOX_FOCUS_VISIBLE; 273 omnibox_focus_state_ == OMNIBOX_FOCUS_VISIBLE;
297 } 274 }
298 275
299 void InstantController::RedirectToLocalNTP(content::WebContents* contents) {
300 contents->GetController().LoadURL(
301 GURL(chrome::kChromeSearchLocalNtpUrl),
302 content::Referrer(),
303 content::PAGE_TRANSITION_SERVER_REDIRECT,
304 std::string()); // No extra headers.
305 // TODO(dcblack): Remove extraneous history entry caused by 404s.
306 // Note that the base case of a 204 being returned doesn't push a history
307 // entry.
308 }
309
310 InstantService* InstantController::GetInstantService() const { 276 InstantService* InstantController::GetInstantService() const {
311 return InstantServiceFactory::GetForProfile(profile()); 277 return InstantServiceFactory::GetForProfile(profile());
312 } 278 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_controller.h ('k') | chrome/browser/ui/search/instant_extended_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698