Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 case ui::TextEditCommand::MOVE_UP: | 814 case ui::TextEditCommand::MOVE_UP: |
| 815 case ui::TextEditCommand::MOVE_DOWN: | 815 case ui::TextEditCommand::MOVE_DOWN: |
| 816 return !read_only(); | 816 return !read_only(); |
| 817 case ui::TextEditCommand::PASTE: | 817 case ui::TextEditCommand::PASTE: |
| 818 return !read_only() && !GetClipboardText().empty(); | 818 return !read_only() && !GetClipboardText().empty(); |
| 819 default: | 819 default: |
| 820 return Textfield::IsTextEditCommandEnabled(command); | 820 return Textfield::IsTextEditCommandEnabled(command); |
| 821 } | 821 } |
| 822 } | 822 } |
| 823 | 823 |
| 824 void OmniboxViewViews::ExecuteTextEditCommand(ui::TextEditCommand command) { | 824 bool OmniboxViewViews::ExecuteTextEditCommandImpl(ui::TextEditCommand command) { |
| 825 // In the base class, touch text selection is deactivated when a command is | |
| 826 // executed. Since we are not always calling the base class implementation | |
| 827 // here, we need to deactivate touch text selection here, too. | |
| 828 DestroyTouchSelection(); | |
| 829 | |
| 830 if (!IsTextEditCommandEnabled(command)) | |
| 831 return; | |
| 832 | |
| 833 switch (command) { | 825 switch (command) { |
| 834 case ui::TextEditCommand::MOVE_UP: | 826 case ui::TextEditCommand::MOVE_UP: |
| 835 model()->OnUpOrDownKeyPressed(-1); | 827 model()->OnUpOrDownKeyPressed(-1); |
| 828 return false; | |
|
sadrul
2017/03/09 01:47:38
I feel like this should be true? (also, below for
yiyix
2017/03/09 02:45:33
Only OnPaste calls OnAfterPossibleChange, that's w
| |
| 836 break; | 829 break; |
|
sadrul
2017/03/09 01:47:38
You should remove the break; (here and below)
yiyix
2017/03/09 02:45:33
No break needed after return. Right. I will watch
| |
| 837 case ui::TextEditCommand::MOVE_DOWN: | 830 case ui::TextEditCommand::MOVE_DOWN: |
| 838 model()->OnUpOrDownKeyPressed(1); | 831 model()->OnUpOrDownKeyPressed(1); |
| 832 return false; | |
| 839 break; | 833 break; |
| 840 case ui::TextEditCommand::PASTE: | 834 case ui::TextEditCommand::PASTE: |
| 841 OnPaste(); | 835 OnPaste(); |
| 836 return true; | |
| 842 break; | 837 break; |
| 843 default: | 838 default: |
| 844 Textfield::ExecuteTextEditCommand(command); | 839 return Textfield::ExecuteTextEditCommandImpl(command); |
| 845 break; | 840 break; |
| 846 } | 841 } |
| 847 } | 842 } |
| 848 | 843 |
| 849 #if defined(OS_CHROMEOS) | 844 #if defined(OS_CHROMEOS) |
| 850 void OmniboxViewViews::CandidateWindowOpened( | 845 void OmniboxViewViews::CandidateWindowOpened( |
| 851 chromeos::input_method::InputMethodManager* manager) { | 846 chromeos::input_method::InputMethodManager* manager) { |
| 852 ime_candidate_window_open_ = true; | 847 ime_candidate_window_open_ = true; |
| 853 } | 848 } |
| 854 | 849 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1049 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1044 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1050 | 1045 |
| 1051 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1046 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1052 | 1047 |
| 1053 // Minor note: We use IDC_ for command id here while the underlying textfield | 1048 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1054 // is using IDS_ for all its command ids. This is because views cannot depend | 1049 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1055 // on IDC_ for now. | 1050 // on IDC_ for now. |
| 1056 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1051 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1057 IDS_EDIT_SEARCH_ENGINES); | 1052 IDS_EDIT_SEARCH_ENGINES); |
| 1058 } | 1053 } |
| OLD | NEW |