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

Unified Diff: trunk/src/chrome/browser/ui/search/instant_controller.cc

Issue 135903002: Revert 244407 "InstantExtended: remove dead code related to the ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/ui/search/instant_controller.cc
===================================================================
--- trunk/src/chrome/browser/ui/search/instant_controller.cc (revision 244428)
+++ trunk/src/chrome/browser/ui/search/instant_controller.cc (working copy)
@@ -117,6 +117,29 @@
}
}
+void InstantController::InstantPageLoadFailed(content::WebContents* contents) {
+ DCHECK(IsContentsFrom(instant_tab(), contents));
+
+ // Verify we're not already on a local page and that the URL precisely
+ // equals the instant_url (minus the query params, as those will be filled
+ // in by template values). This check is necessary to make sure we don't
+ // inadvertently redirect to the local NTP if someone, say, reloads a SRP
+ // while offline, as a committed results page still counts as an instant
+ // url. We also check to make sure there's no forward history, as if
+ // someone hits the back button a lot when offline and returns to a NTP
+ // we don't want to redirect and nuke their forward history stack.
+ const GURL& current_url = contents->GetURL();
+ GURL instant_url = chrome::GetInstantURL(profile(),
+ chrome::kDisableStartMargin, false);
+ if (instant_tab_->IsLocal() ||
+ !search::MatchesOriginAndPath(instant_url, current_url) ||
+ !current_url.ref().empty() ||
+ contents->GetController().CanGoForward())
+ return;
+ LOG_INSTANT_DEBUG_EVENT(this, "InstantPageLoadFailed: instant_tab");
+ RedirectToLocalNTP(contents);
+}
+
bool InstantController::SubmitQuery(const base::string16& search_terms) {
if (instant_tab_ && instant_tab_->supports_instant() &&
search_mode_.is_origin_search()) {
@@ -273,6 +296,17 @@
omnibox_focus_state_ == OMNIBOX_FOCUS_VISIBLE;
}
+void InstantController::RedirectToLocalNTP(content::WebContents* contents) {
+ contents->GetController().LoadURL(
+ GURL(chrome::kChromeSearchLocalNtpUrl),
+ content::Referrer(),
+ content::PAGE_TRANSITION_SERVER_REDIRECT,
+ std::string()); // No extra headers.
+ // TODO(dcblack): Remove extraneous history entry caused by 404s.
+ // Note that the base case of a 204 being returned doesn't push a history
+ // entry.
+}
+
InstantService* InstantController::GetInstantService() const {
return InstantServiceFactory::GetForProfile(profile());
}

Powered by Google App Engine
This is Rietveld 408576698