| 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());
|
| }
|
|
|