summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 00:56:55 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 00:56:55 +0000
commit6266e95ad64cd5b19e79da042359618acff5eb0c (patch)
tree1e2d24f3cd414d7b1f8a0c942ede72c6422a6b5c /chrome
parentd5f31ef82db2701c10d2c4b936ca119a5a783d89 (diff)
downloadchromium_src-6266e95ad64cd5b19e79da042359618acff5eb0c.zip
chromium_src-6266e95ad64cd5b19e79da042359618acff5eb0c.tar.gz
chromium_src-6266e95ad64cd5b19e79da042359618acff5eb0c.tar.bz2
Implement shift+delete for removing omnibox entries on Linux.
TEST=Select an item from the autocomplete popup and press shift+del. Clear the autocomplete and start typing again. Verify that the item doesn't re-appear. Review URL: http://codereview.chromium.org/271063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc17
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h5
2 files changed, 19 insertions, 3 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index b375c7c..02da78b 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -485,7 +485,7 @@ bool AutocompleteEditViewGtk::OnAfterPossibleChange() {
// See if the text or selection have changed since OnBeforePossibleChange().
std::wstring new_text(GetText());
- bool text_differs = (new_text != text_before_change_);
+ text_changed_ = (new_text != text_before_change_);
// When the user has deleted text, we don't allow inline autocomplete. Make
// sure to not flag cases like selecting part of the text and then pasting
@@ -498,9 +498,9 @@ bool AutocompleteEditViewGtk::OnAfterPossibleChange() {
sel_before_change_.cp_max));
bool something_changed = model_->OnAfterPossibleChange(new_text,
- selection_differs, text_differs, just_deleted_text, at_end_of_edit);
+ selection_differs, text_changed_, just_deleted_text, at_end_of_edit);
- if (something_changed && text_differs)
+ if (something_changed && text_changed_)
TextChanged();
return something_changed;
@@ -643,6 +643,9 @@ gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget,
// key input action as a paste action.
paste_clipboard_requested_ = false;
+ // Reset |text_changed_| before passing the key event on to the text view.
+ text_changed_ = false;
+
// Call the default handler, so that IME can work as normal.
// New line characters will be filtered out by our "insert-text"
// signal handler attached to |text_buffer_| object.
@@ -667,6 +670,14 @@ gboolean AutocompleteEditViewGtk::HandleKeyPress(GtkWidget* widget,
// the contents of omnibox2, we notify the AutocompleteEditModel class when
// the control-key state is changed.
model_->OnControlKeyChanged(true);
+ } else if (!text_changed_ && event->keyval == GDK_Delete &&
+ event->state & GDK_SHIFT_MASK) {
+ // If shift+del didn't change the text, we let this delete an entry from
+ // the popup. We can't check to see if the IME handled it because even if
+ // nothing is selected, the IME or the TextView still report handling it.
+ AutocompletePopupModel* popup_model = popup_view_->GetModel();
+ if (popup_model->IsOpen())
+ popup_model->TryDeletingCurrentItem();
}
// Set |enter_was_pressed_| to false, to make sure OnAfterPossibleChange() can
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index 02c619e..3c16392 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -426,6 +426,11 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
// handled by IME or not.
bool enter_was_inserted_;
+ // Indicates whether the IME changed the text. It's possible for the IME to
+ // handle a key event but not change the text contents (e.g., when pressing
+ // shift+del with no selection).
+ bool text_changed_;
+
// Contains the character range that should have a strikethrough (used for
// insecure schemes). If the range is size one or less, no strikethrough
// is needed.