Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / ui / views / passwords / manage_passwords_bubble_view.h
blob3b3b2b8ce191a7067df60f1b3979460b4f6972b3
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 "ui/views/bubble/bubble_delegate.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 views::BubbleDelegateView {
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 // Whether the bubble is currently showing.
39 static bool IsShowing();
41 // Returns a pointer to the bubble.
42 static const ManagePasswordsBubbleView* manage_password_bubble() {
43 return manage_passwords_bubble_;
46 content::WebContents* web_contents() const;
48 const View* initially_focused_view() const {
49 return initially_focused_view_;
52 private:
53 class BlacklistedView;
54 class ConfirmNeverView;
55 class ManageView;
56 class PendingView;
57 class SaveConfirmationView;
59 ManagePasswordsBubbleView(content::WebContents* web_contents,
60 ManagePasswordsIconView* anchor_view,
61 DisplayReason reason);
62 virtual ~ManagePasswordsBubbleView();
64 // If the bubble is not anchored to a view, places the bubble in the top
65 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s
66 // browser window. Because the positioning is based on the size of the
67 // bubble, this must be called after the bubble is created.
68 void AdjustForFullscreen(const gfx::Rect& screen_bounds);
70 // Close the bubble.
71 void Close();
73 // Refreshes the bubble's state: called to display a confirmation screen after
74 // a user selects "Never for this site", for instance.
75 void Refresh();
77 // Called from PendingView if the user clicks on "Never for this site" in
78 // order to display a confirmation screen.
79 void NotifyNeverForThisSiteClicked();
81 // Called from ConfirmNeverView if the user confirms her intention to never
82 // save passwords, and remove existing passwords, for a site.
83 void NotifyConfirmedNeverForThisSite();
85 // Called from ConfirmNeverView if the user clicks on "Undo" in order to
86 // undo the action and refresh to PendingView.
87 void NotifyUndoNeverForThisSite();
89 // views::BubbleDelegateView:
90 virtual void Init() override;
91 virtual void WindowClosing() override;
93 // views::WidgetDelegate
94 virtual views::View* GetInitiallyFocusedView() override;
96 void set_initially_focused_view(views::View* view) {
97 DCHECK(!initially_focused_view_);
98 initially_focused_view_ = view;
101 // Singleton instance of the Password bubble. The Password bubble can only be
102 // shown on the active browser window, so there is no case in which it will be
103 // shown twice at the same time. The instance is owned by the Bubble and will
104 // be deleted when the bubble closes.
105 static ManagePasswordsBubbleView* manage_passwords_bubble_;
107 ManagePasswordsIconView* anchor_view_;
109 // If true upon destruction, the user has confirmed that she never wants to
110 // save passwords for a particular site.
111 bool never_save_passwords_;
113 views::View* initially_focused_view_;
115 // A helper to intercept mouse click events on the web contents.
116 class WebContentMouseHandler;
117 scoped_ptr<WebContentMouseHandler> mouse_handler_;
119 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
122 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_