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

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

Issue 2027133002: Modify ui::TextInputClient to use ui::TextEditCommand enum in place of resource ids. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor4_up_down_mac
Patch Set: Address review comments. Created 4 years, 6 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
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_views.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/web_contents.h" 35 #include "content/public/browser/web_contents.h"
36 #include "extensions/common/constants.h" 36 #include "extensions/common/constants.h"
37 #include "grit/components_strings.h" 37 #include "grit/components_strings.h"
38 #include "net/base/escape.h" 38 #include "net/base/escape.h"
39 #include "third_party/skia/include/core/SkColor.h" 39 #include "third_party/skia/include/core/SkColor.h"
40 #include "ui/accessibility/ax_view_state.h" 40 #include "ui/accessibility/ax_view_state.h"
41 #include "ui/base/clipboard/scoped_clipboard_writer.h" 41 #include "ui/base/clipboard/scoped_clipboard_writer.h"
42 #include "ui/base/dragdrop/drag_drop_types.h" 42 #include "ui/base/dragdrop/drag_drop_types.h"
43 #include "ui/base/dragdrop/os_exchange_data.h" 43 #include "ui/base/dragdrop/os_exchange_data.h"
44 #include "ui/base/ime/input_method.h" 44 #include "ui/base/ime/input_method.h"
45 #include "ui/base/ime/text_edit_commands.h"
45 #include "ui/base/ime/text_input_client.h" 46 #include "ui/base/ime/text_input_client.h"
46 #include "ui/base/ime/text_input_type.h" 47 #include "ui/base/ime/text_input_type.h"
47 #include "ui/base/l10n/l10n_util.h" 48 #include "ui/base/l10n/l10n_util.h"
48 #include "ui/base/material_design/material_design_controller.h" 49 #include "ui/base/material_design/material_design_controller.h"
49 #include "ui/base/models/simple_menu_model.h" 50 #include "ui/base/models/simple_menu_model.h"
50 #include "ui/compositor/layer.h" 51 #include "ui/compositor/layer.h"
51 #include "ui/events/event.h" 52 #include "ui/events/event.h"
52 #include "ui/gfx/canvas.h" 53 #include "ui/gfx/canvas.h"
53 #include "ui/gfx/font_list.h" 54 #include "ui/gfx/font_list.h"
54 #include "ui/gfx/selection_model.h" 55 #include "ui/gfx/selection_model.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return; 363 return;
363 case IDS_SHOW_URL: 364 case IDS_SHOW_URL:
364 controller()->ShowURL(); 365 controller()->ShowURL();
365 return; 366 return;
366 case IDC_EDIT_SEARCH_ENGINES: 367 case IDC_EDIT_SEARCH_ENGINES:
367 location_bar_view_->command_updater()->ExecuteCommand(command_id); 368 location_bar_view_->command_updater()->ExecuteCommand(command_id);
368 return; 369 return;
369 370
370 // These commands do invoke the popup. 371 // These commands do invoke the popup.
371 case IDS_APP_PASTE: 372 case IDS_APP_PASTE:
372 ExecuteEditCommand(IDS_APP_PASTE); 373 ExecuteTextEditCommand(ui::TextEditCommand::PASTE);
373 return; 374 return;
374 default: 375 default:
375 if (Textfield::IsCommandIdEnabled(command_id)) { 376 if (Textfield::IsCommandIdEnabled(command_id)) {
376 // The Textfield code will invoke OnBefore/AfterPossibleChange() itself 377 // The Textfield code will invoke OnBefore/AfterPossibleChange() itself
377 // as necessary. 378 // as necessary.
378 Textfield::ExecuteCommand(command_id, event_flags); 379 Textfield::ExecuteCommand(command_id, event_flags);
379 return; 380 return;
380 } 381 }
381 OnBeforePossibleChange(); 382 OnBeforePossibleChange();
382 location_bar_view_->command_updater()->ExecuteCommand(command_id); 383 location_bar_view_->command_updater()->ExecuteCommand(command_id);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 case ui::VKEY_ESCAPE: 748 case ui::VKEY_ESCAPE:
748 return model()->OnEscapeKeyPressed(); 749 return model()->OnEscapeKeyPressed();
749 case ui::VKEY_CONTROL: 750 case ui::VKEY_CONTROL:
750 model()->OnControlKeyChanged(true); 751 model()->OnControlKeyChanged(true);
751 break; 752 break;
752 case ui::VKEY_DELETE: 753 case ui::VKEY_DELETE:
753 if (shift && model()->popup_model()->IsOpen()) 754 if (shift && model()->popup_model()->IsOpen())
754 model()->popup_model()->TryDeletingCurrentItem(); 755 model()->popup_model()->TryDeletingCurrentItem();
755 break; 756 break;
756 case ui::VKEY_UP: 757 case ui::VKEY_UP:
757 if (IsEditCommandEnabled(IDS_MOVE_UP)) { 758 if (IsTextEditCommandEnabled(ui::TextEditCommand::MOVE_UP)) {
758 ExecuteEditCommand(IDS_MOVE_UP); 759 ExecuteTextEditCommand(ui::TextEditCommand::MOVE_UP);
759 return true; 760 return true;
760 } 761 }
761 break; 762 break;
762 case ui::VKEY_DOWN: 763 case ui::VKEY_DOWN:
763 if (IsEditCommandEnabled(IDS_MOVE_DOWN)) { 764 if (IsTextEditCommandEnabled(ui::TextEditCommand::MOVE_DOWN)) {
764 ExecuteEditCommand(IDS_MOVE_DOWN); 765 ExecuteTextEditCommand(ui::TextEditCommand::MOVE_DOWN);
765 return true; 766 return true;
766 } 767 }
767 break; 768 break;
768 case ui::VKEY_PRIOR: 769 case ui::VKEY_PRIOR:
769 if (control || alt || shift) 770 if (control || alt || shift)
770 return false; 771 return false;
771 model()->OnUpOrDownKeyPressed(-1 * model()->result().size()); 772 model()->OnUpOrDownKeyPressed(-1 * model()->result().size());
772 return true; 773 return true;
773 case ui::VKEY_NEXT: 774 case ui::VKEY_NEXT:
774 if (control || alt || shift) 775 if (control || alt || shift)
775 return false; 776 return false;
776 model()->OnUpOrDownKeyPressed(model()->result().size()); 777 model()->OnUpOrDownKeyPressed(model()->result().size());
777 return true; 778 return true;
778 case ui::VKEY_V: 779 case ui::VKEY_V:
779 if (control && !alt && IsEditCommandEnabled(IDS_APP_PASTE)) { 780 if (control && !alt &&
780 ExecuteEditCommand(IDS_APP_PASTE); 781 IsTextEditCommandEnabled(ui::TextEditCommand::PASTE)) {
782 ExecuteTextEditCommand(ui::TextEditCommand::PASTE);
781 return true; 783 return true;
782 } 784 }
783 break; 785 break;
784 case ui::VKEY_INSERT: 786 case ui::VKEY_INSERT:
785 if (shift && !control && IsEditCommandEnabled(IDS_APP_PASTE)) { 787 if (shift && !control &&
786 ExecuteEditCommand(IDS_APP_PASTE); 788 IsTextEditCommandEnabled(ui::TextEditCommand::PASTE)) {
789 ExecuteTextEditCommand(ui::TextEditCommand::PASTE);
787 return true; 790 return true;
788 } 791 }
789 break; 792 break;
790 default: 793 default:
791 break; 794 break;
792 } 795 }
793 796
794 return views::Textfield::OnKeyPressed(event) || HandleEarlyTabActions(event); 797 return views::Textfield::OnKeyPressed(event) || HandleEarlyTabActions(event);
795 } 798 }
796 799
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 } 916 }
914 917
915 void OmniboxViewViews::DoInsertChar(base::char16 ch) { 918 void OmniboxViewViews::DoInsertChar(base::char16 ch) {
916 // If |insert_char_time_| is not null, there's a pending insert char operation 919 // If |insert_char_time_| is not null, there's a pending insert char operation
917 // that hasn't been painted yet. Keep the earlier time. 920 // that hasn't been painted yet. Keep the earlier time.
918 if (insert_char_time_.is_null()) 921 if (insert_char_time_.is_null())
919 insert_char_time_ = base::TimeTicks::Now(); 922 insert_char_time_ = base::TimeTicks::Now();
920 Textfield::DoInsertChar(ch); 923 Textfield::DoInsertChar(ch);
921 } 924 }
922 925
923 bool OmniboxViewViews::IsEditCommandEnabled(int command_id) const { 926 bool OmniboxViewViews::IsTextEditCommandEnabled(
924 switch (command_id) { 927 ui::TextEditCommand command) const {
925 case IDS_MOVE_UP: 928 switch (command) {
926 case IDS_MOVE_DOWN: 929 case ui::TextEditCommand::MOVE_UP:
930 case ui::TextEditCommand::MOVE_DOWN:
927 return !read_only(); 931 return !read_only();
928 case IDS_APP_PASTE: 932 case ui::TextEditCommand::PASTE:
929 return !read_only() && !GetClipboardText().empty(); 933 return !read_only() && !GetClipboardText().empty();
930 default: 934 default:
931 return Textfield::IsEditCommandEnabled(command_id); 935 return Textfield::IsTextEditCommandEnabled(command);
932 } 936 }
933 } 937 }
934 938
935 void OmniboxViewViews::ExecuteEditCommand(int command_id) { 939 void OmniboxViewViews::ExecuteTextEditCommand(ui::TextEditCommand command) {
936 // In the base class, touch text selection is deactivated when a command is 940 // In the base class, touch text selection is deactivated when a command is
937 // executed. Since we are not always calling the base class implementation 941 // executed. Since we are not always calling the base class implementation
938 // here, we need to deactivate touch text selection here, too. 942 // here, we need to deactivate touch text selection here, too.
939 DestroyTouchSelection(); 943 DestroyTouchSelection();
940 944
941 if (!IsEditCommandEnabled(command_id)) 945 if (!IsTextEditCommandEnabled(command))
942 return; 946 return;
943 947
944 switch (command_id) { 948 switch (command) {
945 case IDS_MOVE_UP: 949 case ui::TextEditCommand::MOVE_UP:
946 model()->OnUpOrDownKeyPressed(-1); 950 model()->OnUpOrDownKeyPressed(-1);
947 break; 951 break;
948 case IDS_MOVE_DOWN: 952 case ui::TextEditCommand::MOVE_DOWN:
949 model()->OnUpOrDownKeyPressed(1); 953 model()->OnUpOrDownKeyPressed(1);
950 break; 954 break;
951 case IDS_APP_PASTE: 955 case ui::TextEditCommand::PASTE:
952 OnPaste(); 956 OnPaste();
953 break; 957 break;
954 default: 958 default:
955 Textfield::ExecuteEditCommand(command_id); 959 Textfield::ExecuteTextEditCommand(command);
956 break; 960 break;
957 } 961 }
958 } 962 }
959 963
960 #if defined(OS_CHROMEOS) 964 #if defined(OS_CHROMEOS)
961 void OmniboxViewViews::CandidateWindowOpened( 965 void OmniboxViewViews::CandidateWindowOpened(
962 chromeos::input_method::InputMethodManager* manager) { 966 chromeos::input_method::InputMethodManager* manager) {
963 ime_candidate_window_open_ = true; 967 ime_candidate_window_open_ = true;
964 } 968 }
965 969
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 menu_contents->InsertItemWithStringIdAt( 1119 menu_contents->InsertItemWithStringIdAt(
1116 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); 1120 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL);
1117 } 1121 }
1118 1122
1119 // Minor note: We use IDC_ for command id here while the underlying textfield 1123 // Minor note: We use IDC_ for command id here while the underlying textfield
1120 // is using IDS_ for all its command ids. This is because views cannot depend 1124 // is using IDS_ for all its command ids. This is because views cannot depend
1121 // on IDC_ for now. 1125 // on IDC_ for now.
1122 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1126 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1123 IDS_EDIT_SEARCH_ENGINES); 1127 IDS_EDIT_SEARCH_ENGINES);
1124 } 1128 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | components/arc/ime/arc_ime_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698