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" | 8 #include "base/basictypes.h" |
9 #include "base/timer/timer.h" | |
10 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" |
11 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" | 10 #include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
12 #include "ui/views/bubble/bubble_delegate.h" | 11 #include "ui/views/bubble/bubble_delegate.h" |
13 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
14 #include "ui/views/controls/combobox/combobox.h" | 13 #include "ui/views/controls/combobox/combobox.h" |
15 #include "ui/views/controls/combobox/combobox_listener.h" | 14 #include "ui/views/controls/combobox/combobox_listener.h" |
16 #include "ui/views/controls/link.h" | 15 #include "ui/views/controls/link.h" |
17 #include "ui/views/controls/link_listener.h" | 16 #include "ui/views/controls/link_listener.h" |
18 #include "ui/views/controls/styled_label_listener.h" | 17 #include "ui/views/controls/styled_label_listener.h" |
19 | 18 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 167 |
169 // Returns a pointer to the bubble. | 168 // Returns a pointer to the bubble. |
170 static const ManagePasswordsBubbleView* manage_password_bubble() { | 169 static const ManagePasswordsBubbleView* manage_password_bubble() { |
171 return manage_passwords_bubble_; | 170 return manage_passwords_bubble_; |
172 } | 171 } |
173 | 172 |
174 const View* initially_focused_view() const { | 173 const View* initially_focused_view() const { |
175 return initially_focused_view_; | 174 return initially_focused_view_; |
176 } | 175 } |
177 | 176 |
178 bool IsTimerRunning() const { | 177 bool IsFadingAway() const { |
179 return timer_.IsRunning(); | 178 return fadeout_observer_; |
180 } | 179 } |
181 | 180 |
182 private: | 181 private: |
183 ManagePasswordsBubbleView(content::WebContents* web_contents, | 182 ManagePasswordsBubbleView(content::WebContents* web_contents, |
184 ManagePasswordsIconView* anchor_view, | 183 ManagePasswordsIconView* anchor_view, |
185 DisplayReason reason); | 184 DisplayReason reason); |
186 virtual ~ManagePasswordsBubbleView(); | 185 virtual ~ManagePasswordsBubbleView(); |
187 | 186 |
188 // If the bubble is not anchored to a view, places the bubble in the top | 187 // If the bubble is not anchored to a view, places the bubble in the top |
189 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s | 188 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s |
(...skipping 13 matching lines...) Expand all Loading... |
203 void NotifyNeverForThisSiteClicked(); | 202 void NotifyNeverForThisSiteClicked(); |
204 | 203 |
205 // Called from ConfirmNeverView if the user confirms her intention to never | 204 // Called from ConfirmNeverView if the user confirms her intention to never |
206 // save passwords, and remove existing passwords, for a site. | 205 // save passwords, and remove existing passwords, for a site. |
207 void NotifyConfirmedNeverForThisSite(); | 206 void NotifyConfirmedNeverForThisSite(); |
208 | 207 |
209 // Called from ConfirmNeverView if the user clicks on "Undo" in order to | 208 // Called from ConfirmNeverView if the user clicks on "Undo" in order to |
210 // undo the action and refresh to PendingView. | 209 // undo the action and refresh to PendingView. |
211 void NotifyUndoNeverForThisSite(); | 210 void NotifyUndoNeverForThisSite(); |
212 | 211 |
213 // Starts a timer which will close the bubble if it's inactive. | |
214 void StartTimerIfNecessary(); | |
215 | |
216 // views::BubbleDelegateView: | 212 // views::BubbleDelegateView: |
217 virtual void Init() OVERRIDE; | 213 virtual void Init() OVERRIDE; |
218 virtual void WindowClosing() OVERRIDE; | 214 virtual void WindowClosing() OVERRIDE; |
219 virtual void OnWidgetActivationChanged(views::Widget* widget, | 215 virtual void OnWidgetActivationChanged(views::Widget* widget, |
220 bool active) OVERRIDE; | 216 bool active) OVERRIDE; |
221 | 217 |
222 // views::WidgetDelegate | 218 // views::WidgetDelegate |
223 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 219 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
224 | 220 |
225 // views::View methods. | 221 // views::View methods. |
226 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 222 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
227 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | |
228 | 223 |
229 // Called from WebContentMouseHandler when user clicks the web view. | 224 // Starts animating the bubble. |
230 void OnWebContentClicked(); | 225 void StartFadingOut(); |
| 226 |
| 227 // Cancel fading out if it's active. |
| 228 void CancelFadingOut(); |
| 229 |
| 230 // Called when the bubble completely faded out. |
| 231 void OnBubbleDisappeared(); |
231 | 232 |
232 void set_initially_focused_view(views::View* view) { | 233 void set_initially_focused_view(views::View* view) { |
233 DCHECK(!initially_focused_view_); | 234 DCHECK(!initially_focused_view_); |
234 initially_focused_view_ = view; | 235 initially_focused_view_ = view; |
235 } | 236 } |
236 | 237 |
237 // Singleton instance of the Password bubble. The Password bubble can only be | 238 // Singleton instance of the Password bubble. The Password bubble can only be |
238 // shown on the active browser window, so there is no case in which it will be | 239 // shown on the active browser window, so there is no case in which it will be |
239 // shown twice at the same time. The instance is owned by the Bubble and will | 240 // shown twice at the same time. The instance is owned by the Bubble and will |
240 // be deleted when the bubble closes. | 241 // be deleted when the bubble closes. |
241 static ManagePasswordsBubbleView* manage_passwords_bubble_; | 242 static ManagePasswordsBubbleView* manage_passwords_bubble_; |
242 | 243 |
243 ManagePasswordsIconView* anchor_view_; | 244 ManagePasswordsIconView* anchor_view_; |
244 | 245 |
245 // If true upon destruction, the user has confirmed that she never wants to | 246 // If true upon destruction, the user has confirmed that she never wants to |
246 // save passwords for a particular site. | 247 // save passwords for a particular site. |
247 bool never_save_passwords_; | 248 bool never_save_passwords_; |
248 | 249 |
249 views::View* initially_focused_view_; | 250 views::View* initially_focused_view_; |
250 | 251 |
251 // Timer used to close the bubble after timeout. | 252 // A helper to intercept mouse click events on the web contents. |
252 base::OneShotTimer<ManagePasswordsBubbleView> timer_; | |
253 | |
254 class WebContentMouseHandler; | 253 class WebContentMouseHandler; |
255 scoped_ptr<WebContentMouseHandler> mouse_handler_; | 254 scoped_ptr<WebContentMouseHandler> mouse_handler_; |
256 | 255 |
| 256 // A helper to get a notification when the bubble fades out completely. |
| 257 class FadeOutObserver; |
| 258 scoped_ptr<FadeOutObserver> fadeout_observer_; |
| 259 |
257 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); | 260 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); |
258 }; | 261 }; |
259 | 262 |
260 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ | 263 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ |
OLD | NEW |