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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 9419043: Revert 122412 - Enabled pressing TAB to traverse through the Omnibox results (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | chrome/chrome_tests.gypi » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/views/omnibox/omnibox_view_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 void OmniboxViewWin::SetUserText(const string16& text) { 682 void OmniboxViewWin::SetUserText(const string16& text) {
683 SetUserText(text, text, true); 683 SetUserText(text, text, true);
684 } 684 }
685 685
686 void OmniboxViewWin::SetUserText(const string16& text, 686 void OmniboxViewWin::SetUserText(const string16& text,
687 const string16& display_text, 687 const string16& display_text,
688 bool update_popup) { 688 bool update_popup) {
689 ScopedFreeze freeze(this, GetTextObjectModel()); 689 ScopedFreeze freeze(this, GetTextObjectModel());
690 model_->SetUserText(text); 690 model_->SetUserText(text);
691 saved_selection_for_focus_change_.cpMin = -1; 691 saved_selection_for_focus_change_.cpMin = -1;
692 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, 692 SetWindowTextAndCaretPos(display_text, display_text.length());
693 true); 693 if (update_popup)
694 UpdatePopup();
695 TextChanged();
694 } 696 }
695 697
696 void OmniboxViewWin::SetWindowTextAndCaretPos(const string16& text, 698 void OmniboxViewWin::SetWindowTextAndCaretPos(const string16& text,
697 size_t caret_pos, 699 size_t caret_pos) {
698 bool update_popup,
699 bool notify_text_changed) {
700 SetWindowText(text.c_str()); 700 SetWindowText(text.c_str());
701 PlaceCaretAt(caret_pos); 701 PlaceCaretAt(caret_pos);
702
703 if (update_popup)
704 UpdatePopup();
705
706 if (notify_text_changed)
707 TextChanged();
708 } 702 }
709 703
710 void OmniboxViewWin::SetForcedQuery() { 704 void OmniboxViewWin::SetForcedQuery() {
711 const string16 current_text(GetText()); 705 const string16 current_text(GetText());
712 const size_t start = current_text.find_first_not_of(kWhitespaceWide); 706 const size_t start = current_text.find_first_not_of(kWhitespaceWide);
713 if (start == string16::npos || (current_text[start] != '?')) 707 if (start == string16::npos || (current_text[start] != '?'))
714 SetUserText(L"?"); 708 SetUserText(L"?");
715 else 709 else
716 SetSelection(current_text.length(), start + 1); 710 SetSelection(current_text.length(), start + 1);
717 } 711 }
(...skipping 19 matching lines...) Expand all
737 void OmniboxViewWin::SelectAll(bool reversed) { 731 void OmniboxViewWin::SelectAll(bool reversed) {
738 if (reversed) 732 if (reversed)
739 SetSelection(GetTextLength(), 0); 733 SetSelection(GetTextLength(), 0);
740 else 734 else
741 SetSelection(0, GetTextLength()); 735 SetSelection(0, GetTextLength());
742 } 736 }
743 737
744 void OmniboxViewWin::RevertAll() { 738 void OmniboxViewWin::RevertAll() {
745 ScopedFreeze freeze(this, GetTextObjectModel()); 739 ScopedFreeze freeze(this, GetTextObjectModel());
746 ClosePopup(); 740 ClosePopup();
741 model_->Revert();
747 saved_selection_for_focus_change_.cpMin = -1; 742 saved_selection_for_focus_change_.cpMin = -1;
748 model_->Revert(); 743 TextChanged();
749 } 744 }
750 745
751 void OmniboxViewWin::UpdatePopup() { 746 void OmniboxViewWin::UpdatePopup() {
752 ScopedFreeze freeze(this, GetTextObjectModel()); 747 ScopedFreeze freeze(this, GetTextObjectModel());
753 model_->SetInputInProgress(true); 748 model_->SetInputInProgress(true);
754 749
755 // Don't allow the popup to open while the candidate window is open, so 750 // Don't allow the popup to open while the candidate window is open, so
756 // they don't overlap. 751 // they don't overlap.
757 if (ime_candidate_window_open_) 752 if (ime_candidate_window_open_)
758 return; 753 return;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 GetSelection(original_selection_); 828 GetSelection(original_selection_);
834 829
835 // Set new text and cursor position. Sometimes this does extra work (e.g. 830 // Set new text and cursor position. Sometimes this does extra work (e.g.
836 // when the new text and the old text are identical), but it's only called 831 // when the new text and the old text are identical), but it's only called
837 // when the user manually changes the selected line in the popup, so that's 832 // when the user manually changes the selected line in the popup, so that's
838 // not really a problem. Also, even when the text hasn't changed we'd want to 833 // not really a problem. Also, even when the text hasn't changed we'd want to
839 // update the caret, because if the user had the cursor in the middle of the 834 // update the caret, because if the user had the cursor in the middle of the
840 // text and then arrowed to another entry with the same text, we'd still want 835 // text and then arrowed to another entry with the same text, we'd still want
841 // to move the caret. 836 // to move the caret.
842 ScopedFreeze freeze(this, GetTextObjectModel()); 837 ScopedFreeze freeze(this, GetTextObjectModel());
843 SetWindowTextAndCaretPos(display_text, display_text.length(), false, true); 838 SetWindowTextAndCaretPos(display_text, display_text.length());
839 TextChanged();
844 } 840 }
845 841
846 bool OmniboxViewWin::OnInlineAutocompleteTextMaybeChanged( 842 bool OmniboxViewWin::OnInlineAutocompleteTextMaybeChanged(
847 const string16& display_text, 843 const string16& display_text,
848 size_t user_text_length) { 844 size_t user_text_length) {
849 // Update the text and selection. Because this can be called repeatedly while 845 // Update the text and selection. Because this can be called repeatedly while
850 // typing, we've careful not to freeze the edit unless we really need to. 846 // typing, we've careful not to freeze the edit unless we really need to.
851 // Also, unlike in the temporary text case above, here we don't want to update 847 // Also, unlike in the temporary text case above, here we don't want to update
852 // the caret/selection unless we have to, since this might make the user's 848 // the caret/selection unless we have to, since this might make the user's
853 // caret position change without warning during typing. 849 // caret position change without warning during typing.
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 } 2080 }
2085 2081
2086 // We're showing a keyword and the user pressed backspace at the beginning 2082 // We're showing a keyword and the user pressed backspace at the beginning
2087 // of the text. Delete the selected keyword. 2083 // of the text. Delete the selected keyword.
2088 ScopedFreeze freeze(this, GetTextObjectModel()); 2084 ScopedFreeze freeze(this, GetTextObjectModel());
2089 model_->ClearKeyword(GetText()); 2085 model_->ClearKeyword(GetText());
2090 return true; 2086 return true;
2091 } 2087 }
2092 2088
2093 case VK_TAB: { 2089 case VK_TAB: {
2094 const bool shift_pressed = GetKeyState(VK_SHIFT) < 0; 2090 if (model_->is_keyword_hint()) {
2095 if (model_->is_keyword_hint() && !shift_pressed) {
2096 // Accept the keyword. 2091 // Accept the keyword.
2097 ScopedFreeze freeze(this, GetTextObjectModel()); 2092 ScopedFreeze freeze(this, GetTextObjectModel());
2098 model_->AcceptKeyword(); 2093 model_->AcceptKeyword();
2099 } else if (shift_pressed && 2094 } else if (!IsCaretAtEnd()) {
2100 model_->popup_model()->selected_line_state() == 2095 ScopedFreeze freeze(this, GetTextObjectModel());
2101 AutocompletePopupModel::KEYWORD) { 2096 OnBeforePossibleChange();
2102 model_->ClearKeyword(GetText()); 2097 PlaceCaretAt(GetTextLength());
2098 OnAfterPossibleChange();
2103 } else { 2099 } else {
2104 model_->OnUpOrDownKeyPressed(shift_pressed ? -count : count); 2100 model_->CommitSuggestedText(true);
2105 } 2101 }
2106 return true; 2102 return true;
2107 } 2103 }
2108 2104
2109 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode). 2105 case 0xbb: // Ctrl-'='. Triggers subscripting (even in plain text mode).
2110 // We don't use VK_OEM_PLUS in case the macro isn't defined. 2106 // We don't use VK_OEM_PLUS in case the macro isn't defined.
2111 // (e.g., we don't have this symbol in embeded environment). 2107 // (e.g., we don't have this symbol in embeded environment).
2112 return true; 2108 return true;
2113 2109
2114 default: 2110 default:
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 return omnibox_view; 2712 return omnibox_view;
2717 } 2713 }
2718 return new OmniboxViewWin(controller, 2714 return new OmniboxViewWin(controller,
2719 toolbar_model, 2715 toolbar_model,
2720 location_bar, 2716 location_bar,
2721 command_updater, 2717 command_updater,
2722 popup_window_mode, 2718 popup_window_mode,
2723 location_bar); 2719 location_bar);
2724 } 2720 }
2725 #endif 2721 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_win.h ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698