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

Side by Side Diff: chrome/browser/ui/views/autofill/decorated_textfield.h

Issue 55243005: Implement learn more bubble on views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_
6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_ 6 #define CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h"
9 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
10 #include "ui/gfx/image/image.h" 11 #include "ui/gfx/image/image.h"
11 #include "ui/views/controls/textfield/textfield.h" 12 #include "ui/views/controls/textfield/textfield.h"
12 #include "ui/views/controls/textfield/textfield.h" 13 #include "ui/views/controls/textfield/textfield.h"
13 14
14 namespace views { 15 namespace views {
15 class FocusableBorder; 16 class FocusableBorder;
16 class TextfieldController; 17 class TextfieldController;
17 } 18 }
18 19
19 namespace autofill { 20 namespace autofill {
20 21
22 class LearnMoreIconDelegate;
23
21 // A class which holds a textfield and draws extra stuff on top, like 24 // A class which holds a textfield and draws extra stuff on top, like
22 // invalid content indications. 25 // invalid content indications.
23 class DecoratedTextfield : public views::Textfield { 26 class DecoratedTextfield : public views::Textfield {
24 public: 27 public:
25 static const char kViewClassName[]; 28 static const char kViewClassName[];
26 29
27 DecoratedTextfield(const base::string16& default_value, 30 DecoratedTextfield(const base::string16& default_value,
28 const base::string16& placeholder, 31 const base::string16& placeholder,
29 views::TextfieldController* controller); 32 views::TextfieldController* controller);
30 virtual ~DecoratedTextfield(); 33 virtual ~DecoratedTextfield();
31 34
32 // Sets whether to indicate the textfield has invalid content. 35 // Sets whether to indicate the textfield has invalid content.
33 void SetInvalid(bool invalid); 36 void SetInvalid(bool invalid);
34 bool invalid() const { return invalid_; } 37 bool invalid() const { return invalid_; }
35 38
36 // See docs for |editable_|. 39 // See docs for |editable_|.
37 void SetEditable(bool editable); 40 void SetEditable(bool editable);
38 bool editable() const { return editable_; } 41 bool editable() const { return editable_; }
39 42
40 // Sets the icon to be displayed inside the textfield at the end of the 43 // Sets the icon to be displayed inside the textfield at the end of the
41 // text. 44 // text.
42 void SetIcon(const gfx::Image& icon); 45 void SetIcon(const gfx::Image& icon);
43 46
44 // Sets a tooltip for this field. This will override the icon set with 47 // Sets a learn more icon for this field. This will override the icon set with
45 // SetIcon(), if any, and will be overridden by future calls to SetIcon(). 48 // SetIcon(), if any, and will be overridden by future calls to SetIcon().
46 void SetTooltipIcon(const base::string16& text); 49 void SetLearnMoreIcon(const base::string16& text,
50 const base::WeakPtr<LearnMoreIconDelegate>& delegate);
47 51
48 // views::Textfield implementation. 52 // views::Textfield implementation.
49 virtual base::string16 GetPlaceholderText() const OVERRIDE; 53 virtual base::string16 GetPlaceholderText() const OVERRIDE;
50 54
51 // views::View implementation. 55 // views::View implementation.
52 virtual const char* GetClassName() const OVERRIDE; 56 virtual const char* GetClassName() const OVERRIDE;
53 virtual gfx::Size GetPreferredSize() OVERRIDE; 57 virtual gfx::Size GetPreferredSize() OVERRIDE;
54 virtual void Layout() OVERRIDE; 58 virtual void Layout() OVERRIDE;
55 virtual views::View* GetEventHandlerForPoint(const gfx::Point& point) 59 virtual views::View* GetEventHandlerForPoint(const gfx::Point& point)
56 OVERRIDE; 60 OVERRIDE;
57 virtual void OnFocus() OVERRIDE; 61 virtual void OnFocus() OVERRIDE;
58 virtual void OnBlur() OVERRIDE; 62 virtual void OnBlur() OVERRIDE;
59 63
60 private: 64 private:
61 FRIEND_TEST_ALL_PREFIXES(DecoratedTextfieldTest, HeightMatchesButton); 65 FRIEND_TEST_ALL_PREFIXES(DecoratedTextfieldTest, HeightMatchesButton);
62 66
63 // Updates the background of |this| after it may have changed. This is 67 // Updates the background of |this| after it may have changed. This is
64 // necessary for the sake of the padding around the native textfield. 68 // necessary for the sake of the padding around the native textfield.
65 void UpdateBackground(); 69 void UpdateBackground();
66 70
67 // Called to update the layout after SetIcon or SetTooltipIcon has been 71 // Called to update the layout after SetIcon or SetLearnMoreIcon has been
68 // called. 72 // called.
69 void IconChanged(); 73 void IconChanged();
70 74
71 // This number corresponds to the number of pixels in the images that 75 // This number corresponds to the number of pixels in the images that
72 // are used to draw a views button which are above or below the actual border. 76 // are used to draw a views button which are above or below the actual border.
73 // This number is encoded in the button assets themselves, so there's no other 77 // This number is encoded in the button assets themselves, so there's no other
74 // way to get it than to hardcode it here. 78 // way to get it than to hardcode it here.
75 static const int kMagicInsetNumber; 79 static const int kMagicInsetNumber;
76 80
77 // We draw the border. 81 // We draw the border.
(...skipping 10 matching lines...) Expand all
88 // pieces of the textfield disappear (border, background, icon, placeholder 92 // pieces of the textfield disappear (border, background, icon, placeholder
89 // text) and it can't receive focus. 93 // text) and it can't receive focus.
90 bool editable_; 94 bool editable_;
91 95
92 DISALLOW_COPY_AND_ASSIGN(DecoratedTextfield); 96 DISALLOW_COPY_AND_ASSIGN(DecoratedTextfield);
93 }; 97 };
94 98
95 } // namespace autofill 99 } // namespace autofill
96 100
97 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_ 101 #endif // CHROME_BROWSER_UI_VIEWS_AUTOFILL_DECORATED_TEXTFIELD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698