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

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

Issue 11555033: Adding local html page used in Instant Extended mode when instant is disabled or unavailable. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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 f0241917dd04ac53212ea1a86d935a033c692cb8..30bcf946c4972d9b4ef75c2ee2a38b06da43033b 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -146,11 +146,16 @@ bool IsFullHeight(const InstantModel& model) {
} // namespace
+const char* InstantController::kLocalOmniboxPopupURL =
+ "chrome://local-omnibox-popup/local-omnibox-popup.html";
+
InstantController::InstantController(chrome::BrowserInstantController* browser,
- bool extended_enabled)
+ bool extended_enabled,
+ bool incognito_mode)
: browser_(browser),
extended_enabled_(extended_enabled),
instant_enabled_(false),
+ incognito_mode_(incognito_mode),
model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
last_omnibox_text_has_inline_autocompletion_(false),
last_verbatim_(false),
@@ -447,6 +452,10 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
if (!IsPreviewingSearchResults() && type != INSTANT_COMMIT_NAVIGATED)
return false;
+ // Never commit the local omnibox.
+ if (loader_->IsLoadingLocalOmniboxPopupURL())
+ return false;
+
if (type == INSTANT_COMMIT_FOCUS_LOST)
loader_->Cancel(last_omnibox_text_);
else if (type != INSTANT_COMMIT_NAVIGATED)
@@ -836,10 +845,16 @@ void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) {
}
bool InstantController::ResetLoader(const TemplateURL* template_url,
- const content::WebContents* active_tab) {
+ const content::WebContents* active_tab,
+ bool use_fallback) {
std::string instant_url;
- if (!GetInstantURL(template_url, &instant_url))
- return false;
+ if (!GetInstantURL(template_url, &instant_url)) {
dhollowa 2012/12/13 01:20:15 This seems complicated. If there is just one |use
Shishir 2012/12/13 22:57:58 The use fallback is required for a different reaso
+ if (!use_fallback || !extended_enabled_)
+ return false;
+
+ // If we are in extended mode, fallback to the local popup.
+ instant_url = kLocalOmniboxPopupURL;
+ }
if (loader_ && loader_->instant_url() == instant_url)
return true;
@@ -874,10 +889,14 @@ bool InstantController::CreateDefaultLoader() {
Profile::FromBrowserContext(active_tab->GetBrowserContext()))->
GetDefaultSearchProvider();
- return ResetLoader(template_url, active_tab);
+ return ResetLoader(template_url, active_tab, true);
}
void InstantController::OnStaleLoader() {
+ // The local popup is never stale.
+ if (loader_ && loader_->IsLoadingLocalOmniboxPopupURL())
+ return;
+
// If the preview is showing or the omnibox has focus, don't delete the
// loader. It will get refreshed the next time the preview is hidden or the
// omnibox loses focus.
@@ -920,7 +939,7 @@ bool InstantController::ResetLoaderForMatch(const AutocompleteMatch& match) {
// Try to create a loader for the instant_url in the TemplateURL of |match|.
const TemplateURL* template_url = match.GetTemplateURL(
Profile::FromBrowserContext(active_tab->GetBrowserContext()), false);
- if (ResetLoader(template_url, active_tab))
+ if (ResetLoader(template_url, active_tab, false))
samarth 2012/12/13 00:58:21 Please explain why we don't want to use fallback i
Shishir 2012/12/13 22:57:58 Done.
return true;
// In non-extended mode, stop if we couldn't get a loader for the |match|.
@@ -993,11 +1012,13 @@ void InstantController::ShowLoader(InstantShownReason reason,
}
// Show at 100% height except in the following cases:
+ // - The local omnibox popup is being loaded.
// - Instant is disabled. The page needs to be able to show only a dropdown.
// - The page wants to show custom NTP content.
// - The page is over a website other than search or an NTP, and is not
// already showing at 100% height.
- if (!instant_enabled_ || reason == INSTANT_SHOWN_CUSTOM_NTP_CONTENT ||
+ if (loader_->IsLoadingLocalOmniboxPopupURL() || !instant_enabled_ ||
+ reason == INSTANT_SHOWN_CUSTOM_NTP_CONTENT ||
(search_mode_.is_origin_default() && !IsFullHeight(model_)))
model_.SetPreviewState(search_mode_, height, units);
else
@@ -1033,6 +1054,11 @@ void InstantController::SendBoundsToPage() {
bool InstantController::GetInstantURL(const TemplateURL* template_url,
std::string* instant_url) const {
+ if (incognito_mode_) {
+ *instant_url = kLocalOmniboxPopupURL;
+ return true;
+ }
+
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kInstantURL)) {
*instant_url = command_line->GetSwitchValueASCII(switches::kInstantURL);

Powered by Google App Engine
This is Rietveld 408576698