Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / views / passwords / manage_passwords_bubble_view.h
blob460bae9ca7024ef95588b997437c23b48742e8f4
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;
13 namespace content {
14 class WebContents;
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 {
27 public:
28 // Shows the bubble.
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;
53 #endif
55 private:
56 class AccountChooserView;
57 class AutoSigninView;
58 class BlacklistedView;
59 class ManageView;
60 class PendingView;
61 class SaveConfirmationView;
62 class UpdatePendingView;
63 class WebContentMouseHandler;
65 ManagePasswordsBubbleView(content::WebContents* web_contents,
66 ManagePasswordsIconView* anchor_view,
67 DisplayReason reason);
68 ~ManagePasswordsBubbleView() override;
70 // ManagedFullScreenBubbleDelegateView:
71 views::View* GetInitiallyFocusedView() override;
72 void Init() override;
73 void Close() override;
75 // WidgetObserver:
76 void OnWidgetClosing(views::Widget* widget) override;
78 // WidgetDelegate:
79 bool ShouldShowCloseButton() const override;
81 // Refreshes the bubble's state: called to display a confirmation screen after
82 // a user selects "Never for this site", for instance.
83 void Refresh();
85 void set_initially_focused_view(views::View* view) {
86 DCHECK(!initially_focused_view_);
87 initially_focused_view_ = view;
90 // Singleton instance of the Password bubble. The Password bubble can only be
91 // shown on the active browser window, so there is no case in which it will be
92 // shown twice at the same time. The instance is owned by the Bubble and will
93 // be deleted when the bubble closes.
94 static ManagePasswordsBubbleView* manage_passwords_bubble_;
96 // The timeout in seconds for the auto sign-in toast.
97 static int auto_signin_toast_timeout_;
99 ManagePasswordsIconView* anchor_view_;
101 views::View* initially_focused_view_;
103 // A helper to intercept mouse click events on the web contents.
104 scoped_ptr<WebContentMouseHandler> mouse_handler_;
106 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
109 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_