Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 10535046: Add Windows commandline switch --enable-views-textfield. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/textfield/native_textfield_win.cc ('k') | ui/views/events/event.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/string_util.h" 10 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "ui/base/accessibility/accessible_view_state.h" 12 #include "ui/base/accessibility/accessible_view_state.h"
12 #include "ui/base/ime/text_input_type.h" 13 #include "ui/base/ime/text_input_type.h"
13 #include "ui/base/keycodes/keyboard_codes.h" 14 #include "ui/base/keycodes/keyboard_codes.h"
14 #include "ui/base/range/range.h" 15 #include "ui/base/range/range.h"
16 #include "ui/base/ui_base_switches.h"
15 #include "ui/gfx/insets.h" 17 #include "ui/gfx/insets.h"
16 #include "ui/gfx/selection_model.h" 18 #include "ui/gfx/selection_model.h"
17 #include "ui/views/controls/native/native_view_host.h" 19 #include "ui/views/controls/native/native_view_host.h"
20 #include "ui/views/controls/textfield/native_textfield_views.h"
18 #include "ui/views/controls/textfield/native_textfield_wrapper.h" 21 #include "ui/views/controls/textfield/native_textfield_wrapper.h"
19 #include "ui/views/controls/textfield/textfield_controller.h" 22 #include "ui/views/controls/textfield/textfield_controller.h"
20 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
21 24
22 #if defined(OS_WIN) 25 #if defined(OS_WIN)
23 #include "base/win/win_util.h" 26 #include "base/win/win_util.h"
24 // TODO(beng): this should be removed when the OS_WIN hack from 27 // TODO(beng): this should be removed when the OS_WIN hack from
25 // ViewHierarchyChanged is removed. 28 // ViewHierarchyChanged is removed.
26 #include "ui/views/controls/textfield/native_textfield_views.h"
27 #include "ui/views/controls/textfield/native_textfield_win.h" 29 #include "ui/views/controls/textfield/native_textfield_win.h"
28 #endif 30 #endif
29 31
30 namespace { 32 namespace {
31 33
32 // Default placeholder text color. 34 // Default placeholder text color.
33 const SkColor kDefaultPlaceholderTextColor = SK_ColorLTGRAY; 35 const SkColor kDefaultPlaceholderTextColor = SK_ColorLTGRAY;
34 36
37 #if defined(OS_WIN) && !defined(USE_AURA)
38 bool UseNativeTextfieldViews() {
39 CommandLine* command_line = CommandLine::ForCurrentProcess();
40 return command_line->HasSwitch(switches::kEnableViewsTextfield);
41 }
42 #endif
43
35 } // namespace 44 } // namespace
36 45
37 namespace views { 46 namespace views {
38 47
39 // static 48 // static
40 const char Textfield::kViewClassName[] = "views/Textfield"; 49 const char Textfield::kViewClassName[] = "views/Textfield";
41 50
42 ///////////////////////////////////////////////////////////////////////////// 51 /////////////////////////////////////////////////////////////////////////////
43 // Textfield 52 // Textfield
44 53
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 456
448 // The native wrapper's lifetime will be managed by the view hierarchy after 457 // The native wrapper's lifetime will be managed by the view hierarchy after
449 // we call AddChildView. 458 // we call AddChildView.
450 native_wrapper_ = NativeTextfieldWrapper::CreateWrapper(this); 459 native_wrapper_ = NativeTextfieldWrapper::CreateWrapper(this);
451 AddChildView(native_wrapper_->GetView()); 460 AddChildView(native_wrapper_->GetView());
452 // TODO(beng): Move this initialization to NativeTextfieldWin once it 461 // TODO(beng): Move this initialization to NativeTextfieldWin once it
453 // subclasses NativeControlWin. 462 // subclasses NativeControlWin.
454 UpdateAllProperties(); 463 UpdateAllProperties();
455 464
456 #if defined(OS_WIN) && !defined(USE_AURA) 465 #if defined(OS_WIN) && !defined(USE_AURA)
457 // TODO(beng): remove this once NativeTextfieldWin subclasses 466 // TODO(beng): Remove this once NativeTextfieldWin subclasses
458 // NativeControlWin. This is currently called to perform post-AddChildView 467 // NativeControlWin. This is currently called to perform post-AddChildView
459 // initialization for the wrapper. 468 // initialization for the wrapper.
460 // 469 //
461 // Remove the include for native_textfield_win.h above when you fix this. 470 // Remove the include for native_textfield_win.h above when you fix this.
462 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack(); 471 if (!UseNativeTextfieldViews())
472 static_cast<NativeTextfieldWin*>(native_wrapper_)->AttachHack();
463 #endif 473 #endif
464 } 474 }
465 } 475 }
466 476
467 std::string Textfield::GetClassName() const { 477 std::string Textfield::GetClassName() const {
468 return kViewClassName; 478 return kViewClassName;
469 } 479 }
470 480
481 ////////////////////////////////////////////////////////////////////////////////
482 // NativeTextfieldWrapper, public:
483
484 // static
485 NativeTextfieldWrapper* NativeTextfieldWrapper::CreateWrapper(
486 Textfield* field) {
487 #if defined(OS_WIN) && !defined(USE_AURA)
488 if (!UseNativeTextfieldViews())
489 return new NativeTextfieldWin(field);
490 #endif
491 return new NativeTextfieldViews(field);
492 }
493
471 } // namespace views 494 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/native_textfield_win.cc ('k') | ui/views/events/event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698