[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / passwords / manage_passwords_bubble_view.h
blobc79d92a8f2f40bea82539a05460a61282ce81f06
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 "base/basictypes.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
10 #include "chrome/browser/ui/views/passwords/save_password_refusal_combobox_model.h"
11 #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"
18 class ManagePasswordsIconView;
20 namespace content {
21 class WebContents;
24 namespace views {
25 class BlueButton;
26 class LabelButton;
27 class GridLayout;
30 // The ManagePasswordsBubbleView controls the contents of the bubble which
31 // pops up when Chrome offers to save a user's password, or when the user
32 // interacts with the Omnibox icon. It has two distinct states:
34 // 1. PendingView: Offers the user the possibility of saving credentials.
35 // 2. ManageView: Displays the current page's saved credentials.
36 // 3. BlacklistedView: Informs the user that the current page is blacklisted.
38 class ManagePasswordsBubbleView : public ManagePasswordsBubble,
39 public views::BubbleDelegateView {
40 public:
41 // A view offering the user the ability to save credentials. Contains a
42 // single ManagePasswordItemView, along with a "Save Passwords" button
43 // and a rejection combobox.
44 class PendingView : public views::View,
45 public views::ButtonListener,
46 public views::ComboboxListener {
47 public:
48 explicit PendingView(ManagePasswordsBubbleView* parent);
49 virtual ~PendingView();
51 private:
52 // views::ButtonListener:
53 virtual void ButtonPressed(views::Button* sender,
54 const ui::Event& event) OVERRIDE;
56 // Handles the event when the user changes an index of a combobox.
57 virtual void OnPerformAction(views::Combobox* source) OVERRIDE;
59 ManagePasswordsBubbleView* parent_;
61 views::BlueButton* save_button_;
63 // The combobox doesn't take ownership of its model. If we created a
64 // combobox we need to ensure that we delete the model here, and because the
65 // combobox uses the model in it's destructor, we need to make sure we
66 // delete the model _after_ the combobox itself is deleted.
67 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_;
68 scoped_ptr<views::Combobox> refuse_combobox_;
71 // A view offering the user a list of her currently saved credentials
72 // for the current page, along with a "Manage passwords" link and a
73 // "Done" button.
74 class ManageView : public views::View,
75 public views::ButtonListener,
76 public views::LinkListener {
77 public:
78 explicit ManageView(ManagePasswordsBubbleView* parent);
79 virtual ~ManageView();
81 private:
82 // views::ButtonListener:
83 virtual void ButtonPressed(views::Button* sender,
84 const ui::Event& event) OVERRIDE;
86 // views::LinkListener:
87 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
89 ManagePasswordsBubbleView* parent_;
91 views::Link* manage_link_;
92 views::LabelButton* done_button_;
95 // A view offering the user the ability to re-enable the password manager for
96 // a specific site after she's decided to "never save passwords".
97 class BlacklistedView : public views::View, public views::ButtonListener {
98 public:
99 explicit BlacklistedView(ManagePasswordsBubbleView* parent);
100 virtual ~BlacklistedView();
102 private:
103 // views::ButtonListener:
104 virtual void ButtonPressed(views::Button* sender,
105 const ui::Event& event) OVERRIDE;
107 ManagePasswordsBubbleView* parent_;
109 views::BlueButton* unblacklist_button_;
110 views::LabelButton* done_button_;
113 // Shows the bubble.
114 static void ShowBubble(content::WebContents* web_contents,
115 DisplayReason reason);
117 // Closes any existing bubble.
118 static void CloseBubble();
120 // Whether the bubble is currently showing.
121 static bool IsShowing();
123 private:
124 ManagePasswordsBubbleView(content::WebContents* web_contents,
125 views::View* anchor_view,
126 DisplayReason reason);
127 virtual ~ManagePasswordsBubbleView();
129 // If the bubble is not anchored to a view, places the bubble in the top
130 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s
131 // browser window. Because the positioning is based on the size of the
132 // bubble, this must be called after the bubble is created.
133 void AdjustForFullscreen(const gfx::Rect& screen_bounds);
135 // Close the bubble.
136 void Close();
138 // views::BubbleDelegateView:
139 virtual void Init() OVERRIDE;
140 virtual void WindowClosing() OVERRIDE;
142 // Singleton instance of the Password bubble. The Password bubble can only be
143 // shown on the active browser window, so there is no case in which it will be
144 // shown twice at the same time.
145 static ManagePasswordsBubbleView* manage_passwords_bubble_;
147 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
150 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_