Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h

Issue 266973002: Password bubble: Create subviews for ManagePasswordsBubbleView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/ui/passwords/manage_passwords_bubble.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
10 #include "chrome/browser/ui/views/passwords/save_password_refusal_combobox_model .h" 10 #include "chrome/browser/ui/views/passwords/save_password_refusal_combobox_model .h"
11 #include "ui/views/bubble/bubble_delegate.h" 11 #include "ui/views/bubble/bubble_delegate.h"
12 #include "ui/views/controls/button/button.h" 12 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/combobox/combobox.h" 13 #include "ui/views/controls/combobox/combobox.h"
14 #include "ui/views/controls/combobox/combobox_listener.h" 14 #include "ui/views/controls/combobox/combobox_listener.h"
15 #include "ui/views/controls/link.h" 15 #include "ui/views/controls/link.h"
16 #include "ui/views/controls/link_listener.h" 16 #include "ui/views/controls/link_listener.h"
17 17
18 class ManagePasswordsIconView; 18 class ManagePasswordsIconView;
19 19
20 namespace content { 20 namespace content {
21 class WebContents; 21 class WebContents;
22 } 22 }
23 23
24 namespace views { 24 namespace views {
25 class BlueButton; 25 class BlueButton;
26 class LabelButton; 26 class LabelButton;
27 class GridLayout; 27 class GridLayout;
28 } 28 }
29 29
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:
33 //
34 // 1. PendingView: Offers the user the possibility of saving credentials.
35 // 2. ManageView: Displays the current page's saved credentials.
36 //
37 // TODO(mkwst): Add a third state: "Informing the user that the current page
38 // is blacklisted."
30 class ManagePasswordsBubbleView : public ManagePasswordsBubble, 39 class ManagePasswordsBubbleView : public ManagePasswordsBubble,
31 public views::BubbleDelegateView, 40 public views::BubbleDelegateView {
32 public views::ButtonListener,
33 public views::ComboboxListener,
34 public views::LinkListener {
35 public: 41 public:
42 // A view offering the user the ability to save credentials. Contains a
43 // single ManagePasswordItemView, along with a "Save Passwords" button
44 // and a rejection combobox.
45 class PendingView : public views::View,
46 public views::ButtonListener,
47 public views::ComboboxListener {
48 public:
49 explicit PendingView(ManagePasswordsBubbleView* parent);
50 virtual ~PendingView();
51
52 private:
53 // views::ButtonListener:
54 virtual void ButtonPressed(views::Button* sender,
55 const ui::Event& event) OVERRIDE;
56
57 // Handles the event when the user changes an index of a combobox.
58 virtual void OnPerformAction(views::Combobox* source) OVERRIDE;
59
60 ManagePasswordsBubbleView* parent_;
61
62 views::BlueButton* save_button_;
63
64 // The combobox doesn't take ownership of its model. If we created a
65 // combobox we need to ensure that we delete the model here, and because the
66 // combobox uses the model in it's destructor, we need to make sure we
67 // delete the model _after_ the combobox itself is deleted.
68 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_;
69 scoped_ptr<views::Combobox> refuse_combobox_;
70 };
71
72 // A view offering the user a list of her currently saved credentials
73 // for the current page, along with a "Manage passwords" link and a
74 // "Done" button.
75 class ManageView : public views::View,
76 public views::ButtonListener,
77 public views::LinkListener {
78 public:
79 explicit ManageView(ManagePasswordsBubbleView* parent);
80 virtual ~ManageView();
81
82 private:
83 // views::ButtonListener:
84 virtual void ButtonPressed(views::Button* sender,
85 const ui::Event& event) OVERRIDE;
86
87 // views::LinkListener:
88 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
89
90 ManagePasswordsBubbleView* parent_;
91
92 views::Link* manage_link_;
93 views::LabelButton* done_button_;
94 };
95
36 // Shows the bubble. 96 // Shows the bubble.
37 static void ShowBubble(content::WebContents* web_contents, 97 static void ShowBubble(content::WebContents* web_contents,
38 DisplayReason reason); 98 DisplayReason reason);
39 99
40 // Closes any existing bubble. 100 // Closes any existing bubble.
41 static void CloseBubble(); 101 static void CloseBubble();
42 102
43 // Whether the bubble is currently showing. 103 // Whether the bubble is currently showing.
44 static bool IsShowing(); 104 static bool IsShowing();
45 105
46 private: 106 private:
47 enum ColumnSetType {
48 // | | (FILL, FILL) | |
49 // Used for the bubble's header, the credentials list, and for simple
50 // messages like "No passwords".
51 SINGLE_VIEW_COLUMN_SET = 0,
52
53 // | | (TRAILING, CENTER) | | (TRAILING, CENTER) | |
54 // Used for buttons at the bottom of the bubble which should nest at the
55 // bottom-right corner.
56 DOUBLE_BUTTON_COLUMN_SET = 1,
57
58 // | | (LEADING, CENTER) | | (TRAILING, CENTER) | |
59 // Used for buttons at the bottom of the bubble which should occupy
60 // the corners.
61 LINK_BUTTON_COLUMN_SET = 2,
62 };
63
64 ManagePasswordsBubbleView(content::WebContents* web_contents, 107 ManagePasswordsBubbleView(content::WebContents* web_contents,
65 views::View* anchor_view, 108 views::View* anchor_view,
66 DisplayReason reason); 109 DisplayReason reason);
67 virtual ~ManagePasswordsBubbleView(); 110 virtual ~ManagePasswordsBubbleView();
68 111
69 // Construct an appropriate ColumnSet for the given |type|, and add it
70 // to |layout|.
71 void BuildColumnSet(views::GridLayout* layout, ColumnSetType type);
72
73 // If the bubble is not anchored to a view, places the bubble in the top 112 // If the bubble is not anchored to a view, places the bubble in the top
74 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s 113 // right (left in RTL) of the |screen_bounds| that contain |web_contents_|'s
75 // browser window. Because the positioning is based on the size of the 114 // browser window. Because the positioning is based on the size of the
76 // bubble, this must be called after the bubble is created. 115 // bubble, this must be called after the bubble is created.
77 void AdjustForFullscreen(const gfx::Rect& screen_bounds); 116 void AdjustForFullscreen(const gfx::Rect& screen_bounds);
78 117
79 // Close the bubble. 118 // Close the bubble.
80 void Close(); 119 void Close();
81 120
82 // Close the bubble without triggering UMA logging. We need this for the 121 // Close the bubble without triggering UMA logging. We need this for the
83 // moment, as the current implementation can close the bubble without user 122 // moment, as the current implementation can close the bubble without user
84 // interaction; we want to ensure that doesn't show up as a user action in 123 // interaction; we want to ensure that doesn't show up as a user action in
85 // our counts. 124 // our counts.
86 // 125 //
87 // TODO(mkwst): Throw this away once the icon is no longer responsible for 126 // TODO(mkwst): Throw this away once the icon is no longer responsible for
88 // creating the bubble. 127 // creating the bubble.
89 void CloseWithoutLogging(); 128 void CloseWithoutLogging();
90 129
91 // views::BubbleDelegateView: 130 // views::BubbleDelegateView:
92 virtual void Init() OVERRIDE; 131 virtual void Init() OVERRIDE;
93 virtual void WindowClosing() OVERRIDE; 132 virtual void WindowClosing() OVERRIDE;
94 133
95 // views::ButtonListener:
96 virtual void ButtonPressed(views::Button* sender,
97 const ui::Event& event) OVERRIDE;
98
99 // views::LinkListener:
100 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
101
102 // Handles the event when the user changes an index of a combobox.
103 virtual void OnPerformAction(views::Combobox* source) OVERRIDE;
104
105 // Singleton instance of the Password bubble. The Password bubble can only be 134 // Singleton instance of the Password bubble. The Password bubble can only be
106 // shown on the active browser window, so there is no case in which it will be 135 // shown on the active browser window, so there is no case in which it will be
107 // shown twice at the same time. 136 // shown twice at the same time.
108 static ManagePasswordsBubbleView* manage_passwords_bubble_; 137 static ManagePasswordsBubbleView* manage_passwords_bubble_;
109 138
110 // The views that are shown in the bubble.
111 views::BlueButton* save_button_;
112 views::Link* manage_link_;
113 views::LabelButton* done_button_;
114
115 // The combobox doesn't take ownership of it's model. If we created a combobox
116 // we need to ensure that we delete the model here, and because the combobox
117 // uses the model in it's destructor, we need to make sure we delete the model
118 // _after_ the combobox itself is deleted.
119 scoped_ptr<SavePasswordRefusalComboboxModel> combobox_model_;
120 scoped_ptr<views::Combobox> refuse_combobox_;
121
122 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView); 139 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
123 }; 140 };
124 141
125 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_ 142 #endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698