Chromium Code Reviews| Index: ui/views/controls/textfield/textfield.cc |
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
| index 66291060b17b615696ef37256aa8b715e2df19f2..4aedd4a9dd0936cfc8fb350b0dc7540a02299f64 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -6,15 +6,18 @@ |
| #include <string> |
| +#include "base/command_line.h" |
| #include "base/string_util.h" |
| #include "base/utf_string_conversions.h" |
| #include "ui/base/accessibility/accessible_view_state.h" |
| #include "ui/base/ime/text_input_type.h" |
| #include "ui/base/keycodes/keyboard_codes.h" |
| #include "ui/base/range/range.h" |
| +#include "ui/base/ui_base_switches.h" |
| #include "ui/gfx/insets.h" |
| #include "ui/gfx/selection_model.h" |
| #include "ui/views/controls/native/native_view_host.h" |
| +#include "ui/views/controls/textfield/native_textfield_views.h" |
| #include "ui/views/controls/textfield/native_textfield_wrapper.h" |
| #include "ui/views/controls/textfield/textfield_controller.h" |
| #include "ui/views/widget/widget.h" |
| @@ -23,7 +26,6 @@ |
| #include "base/win/win_util.h" |
| // TODO(beng): this should be removed when the OS_WIN hack from |
| // ViewHierarchyChanged is removed. |
| -#include "ui/views/controls/textfield/native_textfield_views.h" |
| #include "ui/views/controls/textfield/native_textfield_win.h" |
| #endif |
| @@ -32,6 +34,13 @@ namespace { |
| // Default placeholder text color. |
| const SkColor kDefaultPlaceholderTextColor = SK_ColorLTGRAY; |
| +#if defined(OS_WIN) && !defined(USE_AURA) |
| +bool UseNativeTextfieldViews() { |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + return command_line->HasSwitch(switches::kEnableViewsTextfield); |
| +} |
| +#endif |
| + |
| } // namespace |
| namespace views { |
| @@ -367,8 +376,7 @@ void Textfield::AboutToRequestFocusFromTabTraversal(bool reverse) { |
| bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { |
| // TODO(hamaji): Figure out which keyboard combinations we need to add here, |
| // similar to LocationBarView::SkipDefaultKeyEventProcessing. |
| - ui::KeyboardCode key = e.key_code(); |
| - if (key == ui::VKEY_BACK) |
| + if (e.key_code() == ui::VKEY_BACK) |
| return true; // We'll handle BackSpace ourselves. |
| #if defined(USE_AURA) |
| @@ -376,9 +384,7 @@ bool Textfield::SkipDefaultKeyEventProcessing(const KeyEvent& e) { |
| #elif defined(OS_WIN) |
| // We don't translate accelerators for ALT + NumPad digit on Windows, they are |
| // used for entering special characters. We do translate alt-home. |
| - if (e.IsAltDown() && (key != ui::VKEY_HOME) && |
| - NativeTextfieldWin::IsNumPadDigit(key, |
| - (e.flags() & ui::EF_EXTENDED) != 0)) |
| + if (e.IsAltDown() && (e.key_code() != ui::VKEY_HOME) && e.IsNumPadDigit()) |
| return true; |
| #endif |
| return false; |
| @@ -454,12 +460,13 @@ void Textfield::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
| UpdateAllProperties(); |
| #if defined(OS_WIN) && !defined(USE_AURA) |
| - // TODO(beng): remove this once NativeTextfieldWin subclasses |
| + // TODO(beng): Remove this once NativeTextfieldWin subclasses |
| // NativeControlWin. This is currently called to perform post-AddChildView |
| // initialization for the wrapper. |
| // |
| // Remove the include for native_textfield_win.h above when you fix this. |
| - static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); |
| + if (!UseNativeTextfieldViews()) |
| + static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); |
| #endif |
| } |
| } |
| @@ -468,4 +475,17 @@ std::string Textfield::GetClassName() const { |
| return kViewClassName; |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// NativeTextfieldWrapper, public: |
| + |
| +// static |
| +NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
| + Textfield* field) { |
| +#if defined(OS_WIN) && !defined(USE_AURA) |
| + if (!UseNativeTextfieldViews()) |
|
tfarina
2012/06/08 00:15:00
nit: what happens if this is true? Is that even po
msw
2012/06/08 00:23:49
I'm not sure I understand what you're asking. Both
|
| + return new NativeTextfieldWin(field); |
| +#endif |
| + return new NativeTextfieldViews(field); |
| +} |
| + |
| } // namespace views |