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

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

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: Textfield(STYLE_OBSCURED) sets TEXT_INPUT_TYPE_PASSWORD Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
7 #pragma once 7 #pragma once
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 10
(...skipping 29 matching lines...) Expand all
40 class TextfieldController; 40 class TextfieldController;
41 41
42 // This class implements a View that wraps a native text (edit) field. 42 // This class implements a View that wraps a native text (edit) field.
43 class VIEWS_EXPORT Textfield : public View { 43 class VIEWS_EXPORT Textfield : public View {
44 public: 44 public:
45 // The button's class name. 45 // The button's class name.
46 static const char kViewClassName[]; 46 static const char kViewClassName[];
47 47
48 enum StyleFlags { 48 enum StyleFlags {
49 STYLE_DEFAULT = 0, 49 STYLE_DEFAULT = 0,
50 STYLE_PASSWORD = 1 << 0, 50 STYLE_OBSCURED = 1 << 0,
51 STYLE_LOWERCASE = 1 << 1 51 STYLE_LOWERCASE = 1 << 1
52 }; 52 };
53 53
54 // The initial text input type is set to TEXT_INPUT_TYPE_PASSWORD
55 // if STYLE_OBSCURED is set in |style|. Otherwise it is set to
56 // TEXT_INPUT_TYPE_TEXT.
54 Textfield(); 57 Textfield();
55 explicit Textfield(StyleFlags style); 58 explicit Textfield(StyleFlags style);
benrg 2011/12/07 19:17:47 Is it worth adding TextInputType as a second argum
56 virtual ~Textfield(); 59 virtual ~Textfield();
57 60
58 // TextfieldController accessors 61 // TextfieldController accessors
59 void SetController(TextfieldController* controller); 62 void SetController(TextfieldController* controller);
60 TextfieldController* GetController() const; 63 TextfieldController* GetController() const;
61 64
62 // Gets/Sets whether or not the Textfield is read-only. 65 // Gets/Sets whether or not the Textfield is read-only.
63 bool read_only() const { return read_only_; } 66 bool read_only() const { return read_only_; }
64 void SetReadOnly(bool read_only); 67 void SetReadOnly(bool read_only);
65 68
66 // Gets/Sets whether or not this Textfield is a password field. 69 // Gets/sets the STYLE_OBSCURED bit, controlling whether characters in this
67 // TODO(bryeung): Currently this is only used in 70 // Textfield are displayed as asterisks/bullets. This does not affect the
71 // text input type.
72 // TODO(bryeung): Currently SetObscured is only used in
68 // chrome/browser/chromeos/options/wifi_config_view.cc, which is being 73 // chrome/browser/chromeos/options/wifi_config_view.cc, which is being
69 // converted to WebUI. Please remove this when that happens. 74 // converted to WebUI. Please remove it when that happens.
70 bool IsPassword() const; 75 bool IsObscured() const;
71 void SetPassword(bool password); 76 void SetObscured(bool obscured);
72 77
73 // Gets/Sets the input type of this textfield. 78 // Gets/Sets the input type of this textfield. TEXT_INPUT_TYPE_PASSWORD
79 // disables the virtual keyboard and IME, but does not hide the text (use
bryeung 2011/12/07 19:33:15 it does not disable the virtual keyboard, just the
benrg 2011/12/07 21:33:20 Changed. I misinterpreted Peng's comment.
80 // STYLE_OBSCURED for that).
74 ui::TextInputType GetTextInputType() const; 81 ui::TextInputType GetTextInputType() const;
75 void SetTextInputType(ui::TextInputType type); 82 void SetTextInputType(ui::TextInputType type);
76 83
77 // Gets/Sets the text currently displayed in the Textfield. 84 // Gets/Sets the text currently displayed in the Textfield.
78 const string16& text() const { return text_; } 85 const string16& text() const { return text_; }
79 86
80 // Sets the text currently displayed in the Textfield. This doesn't 87 // Sets the text currently displayed in the Textfield. This doesn't
81 // change the cursor position if the current cursor is within the 88 // change the cursor position if the current cursor is within the
82 // new text's range, or moves the cursor to the end if the cursor is 89 // new text's range, or moves the cursor to the end if the cursor is
83 // out of the new text's range. 90 // out of the new text's range.
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 313
307 // The input type of this text field. 314 // The input type of this text field.
308 ui::TextInputType text_input_type_; 315 ui::TextInputType text_input_type_;
309 316
310 DISALLOW_COPY_AND_ASSIGN(Textfield); 317 DISALLOW_COPY_AND_ASSIGN(Textfield);
311 }; 318 };
312 319
313 } // namespace views 320 } // namespace views
314 321
315 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ 322 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698