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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
8 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
9 #include "chrome/browser/ui/views/managed_full_screen_bubble_delegate_view.h"
11 class ManagePasswordsIconView
;
17 // The ManagePasswordsBubbleView controls the contents of the bubble which
18 // pops up when Chrome offers to save a user's password, or when the user
19 // interacts with the Omnibox icon. It has two distinct states:
21 // 1. PendingView: Offers the user the possibility of saving credentials.
22 // 2. ManageView: Displays the current page's saved credentials.
23 // 3. BlacklistedView: Informs the user that the current page is blacklisted.
25 class ManagePasswordsBubbleView
: public ManagePasswordsBubble
,
26 public ManagedFullScreenBubbleDelegateView
{
29 static void ShowBubble(content::WebContents
* web_contents
,
30 DisplayReason reason
);
32 // Closes the existing bubble.
33 static void CloseBubble();
35 // Makes the bubble the foreground window.
36 static void ActivateBubble();
38 // Returns a pointer to the bubble.
39 static ManagePasswordsBubbleView
* manage_password_bubble() {
40 return manage_passwords_bubble_
;
43 content::WebContents
* web_contents() const;
45 #if defined(UNIT_TEST)
46 const View
* initially_focused_view() const {
47 return initially_focused_view_
;
50 static void set_auto_signin_toast_timeout(int seconds
) {
51 auto_signin_toast_timeout_
= seconds
;
56 class AccountChooserView
;
58 class BlacklistedView
;
59 class ConfirmNeverView
;
61 class ManageAccountsView
;
63 class SaveConfirmationView
;
64 class WebContentMouseHandler
;
66 ManagePasswordsBubbleView(content::WebContents
* web_contents
,
67 ManagePasswordsIconView
* anchor_view
,
68 DisplayReason reason
);
69 ~ManagePasswordsBubbleView() override
;
71 // ManagedFullScreenBubbleDelegateView:
72 views::View
* GetInitiallyFocusedView() override
;
74 void Close() override
;
77 void OnWidgetClosing(views::Widget
* widget
) override
;
79 // Refreshes the bubble's state: called to display a confirmation screen after
80 // a user selects "Never for this site", for instance.
83 // Called from PendingView if the user clicks on "Never for this site" in
84 // order to display a confirmation screen.
85 void NotifyNeverForThisSiteClicked();
87 // Called from ConfirmNeverView if the user confirms her intention to never
88 // save passwords, and remove existing passwords, for a site.
89 void NotifyConfirmedNeverForThisSite();
91 // Called from ConfirmNeverView if the user clicks on "Undo" in order to
92 // undo the action and refresh to PendingView.
93 void NotifyUndoNeverForThisSite();
95 void set_initially_focused_view(views::View
* view
) {
96 DCHECK(!initially_focused_view_
);
97 initially_focused_view_
= view
;
100 // Singleton instance of the Password bubble. The Password bubble can only be
101 // shown on the active browser window, so there is no case in which it will be
102 // shown twice at the same time. The instance is owned by the Bubble and will
103 // be deleted when the bubble closes.
104 static ManagePasswordsBubbleView
* manage_passwords_bubble_
;
106 // The timeout in seconds for the auto sign-in toast.
107 static int auto_signin_toast_timeout_
;
109 ManagePasswordsIconView
* anchor_view_
;
111 views::View
* initially_focused_view_
;
113 // A helper to intercept mouse click events on the web contents.
114 scoped_ptr
<WebContentMouseHandler
> mouse_handler_
;
116 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView
);
119 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_