Index: chrome/browser/instant/instant_controller.cc |
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc |
index 47663bc6ae185a7dd239519067afe180dddc15e5..0e1c9c685edc762a5b4dd5fdfbeb6b8c142df02a 100644 |
--- a/chrome/browser/instant/instant_controller.cc |
+++ b/chrome/browser/instant/instant_controller.cc |
@@ -152,7 +152,7 @@ InstantController::InstantController(chrome::BrowserInstantController* browser, |
last_verbatim_(false), |
last_transition_type_(content::PAGE_TRANSITION_LINK), |
last_match_was_search_(false), |
- is_omnibox_focused_(false) { |
+ omnibox_focus_state_(NONE) { |
} |
InstantController::~InstantController() { |
@@ -476,7 +476,7 @@ bool InstantController::CommitIfCurrent(InstantCommitType type) { |
void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { |
DVLOG(1) << "OmniboxLostFocus"; |
- is_omnibox_focused_ = false; |
+ omnibox_focus_state_ = NONE; |
if (!extended_enabled_ && !instant_enabled_) |
return; |
@@ -489,6 +489,7 @@ void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { |
return; |
} |
+ SendKeyCaptureModeToPage(); |
sreeram
2012/11/29 13:22:31
IsCurrent() returns false when on the NTP. Don't y
samarth
2012/11/29 17:28:21
Good catch. Fixed it so that the Send..() call is
|
#if defined(OS_MACOSX) |
if (!loader_->IsPointerDownFromActivate()) |
Hide(true); |
@@ -501,13 +502,15 @@ void InstantController::OmniboxLostFocus(gfx::NativeView view_gaining_focus) { |
#endif |
} |
-void InstantController::OmniboxGotFocus() { |
+void InstantController::OmniboxGotFocus(bool focus_is_visible) { |
DVLOG(1) << "OmniboxGotFocus"; |
- is_omnibox_focused_ = true; |
+ omnibox_focus_state_ = focus_is_visible ? VISIBLE : INVISIBLE; |
if (!extended_enabled_ && !instant_enabled_) |
return; |
+ SendKeyCaptureModeToPage(); |
+ |
if (!GetPreviewContents()) |
CreateDefaultLoader(); |
} |
@@ -707,10 +710,11 @@ bool InstantController::ResetLoader(const TemplateURL* template_url, |
loader_.reset(new InstantLoader(this, instant_url, active_tab)); |
loader_->Init(); |
- // Ensure the searchbox API has the correct theme-related info and context. |
+ // Ensure the searchbox API has correct state. |
if (extended_enabled_) { |
browser_->UpdateThemeInfoForPreview(); |
loader_->SearchModeChanged(search_mode_); |
+ SendKeyCaptureModeToPage(); |
} |
// Reset the loader timer. |
@@ -740,7 +744,7 @@ void InstantController::OnStaleLoader() { |
// 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. |
- if (!stale_loader_timer_.IsRunning() && !is_omnibox_focused_ && |
+ if (!stale_loader_timer_.IsRunning() && omnibox_focus_state_ == NONE && |
model_.mode().is_default()) { |
DeleteLoader(); |
CreateDefaultLoader(); |
@@ -850,6 +854,10 @@ void InstantController::SendBoundsToPage() { |
loader_->SetOmniboxBounds(intersection); |
} |
+void InstantController::SendKeyCaptureModeToPage() { |
+ loader_->OnKeyCaptureChange(omnibox_focus_state_ == INVISIBLE); |
sreeram
2012/11/29 13:22:31
You should guard this on these two clauses (either
samarth
2012/11/29 17:28:21
Added the checks here to be safe.
|
+} |
+ |
bool InstantController::GetInstantURL(const TemplateURL* template_url, |
std::string* instant_url) const { |
CommandLine* command_line = CommandLine::ForCurrentProcess(); |