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

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

Issue 8748001: Make text input type and password visibility bit independent in Textfield (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 10 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
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 #if defined(TOOLKIT_USES_GTK) 7 #if defined(TOOLKIT_USES_GTK)
8 #include <gdk/gdkkeysyms.h> 8 #include <gdk/gdkkeysyms.h>
9 #endif 9 #endif
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 native_wrapper_->UpdateTextColor(); 98 native_wrapper_->UpdateTextColor();
99 native_wrapper_->UpdateBackgroundColor(); 99 native_wrapper_->UpdateBackgroundColor();
100 } 100 }
101 } 101 }
102 102
103 bool Textfield::IsObscured() const { 103 bool Textfield::IsObscured() const {
104 return style_ & STYLE_OBSCURED; 104 return style_ & STYLE_OBSCURED;
105 } 105 }
106 106
107 void Textfield::SetObscured(bool obscured) { 107 void Textfield::SetObscured(bool obscured) {
108 if (obscured) { 108 if (obscured != IsObscured()) {
109 style_ = static_cast<StyleFlags>(style_ | STYLE_OBSCURED); 109 style_ = static_cast<StyleFlags>(style_ ^ STYLE_OBSCURED);
110 SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 110 if (native_wrapper_)
111 } else { 111 native_wrapper_->UpdateIsObscured();
112 style_ = static_cast<StyleFlags>(style_ & ~STYLE_OBSCURED);
113 SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT);
114 } 112 }
115 if (native_wrapper_)
116 native_wrapper_->UpdateIsObscured();
117 } 113 }
118 114
119
120 ui::TextInputType Textfield::GetTextInputType() const { 115 ui::TextInputType Textfield::GetTextInputType() const {
121 if (read_only() || !enabled()) 116 if (read_only() || !enabled())
122 return ui::TEXT_INPUT_TYPE_NONE; 117 return ui::TEXT_INPUT_TYPE_NONE;
123 return text_input_type_; 118 return text_input_type_;
124 } 119 }
125 120
126 void Textfield::SetTextInputType(ui::TextInputType type) { 121 void Textfield::SetTextInputType(ui::TextInputType type) {
127 text_input_type_ = type; 122 text_input_type_ = type;
128 bool should_be_obscured = type == ui::TEXT_INPUT_TYPE_PASSWORD;
129 if (IsObscured() != should_be_obscured)
130 SetObscured(should_be_obscured);
131 } 123 }
132 124
133 void Textfield::SetText(const string16& text) { 125 void Textfield::SetText(const string16& text) {
134 text_ = text; 126 text_ = text;
135 if (native_wrapper_) 127 if (native_wrapper_)
136 native_wrapper_->UpdateText(); 128 native_wrapper_->UpdateText();
137 } 129 }
138 130
139 void Textfield::AppendText(const string16& text) { 131 void Textfield::AppendText(const string16& text) {
140 text_ += text; 132 text_ += text;
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 } 440 }
449 #endif 441 #endif
450 } 442 }
451 } 443 }
452 444
453 std::string Textfield::GetClassName() const { 445 std::string Textfield::GetClassName() const {
454 return kViewClassName; 446 return kViewClassName;
455 } 447 }
456 448
457 } // namespace views 449 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698