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 "ui/views/controls/textfield/textfield.h" | 5 #include "ui/views/controls/textfield/textfield.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "ui/base/accessibility/accessible_view_state.h" | 12 #include "ui/base/accessibility/accessible_view_state.h" |
13 #include "ui/base/events/event.h" | 13 #include "ui/base/events/event.h" |
14 #include "ui/base/ime/text_input_type.h" | 14 #include "ui/base/ime/text_input_type.h" |
15 #include "ui/base/keycodes/keyboard_codes.h" | 15 #include "ui/base/keycodes/keyboard_codes.h" |
16 #include "ui/base/range/range.h" | 16 #include "ui/base/range/range.h" |
17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/base/ui_base_switches.h" | 18 #include "ui/base/ui_base_switches.h" |
19 #include "ui/base/ui_base_switches_util.h" | |
20 #include "ui/gfx/insets.h" | 19 #include "ui/gfx/insets.h" |
21 #include "ui/gfx/selection_model.h" | 20 #include "ui/gfx/selection_model.h" |
22 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
23 #include "ui/views/controls/native/native_view_host.h" | 22 #include "ui/views/controls/native/native_view_host.h" |
24 #include "ui/views/controls/textfield/native_textfield_views.h" | 23 #include "ui/views/controls/textfield/native_textfield_views.h" |
25 #include "ui/views/controls/textfield/native_textfield_wrapper.h" | 24 #include "ui/views/controls/textfield/native_textfield_wrapper.h" |
26 #include "ui/views/controls/textfield/textfield_controller.h" | 25 #include "ui/views/controls/textfield/textfield_controller.h" |
27 #include "ui/views/views_delegate.h" | 26 #include "ui/views/views_delegate.h" |
28 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
29 | 28 |
(...skipping 25 matching lines...) Expand all Loading... |
55 const char Textfield::kViewClassName[] = "Textfield"; | 54 const char Textfield::kViewClassName[] = "Textfield"; |
56 | 55 |
57 // static | 56 // static |
58 bool Textfield::IsViewsTextfieldEnabled() { | 57 bool Textfield::IsViewsTextfieldEnabled() { |
59 #if defined(OS_WIN) && !defined(USE_AURA) | 58 #if defined(OS_WIN) && !defined(USE_AURA) |
60 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 59 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
61 if (command_line->HasSwitch(switches::kDisableViewsTextfield)) | 60 if (command_line->HasSwitch(switches::kDisableViewsTextfield)) |
62 return false; | 61 return false; |
63 if (command_line->HasSwitch(switches::kEnableViewsTextfield)) | 62 if (command_line->HasSwitch(switches::kEnableViewsTextfield)) |
64 return true; | 63 return true; |
65 // The new dialog style cannot host native Windows textfield controls. | |
66 if (switches::IsNewDialogStyleEnabled()) | |
67 return true; | |
68 // Avoid native Windows Textfields if the RichEdit library is not available. | 64 // Avoid native Windows Textfields if the RichEdit library is not available. |
69 static const HMODULE loaded_msftedit_dll = LoadLibrary(L"msftedit.dll"); | 65 static const HMODULE loaded_msftedit_dll = LoadLibrary(L"msftedit.dll"); |
70 if (!loaded_msftedit_dll) | 66 if (!loaded_msftedit_dll) |
71 return true; | 67 return true; |
72 #endif | 68 #endif |
73 return true; | 69 return true; |
74 } | 70 } |
75 | 71 |
76 Textfield::Textfield() | 72 Textfield::Textfield() |
77 : native_wrapper_(NULL), | 73 : native_wrapper_(NULL), |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( | 557 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper( |
562 Textfield* field) { | 558 Textfield* field) { |
563 #if defined(OS_WIN) && !defined(USE_AURA) | 559 #if defined(OS_WIN) && !defined(USE_AURA) |
564 if (!Textfield::IsViewsTextfieldEnabled()) | 560 if (!Textfield::IsViewsTextfieldEnabled()) |
565 return new NativeTextfieldWin(field); | 561 return new NativeTextfieldWin(field); |
566 #endif | 562 #endif |
567 return new NativeTextfieldViews(field); | 563 return new NativeTextfieldViews(field); |
568 } | 564 } |
569 | 565 |
570 } // namespace views | 566 } // namespace views |
OLD | NEW |