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

Unified Diff: chrome/browser/instant/instant_controller.cc

Issue 11833043: Instant Extended: Fallback to local preview if the remote instant page is not ready on user input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor
Patch Set: Removing LOG messages. Created 7 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: chrome/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 17a2fbae5cef7ce269772629b18ae3b34666e0b4..b94546bab03bb2920172f53274218b7e399c9bfe 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -371,6 +371,15 @@ bool InstantController::Update(const AutocompleteMatch& match,
if (first_interaction_time_.is_null())
first_interaction_time_ = base::Time::Now();
allow_preview_to_show_search_suggestions_ = true;
+
+ // For extended mode, if the loader is not ready at this point, switch over
+ // to a backup loader.
+ if (extended_enabled_ && !loader_->supports_instant() &&
+ !loader_->IsUsingLocalPreview() && browser_->GetActiveWebContents()) {
+ CreateLoader(kLocalOmniboxPopupURL, browser_->GetActiveWebContents());
+ loader_->set_is_in_fallback_mode(true);
+ }
+
loader_->Update(extended_enabled_ ? user_text : full_text,
selection_start, selection_end, verbatim);
}
@@ -921,6 +930,7 @@ void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) {
// If the preview is not showing at all, recreate it if it's stale.
if (model_.mode().is_default()) {
OnStaleLoader();
+ MaybeSwitchToRemoteLoader();
return;
}
@@ -961,6 +971,10 @@ bool InstantController::EnsureLoaderIsCurrent() {
if (!active_tab)
return false;
+ // In fallback mode, we do not change the loader.
+ if (loader_ && loader_->is_in_fallback_mode())
+ return true;
+
std::string instant_url;
if (!GetInstantURL(active_tab, &instant_url)) {
// If we are in extended mode, fallback to the local popup.
@@ -987,6 +1001,7 @@ void InstantController::CreateLoader(const std::string& instant_url,
loader_->SearchModeChanged(search_mode_);
loader_->KeyCaptureChanged(omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE);
loader_->SetMarginSize(start_margin_, end_margin_);
+ loader_->InitializeFonts();
}
// Restart the stale loader timer.
@@ -1011,6 +1026,17 @@ void InstantController::OnStaleLoader() {
}
}
+void InstantController::MaybeSwitchToRemoteLoader() {
+ if (!loader_ || !loader_->is_in_fallback_mode() ||
+ omnibox_focus_state_ != OMNIBOX_FOCUS_NONE ||
+ !model_.mode().is_default()) {
+ return;
+ }
+
+ loader_->set_is_in_fallback_mode(false);
+ EnsureLoaderIsCurrent();
+}
+
void InstantController::ResetInstantTab() {
// Do not wire up the InstantTab if instant should only use local previews, to
// prevent it from sending data to the page.
@@ -1021,6 +1047,7 @@ void InstantController::ResetInstantTab() {
instant_tab_->Init();
instant_tab_->SetDisplayInstantResults(instant_enabled_);
instant_tab_->SetMarginSize(start_margin_, end_margin_);
+ instant_tab_->InitializeFonts();
}
// Hide the |loader_| since we are now using |instant_tab_| instead.
@@ -1033,6 +1060,7 @@ void InstantController::ResetInstantTab() {
void InstantController::HideLoader() {
HideInternal();
OnStaleLoader();
+ MaybeSwitchToRemoteLoader();
}
void InstantController::HideInternal() {

Powered by Google App Engine
This is Rietveld 408576698