OLD | NEW |
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_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | |
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" | 8 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" |
10 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | |
11 #include "ui/views/bubble/bubble_delegate.h" | 9 #include "ui/views/bubble/bubble_delegate.h" |
12 #include "ui/views/controls/button/button.h" | |
13 #include "ui/views/controls/combobox/combobox.h" | |
14 #include "ui/views/controls/combobox/combobox_listener.h" | |
15 #include "ui/views/controls/link.h" | |
16 #include "ui/views/controls/link_listener.h" | |
17 #include "ui/views/controls/styled_label_listener.h" | |
18 | 10 |
19 class ManagePasswordsIconView; | 11 class ManagePasswordsIconView; |
20 | 12 |
21 namespace content { | 13 namespace content { |
22 class WebContents; | 14 class WebContents; |
23 } | 15 } |
24 | 16 |
25 namespace views { | |
26 class BlueButton; | |
27 class LabelButton; | |
28 class GridLayout; | |
29 } | |
30 | |
31 // The ManagePasswordsBubbleView controls the contents of the bubble which | 17 // The ManagePasswordsBubbleView controls the contents of the bubble which |
32 // pops up when Chrome offers to save a user's password, or when the user | 18 // pops up when Chrome offers to save a user's password, or when the user |
33 // interacts with the Omnibox icon. It has two distinct states: | 19 // interacts with the Omnibox icon. It has two distinct states: |
34 // | 20 // |
35 // 1. PendingView: Offers the user the possibility of saving credentials. | 21 // 1. PendingView: Offers the user the possibility of saving credentials. |
36 // 2. ManageView: Displays the current page's saved credentials. | 22 // 2. ManageView: Displays the current page's saved credentials. |
37 // 3. BlacklistedView: Informs the user that the current page is blacklisted. | 23 // 3. BlacklistedView: Informs the user that the current page is blacklisted. |
38 // | 24 // |
39 class ManagePasswordsBubbleView : public ManagePasswordsBubble, | 25 class ManagePasswordsBubbleView : public ManagePasswordsBubble, |
40 public views::BubbleDelegateView { | 26 public views::BubbleDelegateView { |
41 public: | 27 public: |
42 // A view offering the user the ability to save credentials. Contains a | |
43 // single ManagePasswordItemView, along with a "Save Passwords" button | |
44 // and a rejection combobox. | |
45 class PendingView : public views::View, | |
46 public views::ButtonListener, | |
47 public views::ComboboxListener { | |
48 public: | |
49 explicit PendingView(ManagePasswordsBubbleView* parent); | |
50 virtual ~PendingView(); | |
51 | |
52 private: | |
53 // views::ButtonListener: | |
54 virtual void ButtonPressed(views::Button* sender, | |
55 const ui::Event& event) OVERRIDE; | |
56 | |
57 // Handles the event when the user changes an index of a combobox. | |
58 virtual void OnPerformAction(views::Combobox* source) OVERRIDE; | |
59 | |
60 ManagePasswordsBubbleView* parent_; | |
61 | |
62 views::BlueButton* save_button_; | |
63 | |
64 // The combobox doesn't take ownership of its model. If we created a | |
65 // combobox we need to ensure that we delete the model here, and because the | |
66 // combobox uses the model in it's destructor, we need to make sure we | |
67 // delete the model _after_ the combobox itself is deleted. | |
68 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_; | |
69 scoped_ptr<views::Combobox> refuse_combobox_; | |
70 }; | |
71 | |
72 // A view offering the user the ability to undo her decision to never save | |
73 // passwords for a particular site. | |
74 class ConfirmNeverView : public views::View, public views::ButtonListener { | |
75 public: | |
76 explicit ConfirmNeverView(ManagePasswordsBubbleView* parent); | |
77 virtual ~ConfirmNeverView(); | |
78 | |
79 private: | |
80 // views::ButtonListener: | |
81 virtual void ButtonPressed(views::Button* sender, | |
82 const ui::Event& event) OVERRIDE; | |
83 | |
84 ManagePasswordsBubbleView* parent_; | |
85 | |
86 views::LabelButton* confirm_button_; | |
87 views::LabelButton* undo_button_; | |
88 }; | |
89 | |
90 // A view offering the user a list of her currently saved credentials | |
91 // for the current page, along with a "Manage passwords" link and a | |
92 // "Done" button. | |
93 class ManageView : public views::View, | |
94 public views::ButtonListener, | |
95 public views::LinkListener { | |
96 public: | |
97 explicit ManageView(ManagePasswordsBubbleView* parent); | |
98 virtual ~ManageView(); | |
99 | |
100 private: | |
101 // views::ButtonListener: | |
102 virtual void ButtonPressed(views::Button* sender, | |
103 const ui::Event& event) OVERRIDE; | |
104 | |
105 // views::LinkListener: | |
106 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | |
107 | |
108 ManagePasswordsBubbleView* parent_; | |
109 | |
110 views::Link* manage_link_; | |
111 views::LabelButton* done_button_; | |
112 }; | |
113 | |
114 // A view offering the user the ability to re-enable the password manager for | |
115 // a specific site after she's decided to "never save passwords". | |
116 class BlacklistedView : public views::View, public views::ButtonListener { | |
117 public: | |
118 explicit BlacklistedView(ManagePasswordsBubbleView* parent); | |
119 virtual ~BlacklistedView(); | |
120 | |
121 private: | |
122 // views::ButtonListener: | |
123 virtual void ButtonPressed(views::Button* sender, | |
124 const ui::Event& event) OVERRIDE; | |
125 | |
126 ManagePasswordsBubbleView* parent_; | |
127 | |
128 views::BlueButton* unblacklist_button_; | |
129 views::LabelButton* done_button_; | |
130 }; | |
131 | |
132 // A view confirming to the user that a password was saved and offering a link | |
133 // to the Google account manager. | |
134 class SaveConfirmationView : public views::View, | |
135 public views::ButtonListener, | |
136 public views::StyledLabelListener { | |
137 public: | |
138 explicit SaveConfirmationView(ManagePasswordsBubbleView* parent); | |
139 virtual ~SaveConfirmationView(); | |
140 | |
141 private: | |
142 // views::ButtonListener: | |
143 virtual void ButtonPressed(views::Button* sender, | |
144 const ui::Event& event) OVERRIDE; | |
145 | |
146 // views::StyledLabelListener implementation | |
147 virtual void StyledLabelLinkClicked(const gfx::Range& range, | |
148 int event_flags) OVERRIDE; | |
149 | |
150 ManagePasswordsBubbleView* parent_; | |
151 | |
152 views::LabelButton* ok_button_; | |
153 }; | |
154 | |
155 // Shows the bubble. | 28 // Shows the bubble. |
156 static void ShowBubble(content::WebContents* web_contents, | 29 static void ShowBubble(content::WebContents* web_contents, |
157 DisplayReason reason); | 30 DisplayReason reason); |
158 | 31 |
159 // Closes any existing bubble. | 32 // Closes the existing bubble. |
160 static void CloseBubble(); | 33 static void CloseBubble(); |
161 | 34 |
162 // Makes the bubble the foreground window. | 35 // Makes the bubble the foreground window. |
163 static void ActivateBubble(); | 36 static void ActivateBubble(); |
164 | 37 |
165 // Whether the bubble is currently showing. | 38 // Whether the bubble is currently showing. |
166 static bool IsShowing(); | 39 static bool IsShowing(); |
167 | 40 |
168 // Returns a pointer to the bubble. | 41 // Returns a pointer to the bubble. |
169 static const ManagePasswordsBubbleView* manage_password_bubble() { | 42 static const ManagePasswordsBubbleView* manage_password_bubble() { |
170 return manage_passwords_bubble_; | 43 return manage_passwords_bubble_; |
171 } | 44 } |
172 | 45 |
173 const View* initially_focused_view() const { | 46 const View* initially_focused_view() const { |
174 return initially_focused_view_; | 47 return initially_focused_view_; |
175 } | 48 } |
176 | 49 |
177 bool IsFadingAway() const { | 50 bool IsFadingAway() const { |
178 return fadeout_observer_; | 51 return fadeout_observer_; |
179 } | 52 } |
180 | 53 |
181 private: | 54 private: |
| 55 class BlacklistedView; |
| 56 class ConfirmNeverView; |
| 57 class ManageView; |
| 58 class PendingView; |
| 59 class SaveConfirmationView; |
| 60 |
182 ManagePasswordsBubbleView(content::WebContents* web_contents, | 61 ManagePasswordsBubbleView(content::WebContents* web_contents, |
183 ManagePasswordsIconView* anchor_view, | 62 ManagePasswordsIconView* anchor_view, |
184 DisplayReason reason); | 63 DisplayReason reason); |
185 virtual ~ManagePasswordsBubbleView(); | 64 virtual ~ManagePasswordsBubbleView(); |
186 | 65 |
187 // If the bubble is not anchored to a view, places the bubble in the top | 66 // If the bubble is not anchored to a view, places the bubble in the top |
188 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s | 67 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s |
189 // browser window. Because the positioning is based on the size of the | 68 // browser window. Because the positioning is based on the size of the |
190 // bubble, this must be called after the bubble is created. | 69 // bubble, this must be called after the bubble is created. |
191 void AdjustForFullscreen(const gfx::Rect& screen_bounds); | 70 void AdjustForFullscreen(const gfx::Rect& screen_bounds); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 scoped_ptr<WebContentMouseHandler> mouse_handler_; | 133 scoped_ptr<WebContentMouseHandler> mouse_handler_; |
255 | 134 |
256 // A helper to get a notification when the bubble fades out completely. | 135 // A helper to get a notification when the bubble fades out completely. |
257 class FadeOutObserver; | 136 class FadeOutObserver; |
258 scoped_ptr<FadeOutObserver> fadeout_observer_; | 137 scoped_ptr<FadeOutObserver> fadeout_observer_; |
259 | 138 |
260 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); | 139 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); |
261 }; | 140 }; |
262 | 141 |
263 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 142 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
OLD | NEW |