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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_mac.mm

Issue 180010: [Mac] Don't eat tab if tab-to-search hint not visible. (Closed)
Patch Set: Created 11 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit_view_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 #include "app/gfx/font.h" 8 #include "app/gfx/font.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/clipboard.h" 10 #include "base/clipboard.h"
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // OnAfterPossibleChange(), even if identical contents are pasted into the 615 // OnAfterPossibleChange(), even if identical contents are pasted into the
616 // text box. 616 // text box.
617 text_before_change_.clear(); 617 text_before_change_.clear();
618 618
619 NSString* s = base::SysWideToNSString(text); 619 NSString* s = base::SysWideToNSString(text);
620 [[field_ currentEditor] replaceCharactersInRange:selectedRange withString:s]; 620 [[field_ currentEditor] replaceCharactersInRange:selectedRange withString:s];
621 621
622 OnAfterPossibleChange(); 622 OnAfterPossibleChange();
623 } 623 }
624 624
625 bool AutocompleteEditViewMac::OnTabPressed() {
626 if (model_->is_keyword_hint() && !model_->keyword().empty()) {
627 model_->AcceptKeyword();
628 return true;
629 }
630 return false;
631 }
632
625 bool AutocompleteEditViewMac::IsPopupOpen() const { 633 bool AutocompleteEditViewMac::IsPopupOpen() const {
626 return popup_view_->IsOpen(); 634 return popup_view_->IsOpen();
627 } 635 }
628 636
629 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) { 637 void AutocompleteEditViewMac::OnControlKeyChanged(bool pressed) {
630 model_->OnControlKeyChanged(pressed); 638 model_->OnControlKeyChanged(pressed);
631 } 639 }
632 640
633 void AutocompleteEditViewMac::AcceptInput( 641 void AutocompleteEditViewMac::AcceptInput(
634 WindowOpenDisposition disposition, bool for_drop) { 642 WindowOpenDisposition disposition, bool for_drop) {
635 model_->AcceptInput(disposition, for_drop); 643 model_->AcceptInput(disposition, for_drop);
636 } 644 }
637 645
638 void AutocompleteEditViewMac::AcceptKeyword() {
639 model_->AcceptKeyword();
640 }
641
642 void AutocompleteEditViewMac::FocusLocation() { 646 void AutocompleteEditViewMac::FocusLocation() {
643 [[field_ window] makeFirstResponder:field_]; 647 [[field_ window] makeFirstResponder:field_];
644 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]); 648 DCHECK_EQ([field_ currentEditor], [[field_ window] firstResponder]);
645 } 649 }
646 650
647 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this 651 // TODO(shess): Copied from autocomplete_edit_view_win.cc. Could this
648 // be pushed into the model? 652 // be pushed into the model?
649 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) { 653 std::wstring AutocompleteEditViewMac::GetClipboardText(Clipboard* clipboard) {
650 // autocomplete_edit_view_win.cc assumes this can never happen, we 654 // autocomplete_edit_view_win.cc assumes this can never happen, we
651 // will too. 655 // will too.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 edit_view_->OnUpOrDownKeyPressed(true, true); 722 edit_view_->OnUpOrDownKeyPressed(true, true);
719 return YES; 723 return YES;
720 } 724 }
721 725
722 if (cmd == @selector(cancelOperation:)) { 726 if (cmd == @selector(cancelOperation:)) {
723 edit_view_->OnEscapeKeyPressed(); 727 edit_view_->OnEscapeKeyPressed();
724 return YES; 728 return YES;
725 } 729 }
726 730
727 if (cmd == @selector(insertTab:)) { 731 if (cmd == @selector(insertTab:)) {
728 edit_view_->AcceptKeyword(); 732 if (edit_view_->OnTabPressed()) {
729 return YES; 733 return YES;
734 }
730 } 735 }
731 736
732 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op 737 // |-noop:| is sent when the user presses Cmd+Return. Override the no-op
733 // behavior with the proper WindowOpenDisposition. 738 // behavior with the proper WindowOpenDisposition.
734 NSEvent* event = [NSApp currentEvent]; 739 NSEvent* event = [NSApp currentEvent];
735 if (cmd == @selector(insertNewline:) || 740 if (cmd == @selector(insertNewline:) ||
736 (cmd == @selector(noop:) && [event keyCode] == kVK_Return)) { 741 (cmd == @selector(noop:) && [event keyCode] == kVK_Return)) {
737 WindowOpenDisposition disposition = 742 WindowOpenDisposition disposition =
738 event_utils::WindowOpenDispositionFromNSEvent(event); 743 event_utils::WindowOpenDispositionFromNSEvent(event);
739 edit_view_->AcceptInput(disposition, false); 744 edit_view_->AcceptInput(disposition, false);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 // prepended and ".com" appended. This calls down to 806 // prepended and ".com" appended. This calls down to
802 // AutocompleteEditModel::OnControlKeyChanged() so that it can change 807 // AutocompleteEditModel::OnControlKeyChanged() so that it can change
803 // the popup to reflect this. See autocomplete_edit.cc 808 // the popup to reflect this. See autocomplete_edit.cc
804 // OnControlKeyChanged() and OnAfterPossibleChange(). 809 // OnControlKeyChanged() and OnAfterPossibleChange().
805 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent { 810 - (void)control:(NSControl*)control flagsChanged:(NSEvent*)theEvent {
806 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0; 811 BOOL controlFlag = ([theEvent modifierFlags]&NSControlKeyMask) != 0;
807 edit_view_->OnControlKeyChanged(controlFlag); 812 edit_view_->OnControlKeyChanged(controlFlag);
808 } 813 }
809 814
810 @end 815 @end
OLDNEW
« 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