summaryrefslogtreecommitdiffstats
path: root/views/controls/textfield/textfield.cc
diff options
context:
space:
mode:
authorbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 14:55:13 +0000
committerbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-06 14:55:13 +0000
commita9a0417e2b621c778b0f1a8df7b424a32b284041 (patch)
tree1caeb4d3bf2c6708a8340f29924c8dbe61661973 /views/controls/textfield/textfield.cc
parentbda863e986f517e04fbec41cf6034d483fc03f68 (diff)
downloadchromium_src-a9a0417e2b621c778b0f1a8df7b424a32b284041.zip
chromium_src-a9a0417e2b621c778b0f1a8df7b424a32b284041.tar.gz
chromium_src-a9a0417e2b621c778b0f1a8df7b424a32b284041.tar.bz2
Identify the omnibox as a URL field.
Although the omnibox is not strictly a URL field, for the purposes of TOUCH_UI, we would prefer to show the URL-friendly keyboard for the omnibox instead of a plain-text keyboard. BUG=none TEST=updated unittest Review URL: http://codereview.chromium.org/7826039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/textfield/textfield.cc')
-rw-r--r--views/controls/textfield/textfield.cc30
1 files changed, 26 insertions, 4 deletions
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 8061126..c422a2c 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,31 @@ 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 {
+ if (read_only() || !IsEnabled())
+ return ui::TEXT_INPUT_TYPE_NONE;
+ 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_)