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

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

Issue 11413217: Instant API: tell page whether the browser is capturing key strokes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@focus
Patch Set: Finish renaming. Created 8 years, 1 month 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 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();

Powered by Google App Engine
This is Rietveld 408576698