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

Unified Diff: views/controls/textfield/textfield.cc

Issue 7826039: Identify the omnibox as a URL field. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/textfield.cc
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 8061126d257cd0d41f57000510b0c9985f041461..8c77a169208f4b1c670d1f34ab65f56b70eab61d 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -13,6 +13,7 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "ui/base/accessibility/accessible_view_state.h"
+#include "ui/base/ime/text_input_type.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/base/range/range.h"
#include "ui/gfx/insets.h"
@@ -53,7 +54,8 @@ Textfield::Textfield()
use_default_background_color_(true),
initialized_(false),
horizontal_margins_were_set_(false),
- vertical_margins_were_set_(false) {
+ vertical_margins_were_set_(false),
+ text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
set_focusable(true);
}
@@ -70,8 +72,11 @@ Textfield::Textfield(StyleFlags style)
use_default_background_color_(true),
initialized_(false),
horizontal_margins_were_set_(false),
- vertical_margins_were_set_(false) {
+ vertical_margins_were_set_(false),
+ text_input_type_(ui::TEXT_INPUT_TYPE_TEXT) {
set_focusable(true);
+ if (IsPassword())
+ SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
}
Textfield::~Textfield() {
@@ -99,14 +104,29 @@ bool Textfield::IsPassword() const {
}
void Textfield::SetPassword(bool password) {
- if (password)
+ if (password) {
style_ = static_cast<StyleFlags>(style_ | STYLE_PASSWORD);
- else
+ 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 {
sadrul 2011/09/02 23:47:37 This could be Textfield::text_input_type() const {
oshima 2011/09/03 00:26:32 Textfield and NativeTextfieldViews will be merged,
+ return text_input_type_;
+}
+
+void Textfield::SetTextInputType(ui::TextInputType type) {
+ text_input_type_ = type;
+ bool should_be_password = type == ui::TEXT_INPUT_TYPE_PASSWORD;
+ if (IsPassword() != should_be_password)
+ SetPassword(should_be_password);
+}
+
void Textfield::SetText(const string16& text) {
text_ = text;
if (native_wrapper_)
« no previous file with comments | « views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698