Index: ui/views/controls/textfield/textfield.cc |
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
index 74395f29eea8f5acdb33f177af363fe990b83197..7daddf30b27660a87ee92e02aa703a504c7566b2 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -73,10 +73,9 @@ Textfield::Textfield(StyleFlags style) |
initialized_(false), |
horizontal_margins_were_set_(false), |
vertical_margins_were_set_(false), |
- text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) { |
+ text_input_type_(style & STYLE_PASSWORD ? |
+ ui::TEXT_INPUT_TYPE_PASSWORD : ui::TEXT_INPUT_TYPE_TEXT) { |
set_focusable(true); |
- if (IsPassword()) |
- SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
} |
Textfield::~Textfield() { |
@@ -99,23 +98,6 @@ void Textfield::SetReadOnly(bool read_only) { |
} |
} |
-bool Textfield::IsPassword() const { |
- return style_ & STYLE_PASSWORD; |
-} |
- |
-void Textfield::SetPassword(bool password) { |
- if (password) { |
- style_ = static_cast<StyleFlags>(style_ | STYLE_PASSWORD); |
- SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
- } else { |
- style_ = static_cast<StyleFlags>(style_ & ~STYLE_PASSWORD); |
- SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT); |
- } |
- if (native_wrapper_) |
- native_wrapper_->UpdateIsPassword(); |
-} |
- |
- |
ui::TextInputType Textfield::GetTextInputType() const { |
if (read_only() || !IsEnabled()) |
return ui::TEXT_INPUT_TYPE_NONE; |
@@ -123,10 +105,14 @@ ui::TextInputType Textfield::GetTextInputType() const { |
} |
void Textfield::SetTextInputType(ui::TextInputType type) { |
+ bool was_password = IsPassword(); |
+ bool will_be_password = type == ui::TEXT_INPUT_TYPE_PASSWORD; |
text_input_type_ = type; |
- bool should_be_password = type == ui::TEXT_INPUT_TYPE_PASSWORD; |
- if (IsPassword() != should_be_password) |
- SetPassword(should_be_password); |
+ if (was_password != will_be_password) { |
+ style_ = static_cast<StyleFlags>(style_ ^ STYLE_PASSWORD); |
+ if (native_wrapper_) |
+ native_wrapper_->UpdateIsPassword(); |
+ } |
} |
void Textfield::SetText(const string16& text) { |