OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_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 |
11 #include <richedit.h> | 11 #include <richedit.h> |
12 #include <textserv.h> | 12 #include <textserv.h> |
13 | 13 |
14 #include "app/clipboard/clipboard.h" | 14 #include "app/clipboard/clipboard.h" |
15 #include "app/clipboard/scoped_clipboard_writer.h" | 15 #include "app/clipboard/scoped_clipboard_writer.h" |
| 16 #include "app/keyboard_codes.h" |
16 #include "app/l10n_util.h" | 17 #include "app/l10n_util.h" |
17 #include "app/l10n_util_win.h" | 18 #include "app/l10n_util_win.h" |
18 #include "app/os_exchange_data.h" | 19 #include "app/os_exchange_data.h" |
19 #include "app/os_exchange_data_provider_win.h" | 20 #include "app/os_exchange_data_provider_win.h" |
20 #include "app/win_util.h" | 21 #include "app/win_util.h" |
21 #include "base/auto_reset.h" | 22 #include "base/auto_reset.h" |
22 #include "base/base_drag_source.h" | 23 #include "base/base_drag_source.h" |
23 #include "base/base_drop_target.h" | 24 #include "base/base_drop_target.h" |
24 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
25 #include "base/i18n/rtl.h" | 26 #include "base/i18n/rtl.h" |
26 #include "base/iat_patch.h" | 27 #include "base/iat_patch.h" |
27 #include "base/keyboard_codes.h" | |
28 #include "base/lazy_instance.h" | 28 #include "base/lazy_instance.h" |
29 #include "base/ref_counted.h" | 29 #include "base/ref_counted.h" |
30 #include "base/utf_string_conversions.h" | 30 #include "base/utf_string_conversions.h" |
31 #include "chrome/app/chrome_dll_resource.h" | 31 #include "chrome/app/chrome_dll_resource.h" |
32 #include "chrome/browser/autocomplete/autocomplete_accessibility.h" | 32 #include "chrome/browser/autocomplete/autocomplete_accessibility.h" |
33 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 33 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
34 #include "chrome/browser/autocomplete/keyword_provider.h" | 34 #include "chrome/browser/autocomplete/keyword_provider.h" |
35 #include "chrome/browser/browser_process.h" | 35 #include "chrome/browser/browser_process.h" |
36 #include "chrome/browser/command_updater.h" | 36 #include "chrome/browser/command_updater.h" |
37 #include "chrome/browser/metrics/user_metrics.h" | 37 #include "chrome/browser/metrics/user_metrics.h" |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 return command_updater_; | 870 return command_updater_; |
871 } | 871 } |
872 | 872 |
873 void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { | 873 void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { |
874 if (CanPasteAndGo(text)) | 874 if (CanPasteAndGo(text)) |
875 model_->PasteAndGo(); | 875 model_->PasteAndGo(); |
876 } | 876 } |
877 | 877 |
878 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( | 878 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( |
879 const views::KeyEvent& e) { | 879 const views::KeyEvent& e) { |
880 base::KeyboardCode key = e.GetKeyCode(); | 880 app::KeyboardCode key = e.GetKeyCode(); |
881 // We don't process ALT + numpad digit as accelerators, they are used for | 881 // We don't process ALT + numpad digit as accelerators, they are used for |
882 // entering special characters. We do translate alt-home. | 882 // entering special characters. We do translate alt-home. |
883 if (e.IsAltDown() && (key != base::VKEY_HOME) && | 883 if (e.IsAltDown() && (key != app::VKEY_HOME) && |
884 win_util::IsNumPadDigit(key, e.IsExtendedKey())) | 884 win_util::IsNumPadDigit(key, e.IsExtendedKey())) |
885 return true; | 885 return true; |
886 | 886 |
887 // Skip accelerators for key combinations omnibox wants to crack. This list | 887 // Skip accelerators for key combinations omnibox wants to crack. This list |
888 // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt | 888 // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt |
889 // with above in LocationBarView::SkipDefaultKeyEventProcessing). | 889 // with above in LocationBarView::SkipDefaultKeyEventProcessing). |
890 // | 890 // |
891 // We cannot return true for all keys because we still need to handle some | 891 // We cannot return true for all keys because we still need to handle some |
892 // accelerators (e.g., F5 for reload the page should work even when the | 892 // accelerators (e.g., F5 for reload the page should work even when the |
893 // Omnibox gets focused). | 893 // Omnibox gets focused). |
894 switch (key) { | 894 switch (key) { |
895 case base::VKEY_ESCAPE: { | 895 case app::VKEY_ESCAPE: { |
896 ScopedFreeze freeze(this, GetTextObjectModel()); | 896 ScopedFreeze freeze(this, GetTextObjectModel()); |
897 return model_->OnEscapeKeyPressed(); | 897 return model_->OnEscapeKeyPressed(); |
898 } | 898 } |
899 | 899 |
900 case base::VKEY_RETURN: | 900 case app::VKEY_RETURN: |
901 return true; | 901 return true; |
902 | 902 |
903 case base::VKEY_UP: | 903 case app::VKEY_UP: |
904 case base::VKEY_DOWN: | 904 case app::VKEY_DOWN: |
905 return !e.IsAltDown(); | 905 return !e.IsAltDown(); |
906 | 906 |
907 case base::VKEY_DELETE: | 907 case app::VKEY_DELETE: |
908 case base::VKEY_INSERT: | 908 case app::VKEY_INSERT: |
909 return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); | 909 return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); |
910 | 910 |
911 case base::VKEY_X: | 911 case app::VKEY_X: |
912 case base::VKEY_V: | 912 case app::VKEY_V: |
913 return !e.IsAltDown() && e.IsControlDown(); | 913 return !e.IsAltDown() && e.IsControlDown(); |
914 | 914 |
915 case base::VKEY_BACK: | 915 case app::VKEY_BACK: |
916 case base::VKEY_OEM_PLUS: | 916 case app::VKEY_OEM_PLUS: |
917 return true; | 917 return true; |
918 | 918 |
919 default: | 919 default: |
920 return false; | 920 return false; |
921 } | 921 } |
922 } | 922 } |
923 | 923 |
924 void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, | 924 void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, |
925 UINT flags, | 925 UINT flags, |
926 const CPoint& screen_point) { | 926 const CPoint& screen_point) { |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 return 0; | 1754 return 0; |
1755 } | 1755 } |
1756 | 1756 |
1757 void AutocompleteEditViewWin::HandleKeystroke(UINT message, | 1757 void AutocompleteEditViewWin::HandleKeystroke(UINT message, |
1758 TCHAR key, | 1758 TCHAR key, |
1759 UINT repeat_count, | 1759 UINT repeat_count, |
1760 UINT flags) { | 1760 UINT flags) { |
1761 ScopedFreeze freeze(this, GetTextObjectModel()); | 1761 ScopedFreeze freeze(this, GetTextObjectModel()); |
1762 OnBeforePossibleChange(); | 1762 OnBeforePossibleChange(); |
1763 | 1763 |
1764 if (key == base::VKEY_HOME || key == base::VKEY_END) { | 1764 if (key == app::VKEY_HOME || key == app::VKEY_END) { |
1765 // DefWindowProc() might reset the keyboard layout when it receives a | 1765 // DefWindowProc() might reset the keyboard layout when it receives a |
1766 // keydown event for VKEY_HOME or VKEY_END. When the window was created | 1766 // keydown event for VKEY_HOME or VKEY_END. When the window was created |
1767 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, | 1767 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, |
1768 // if the input text is pure LTR text, the layout changes to the first RTL | 1768 // if the input text is pure LTR text, the layout changes to the first RTL |
1769 // keyboard layout in keyboard layout queue; if the input text is | 1769 // keyboard layout in keyboard layout queue; if the input text is |
1770 // bidirectional text, the layout changes to the keyboard layout of the | 1770 // bidirectional text, the layout changes to the keyboard layout of the |
1771 // first RTL character in input text. When the window was created without | 1771 // first RTL character in input text. When the window was created without |
1772 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if the | 1772 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if the |
1773 // input text is pure RTL text, the layout changes to English; if the input | 1773 // input text is pure RTL text, the layout changes to English; if the input |
1774 // text is bidirectional text, the layout changes to the keyboard layout of | 1774 // text is bidirectional text, the layout changes to the keyboard layout of |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2484 void AutocompleteEditViewWin::TrackMousePosition(MouseButton button, | 2484 void AutocompleteEditViewWin::TrackMousePosition(MouseButton button, |
2485 const CPoint& point) { | 2485 const CPoint& point) { |
2486 if (gaining_focus_.get()) { | 2486 if (gaining_focus_.get()) { |
2487 // This click is giving us focus, so we need to track how much the mouse | 2487 // This click is giving us focus, so we need to track how much the mouse |
2488 // moves to see if it's a drag or just a click. Clicks should select all | 2488 // moves to see if it's a drag or just a click. Clicks should select all |
2489 // the text. | 2489 // the text. |
2490 tracking_click_[button] = true; | 2490 tracking_click_[button] = true; |
2491 click_point_[button] = point; | 2491 click_point_[button] = point; |
2492 } | 2492 } |
2493 } | 2493 } |
OLD | NEW |