| 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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 return command_updater_; | 866 return command_updater_; |
| 867 } | 867 } |
| 868 | 868 |
| 869 void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { | 869 void AutocompleteEditViewWin::PasteAndGo(const std::wstring& text) { |
| 870 if (CanPasteAndGo(text)) | 870 if (CanPasteAndGo(text)) |
| 871 model_->PasteAndGo(); | 871 model_->PasteAndGo(); |
| 872 } | 872 } |
| 873 | 873 |
| 874 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( | 874 bool AutocompleteEditViewWin::SkipDefaultKeyEventProcessing( |
| 875 const views::KeyEvent& e) { | 875 const views::KeyEvent& e) { |
| 876 base::KeyboardCode key = e.GetKeyCode(); | 876 app::KeyboardCode key = e.GetKeyCode(); |
| 877 // We don't process ALT + numpad digit as accelerators, they are used for | 877 // We don't process ALT + numpad digit as accelerators, they are used for |
| 878 // entering special characters. We do translate alt-home. | 878 // entering special characters. We do translate alt-home. |
| 879 if (e.IsAltDown() && (key != base::VKEY_HOME) && | 879 if (e.IsAltDown() && (key != app::VKEY_HOME) && |
| 880 win_util::IsNumPadDigit(key, e.IsExtendedKey())) | 880 win_util::IsNumPadDigit(key, e.IsExtendedKey())) |
| 881 return true; | 881 return true; |
| 882 | 882 |
| 883 // Skip accelerators for key combinations omnibox wants to crack. This list | 883 // Skip accelerators for key combinations omnibox wants to crack. This list |
| 884 // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt | 884 // should be synced with OnKeyDownOnlyWritable() (but for tab which is dealt |
| 885 // with above in LocationBarView::SkipDefaultKeyEventProcessing). | 885 // with above in LocationBarView::SkipDefaultKeyEventProcessing). |
| 886 // | 886 // |
| 887 // We cannot return true for all keys because we still need to handle some | 887 // We cannot return true for all keys because we still need to handle some |
| 888 // accelerators (e.g., F5 for reload the page should work even when the | 888 // accelerators (e.g., F5 for reload the page should work even when the |
| 889 // Omnibox gets focused). | 889 // Omnibox gets focused). |
| 890 switch (key) { | 890 switch (key) { |
| 891 case base::VKEY_ESCAPE: { | 891 case app::VKEY_ESCAPE: { |
| 892 ScopedFreeze freeze(this, GetTextObjectModel()); | 892 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 893 return model_->OnEscapeKeyPressed(); | 893 return model_->OnEscapeKeyPressed(); |
| 894 } | 894 } |
| 895 | 895 |
| 896 case base::VKEY_RETURN: | 896 case app::VKEY_RETURN: |
| 897 return true; | 897 return true; |
| 898 | 898 |
| 899 case base::VKEY_UP: | 899 case app::VKEY_UP: |
| 900 case base::VKEY_DOWN: | 900 case app::VKEY_DOWN: |
| 901 return !e.IsAltDown(); | 901 return !e.IsAltDown(); |
| 902 | 902 |
| 903 case base::VKEY_DELETE: | 903 case app::VKEY_DELETE: |
| 904 case base::VKEY_INSERT: | 904 case app::VKEY_INSERT: |
| 905 return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); | 905 return !e.IsAltDown() && e.IsShiftDown() && !e.IsControlDown(); |
| 906 | 906 |
| 907 case base::VKEY_X: | 907 case app::VKEY_X: |
| 908 case base::VKEY_V: | 908 case app::VKEY_V: |
| 909 return !e.IsAltDown() && e.IsControlDown(); | 909 return !e.IsAltDown() && e.IsControlDown(); |
| 910 | 910 |
| 911 case base::VKEY_BACK: | 911 case app::VKEY_BACK: |
| 912 case base::VKEY_OEM_PLUS: | 912 case app::VKEY_OEM_PLUS: |
| 913 return true; | 913 return true; |
| 914 | 914 |
| 915 default: | 915 default: |
| 916 return false; | 916 return false; |
| 917 } | 917 } |
| 918 } | 918 } |
| 919 | 919 |
| 920 void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, | 920 void AutocompleteEditViewWin::HandleExternalMsg(UINT msg, |
| 921 UINT flags, | 921 UINT flags, |
| 922 const CPoint& screen_point) { | 922 const CPoint& screen_point) { |
| (...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1747 return 0; | 1747 return 0; |
| 1748 } | 1748 } |
| 1749 | 1749 |
| 1750 void AutocompleteEditViewWin::HandleKeystroke(UINT message, | 1750 void AutocompleteEditViewWin::HandleKeystroke(UINT message, |
| 1751 TCHAR key, | 1751 TCHAR key, |
| 1752 UINT repeat_count, | 1752 UINT repeat_count, |
| 1753 UINT flags) { | 1753 UINT flags) { |
| 1754 ScopedFreeze freeze(this, GetTextObjectModel()); | 1754 ScopedFreeze freeze(this, GetTextObjectModel()); |
| 1755 OnBeforePossibleChange(); | 1755 OnBeforePossibleChange(); |
| 1756 | 1756 |
| 1757 if (key == base::VKEY_HOME || key == base::VKEY_END) { | 1757 if (key == app::VKEY_HOME || key == app::VKEY_END) { |
| 1758 // DefWindowProc() might reset the keyboard layout when it receives a | 1758 // DefWindowProc() might reset the keyboard layout when it receives a |
| 1759 // keydown event for VKEY_HOME or VKEY_END. When the window was created | 1759 // keydown event for VKEY_HOME or VKEY_END. When the window was created |
| 1760 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, | 1760 // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, |
| 1761 // if the input text is pure LTR text, the layout changes to the first RTL | 1761 // if the input text is pure LTR text, the layout changes to the first RTL |
| 1762 // keyboard layout in keyboard layout queue; if the input text is | 1762 // keyboard layout in keyboard layout queue; if the input text is |
| 1763 // bidirectional text, the layout changes to the keyboard layout of the | 1763 // bidirectional text, the layout changes to the keyboard layout of the |
| 1764 // first RTL character in input text. When the window was created without | 1764 // first RTL character in input text. When the window was created without |
| 1765 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if the | 1765 // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if the |
| 1766 // input text is pure RTL text, the layout changes to English; if the input | 1766 // input text is pure RTL text, the layout changes to English; if the input |
| 1767 // text is bidirectional text, the layout changes to the keyboard layout of | 1767 // 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... |
| 2477 void AutocompleteEditViewWin::TrackMousePosition(MouseButton button, | 2477 void AutocompleteEditViewWin::TrackMousePosition(MouseButton button, |
| 2478 const CPoint& point) { | 2478 const CPoint& point) { |
| 2479 if (gaining_focus_.get()) { | 2479 if (gaining_focus_.get()) { |
| 2480 // This click is giving us focus, so we need to track how much the mouse | 2480 // This click is giving us focus, so we need to track how much the mouse |
| 2481 // moves to see if it's a drag or just a click. Clicks should select all | 2481 // moves to see if it's a drag or just a click. Clicks should select all |
| 2482 // the text. | 2482 // the text. |
| 2483 tracking_click_[button] = true; | 2483 tracking_click_[button] = true; |
| 2484 click_point_[button] = point; | 2484 click_point_[button] = point; |
| 2485 } | 2485 } |
| 2486 } | 2486 } |
| OLD | NEW |