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

Unified Diff: chrome/browser/ui/omnibox/omnibox_edit_model.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: Rebase and refactor. 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/ui/omnibox/omnibox_edit_model.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 668d9a820ea8ff5b715b1dba83d0cf0d3f6ab002..f1531deb1fa8bbcdd49a1abd7e5b30b86acfa16b 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -136,7 +136,7 @@ const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() {
}
void OmniboxEditModel::RestoreState(const State& state) {
- SetCaretVisibility(state.is_caret_visible);
+ SetCaretVisibilityInternal(state.is_caret_visible, FOCUS_CHANGE_TAB_SWITCH);
// Restore any user editing.
if (state.user_input_in_progress) {
// NOTE: Be sure and set keyword-related state BEFORE invoking
@@ -718,8 +718,10 @@ void OmniboxEditModel::OnSetFocus(bool control_down) {
// Restore caret visibility whenever the user focuses back into the omnibox.
SetCaretVisibility(true);
- if (InstantController* instant = controller_->GetInstant())
- instant->OmniboxGotFocus();
+ if (InstantController* instant = controller_->GetInstant()) {
+ instant->OmniboxFocusChanged(FOCUS_VISIBLE,
+ FOCUS_CHANGE_EXPLICIT, NULL);
+ }
content::WebContents* web_contents = controller_->GetWebContents();
if (web_contents) {
@@ -736,7 +738,17 @@ void OmniboxEditModel::OnSetFocus(bool control_down) {
}
void OmniboxEditModel::SetCaretVisibility(bool visible) {
+ SetCaretVisibilityInternal(visible, FOCUS_CHANGE_EXPLICIT);
+}
+
+void OmniboxEditModel::SetCaretVisibilityInternal(
+ bool visible,
+ OmniboxFocusChangeReason reason) {
if (has_focus_ && visible != is_caret_visible_) {
+ if (InstantController* instant = controller_->GetInstant()) {
+ instant->OmniboxFocusChanged(visible ? FOCUS_VISIBLE : FOCUS_INVISIBLE,
+ reason, NULL);
+ }
is_caret_visible_ = visible;
view_->ApplyCaretVisibility();
}
@@ -745,8 +757,10 @@ void OmniboxEditModel::SetCaretVisibility(bool visible) {
void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) {
SetInstantSuggestion(InstantSuggestion());
- if (InstantController* instant = controller_->GetInstant())
- instant->OmniboxLostFocus(view_gaining_focus);
+ if (InstantController* instant = controller_->GetInstant()) {
+ instant->OmniboxFocusChanged(FOCUS_NONE, FOCUS_CHANGE_EXPLICIT,
+ view_gaining_focus);
+ }
// TODO(jered): Rip this out along with StartZeroSuggest.
autocomplete_controller_->StopZeroSuggest();
@@ -952,7 +966,7 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
// Restore caret visibility whenever the user changes text or selection in the
// omnibox.
if (text_differs || selection_differs)
- SetCaretVisibility(true);
+ SetCaretVisibilityInternal(true, FOCUS_CHANGE_TYPING);
// Modifying the selection counts as accepting the autocompleted text.
const bool user_text_changed =

Powered by Google App Engine
This is Rietveld 408576698