summaryrefslogtreecommitdiffstats
path: root/views/controls
diff options
context:
space:
mode:
authorchocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 17:15:24 +0000
committerchocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 17:15:24 +0000
commit64dc46a5c7f4f2a9f4436e91d86b33fd64898148 (patch)
tree4bb0276e40f91bcc26453b726adbc116d436250c /views/controls
parent13c04b4deda5816be724ba8038cc4404db3b5fcf (diff)
downloadchromium_src-64dc46a5c7f4f2a9f4436e91d86b33fd64898148.zip
chromium_src-64dc46a5c7f4f2a9f4436e91d86b33fd64898148.tar.gz
chromium_src-64dc46a5c7f4f2a9f4436e91d86b33fd64898148.tar.bz2
Fix bug with native text field where if there's a visibility change, the native control gets recreated without updating the properties. For chromeos login, the password field becomes a normal textfield.
BUG=chromeos:2023 TEST=during login, we should not show the password in the clear. Review URL: http://codereview.chromium.org/1076008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42229 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls')
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc1
-rw-r--r--views/controls/textfield/textfield.cc35
-rw-r--r--views/controls/textfield/textfield.h8
3 files changed, 18 insertions, 26 deletions
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index 0dac9a4..4aef06f 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -243,6 +243,7 @@ void NativeTextfieldGtk::CreateNativeControl() {
NativeControlCreated(gtk_entry_new());
gtk_entry_set_invisible_char(GTK_ENTRY(native_view()),
static_cast<gunichar>(kPasswordChar));
+ textfield_->UpdateAllProperties();
}
void NativeTextfieldGtk::NativeControlCreated(GtkWidget* widget) {
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 8f6486f..d2e2fae 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -183,6 +183,18 @@ void Textfield::RemoveBorder() {
native_wrapper_->UpdateBorder();
}
+void Textfield::UpdateAllProperties() {
+ if (native_wrapper_) {
+ native_wrapper_->UpdateText();
+ native_wrapper_->UpdateTextColor();
+ native_wrapper_->UpdateBackgroundColor();
+ native_wrapper_->UpdateReadOnly();
+ native_wrapper_->UpdateFont();
+ native_wrapper_->UpdateEnabled();
+ native_wrapper_->UpdateBorder();
+ native_wrapper_->UpdateIsPassword();
+ }
+}
void Textfield::SyncText() {
if (native_wrapper_)
@@ -299,14 +311,7 @@ void Textfield::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
AddChildView(native_wrapper_->GetView());
// TODO(beng): Move this initialization to NativeTextfieldWin once it
// subclasses NativeControlWin.
- native_wrapper_->UpdateText();
- native_wrapper_->UpdateTextColor();
- native_wrapper_->UpdateBackgroundColor();
- native_wrapper_->UpdateReadOnly();
- native_wrapper_->UpdateFont();
- native_wrapper_->UpdateEnabled();
- native_wrapper_->UpdateBorder();
- native_wrapper_->UpdateIsPassword();
+ UpdateAllProperties();
#if defined(OS_WIN)
// TODO(beng): remove this once NativeTextfieldWin subclasses
@@ -324,20 +329,6 @@ std::string Textfield::GetClassName() const {
return kViewClassName;
}
-NativeTextfieldWrapper* Textfield::CreateWrapper() {
- NativeTextfieldWrapper* native_wrapper =
- NativeTextfieldWrapper::CreateWrapper(this);
-
- native_wrapper->UpdateText();
- native_wrapper->UpdateBackgroundColor();
- native_wrapper->UpdateReadOnly();
- native_wrapper->UpdateFont();
- native_wrapper->UpdateEnabled();
- native_wrapper->UpdateBorder();
-
- return native_wrapper;
-}
-
base::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const {
#if defined(OS_WIN)
return static_cast<base::KeyboardCode>(key_);
diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h
index 7b9c393..71bdf49 100644
--- a/views/controls/textfield/textfield.h
+++ b/views/controls/textfield/textfield.h
@@ -184,6 +184,10 @@ class Textfield : public View {
bool draw_border() const { return draw_border_; }
void RemoveBorder();
+ // Updates all properties on the textfield. This is invoked internally.
+ // Users of Textfield never need to invoke this directly.
+ void UpdateAllProperties();
+
// Invoked by the edit control when the value changes. This method set
// the text_ member variable to the value contained in edit control.
// This is important because the edit control can be replaced if it has
@@ -216,10 +220,6 @@ class Textfield : public View {
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
virtual std::string GetClassName() const;
- // Creates a new native wrapper properly initialized and returns it. Ownership
- // is passed to the caller.
- NativeTextfieldWrapper* CreateWrapper();
-
// The object that actually implements the native text field.
NativeTextfieldWrapper* native_wrapper_;