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

Unified Diff: ui/views/controls/label.h

Issue 222033002: Add an 'obscured' flag to views::Label. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 6 years, 9 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 | « no previous file | ui/views/controls/label.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.h
diff --git a/ui/views/controls/label.h b/ui/views/controls/label.h
index 463afac9d40d5c6cbe9741b92ecded872de09852..0964b036c511fd8c15f27d3e96a37213aebd278c 100644
--- a/ui/views/controls/label.h
+++ b/ui/views/controls/label.h
@@ -132,6 +132,14 @@ class VIEWS_EXPORT Label : public View {
bool is_multi_line() const { return is_multi_line_; }
void SetMultiLine(bool multi_line);
+ // Get or set if the label text should be obscured before rendering (e.g.
+ // should "Password!" display as "*********"); default is false.
+ bool is_obscured() const { return is_obscured_; }
+ void SetObscured(bool obscured);
+
+ // Get the text as displayed to the user, respecting the 'obscured' flag.
+ const base::string16& layout_text() const { return layout_text_; }
+
// Sets whether the label text can be split on words.
// Default is false. This only works when is_multi_line is true.
void SetAllowCharacterBreak(bool allow_character_break);
@@ -213,6 +221,10 @@ class VIEWS_EXPORT Label : public View {
// Calls ComputeDrawStringFlags().
FRIEND_TEST_ALL_PREFIXES(LabelTest, DisableSubpixelRendering);
+ // Sets both |text_| and |layout_text_| to appropriate values, taking
+ // the label's 'obscured' status into account.
+ void SetTextInternal(const base::string16& text);
+
void Init(const base::string16& text, const gfx::FontList& font_list);
void RecalculateColors();
@@ -239,6 +251,7 @@ class VIEWS_EXPORT Label : public View {
bool ShouldShowDefaultTooltip() const;
base::string16 text_;
+ base::string16 layout_text_;
gfx::FontList font_list_;
SkColor requested_enabled_color_;
SkColor actual_enabled_color_;
@@ -256,6 +269,7 @@ class VIEWS_EXPORT Label : public View {
mutable bool text_size_valid_;
int line_height_;
bool is_multi_line_;
+ bool is_obscured_;
bool allow_character_break_;
ElideBehavior elide_behavior_;
gfx::HorizontalAlignment horizontal_alignment_;
« no previous file with comments | « no previous file | ui/views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698