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

Unified Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 180009: [Mac] Handle backspacing out of keyword search. (Closed)
Patch Set: Consistent initializer per Rohit. Created 11 years, 4 months 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
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index 9ca8a6be54110823de56ea716d01cfdbb213fa7d..69a1b4ee32dd4578503bcc95eef4d7763fa2c325 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -630,6 +630,25 @@ bool AutocompleteEditViewMac::OnTabPressed() {
return false;
}
+bool AutocompleteEditViewMac::OnBackspacePressed() {
+ // Don't intercept if not in keyword search mode.
+ if (model_->is_keyword_hint() || model_->keyword().empty()) {
+ return false;
+ }
+
+ // Don't intercept if there is a selection, or the cursor isn't at
+ // the leftmost position.
+ const NSRange selection = GetSelectedRange();
+ if (selection.length > 0 || selection.location > 0) {
+ return false;
+ }
+
+ // We're showing a keyword and the user pressed backspace at the
+ // beginning of the text. Delete the selected keyword.
+ model_->ClearKeyword(GetText());
+ return true;
+}
+
bool AutocompleteEditViewMac::IsPopupOpen() const {
return popup_view_->IsOpen();
}
@@ -757,6 +776,12 @@ std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
return YES;
}
+ if (cmd == @selector(deleteBackward:)) {
+ if (edit_view_->OnBackspacePressed()) {
+ return YES;
+ }
+ }
+
// Capture the state before the operation changes the content.
// TODO(shess): Determine if this is always redundent WRT the call
// in -controlTextDidChange:.
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698