MacViews: Use Mac's "Constrained Window Button" style for Button::STYLE_BUTTON LabelB...
[chromium-blink-merge.git] / chrome / browser / ui / views / website_settings / website_settings_popup_view.h
blobf33c04e6f516fb1a9496275ca371ba4a5138ed1a
1 // Copyright (c) 2012 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_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/ui/views/website_settings/permission_selector_view_observer.h"
14 #include "chrome/browser/ui/website_settings/website_settings_ui.h"
15 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/button/label_button.h"
18 #include "ui/views/controls/link_listener.h"
19 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
21 class Browser;
22 class GURL;
23 class PermissionSelectorView;
24 class PopupHeaderView;
25 class Profile;
27 namespace content {
28 struct SSLStatus;
29 class WebContents;
32 namespace views {
33 class LabelButton;
34 class Link;
35 class TabbedPane;
36 class Widget;
39 // The views implementation of the website settings UI.
40 class WebsiteSettingsPopupView
41 : public PermissionSelectorViewObserver,
42 public views::BubbleDelegateView,
43 public views::ButtonListener,
44 public views::LinkListener,
45 public views::TabbedPaneListener,
46 public WebsiteSettingsUI {
47 public:
48 ~WebsiteSettingsPopupView() override;
50 static void ShowPopup(views::View* anchor_view,
51 Profile* profile,
52 content::WebContents* web_contents,
53 const GURL& url,
54 const content::SSLStatus& ssl,
55 Browser* browser);
57 static bool IsPopupShowing();
59 private:
60 WebsiteSettingsPopupView(views::View* anchor_view,
61 Profile* profile,
62 content::WebContents* web_contents,
63 const GURL& url,
64 const content::SSLStatus& ssl,
65 Browser* browser);
67 // PermissionSelectorViewObserver implementation.
68 void OnPermissionChanged(
69 const WebsiteSettingsUI::PermissionInfo& permission) override;
71 // views::BubbleDelegateView implementation.
72 void OnWidgetDestroying(views::Widget* widget) override;
74 // views::ButtonListener implementation.
75 void ButtonPressed(views::Button* button, const ui::Event& event) override;
77 // views::LinkListener implementation.
78 void LinkClicked(views::Link* source, int event_flags) override;
80 // views::TabbedPaneListener implementations.
81 void TabSelectedAt(int index) override;
83 // views::View implementation.
84 gfx::Size GetPreferredSize() const override;
86 // WebsiteSettingsUI implementations.
87 void SetCookieInfo(const CookieInfoList& cookie_info_list) override;
88 void SetPermissionInfo(
89 const PermissionInfoList& permission_info_list) override;
90 void SetIdentityInfo(const IdentityInfo& identity_info) override;
91 void SetSelectedTab(TabId tab_id) override;
93 // Creates the contents of the "Permissions" tab. The ownership of the
94 // returned view is transferred to the caller.
95 views::View* CreatePermissionsTab() WARN_UNUSED_RESULT;
97 // Creates the contents of the "connection" tab. The ownership of the returned
98 // view is transferred to the caller.
99 views::View* CreateConnectionTab() WARN_UNUSED_RESULT;
101 // Each tab contains several sections with a |headline| followed by the
102 // section |contents| and an optional |link|. This method creates a section
103 // for the given |headline|, |contents| and |link|. |link| can be NULL if the
104 // section should not contain a link.
105 views::View* CreateSection(const base::string16& headline,
106 views::View* contents,
107 views::Link* link) WARN_UNUSED_RESULT;
109 // Resets the content of a section. All children of the |section_container|
110 // are cleared and destroyed first. Then the |icon|, |headline|, |text|,
111 // |link|, and |secondary_link| are laid out properly. If the |headline| is an
112 // empty string then no headline will be displayed. Ownership of |link| and
113 // |secondary_link| is transfered to the ResetConnectionSection method and the
114 // links are added to the views hierarchy. NULL links are not displayed.
115 void ResetConnectionSection(views::View* section_container,
116 const gfx::Image& icon,
117 const base::string16& headline,
118 const base::string16& text,
119 views::Link* link,
120 views::LabelButton* reset_decisions_button);
122 // Used to asynchronously handle clicks since these calls may cause the
123 // destruction of the settings view and the base class window still needs to
124 // be alive to finish handling the mouse or keyboard click.
125 void HandleLinkClickedAsync(views::Link* source);
127 // The web contents of the current tab. The popup can't live longer than a
128 // tab.
129 content::WebContents* web_contents_;
131 // The Browser is used to load the help center page.
132 Browser* browser_;
134 // The presenter that controls the Website Settings UI.
135 scoped_ptr<WebsiteSettings> presenter_;
137 PopupHeaderView* header_; // Owned by views hierarchy.
139 // The |TabbedPane| that contains the tabs of the Website Settings UI.
140 views::TabbedPane* tabbed_pane_;
142 // The view that contains the permissions tab contents.
143 views::View* permissions_tab_;
144 // The view that contains the contents of the "Cookies and Site data" section
145 // from the "Permissions" tab.
146 views::View* site_data_content_;
147 // The link that opens the "Cookies" dialog.
148 views::Link* cookie_dialog_link_;
149 // The view that contains the contents of the "Permissions" section from the
150 // "Permissions" tab.
151 views::View* permissions_content_;
153 // The view that contains the connection tab contents.
154 views::View* connection_tab_;
155 // The view that contains the UI elements for displaying information about
156 // the site's identity.
157 views::View* identity_info_content_;
158 // The link to open the certificate viewer for displaying the certificate
159 // provided by the website. If the site does not provide a certificate then
160 // |certificate_dialog_link_| is NULL.
161 views::Link* certificate_dialog_link_;
162 // The button to reset the Allow/Deny certificate errors decision for the
163 // current host.
164 views::LabelButton* reset_decisions_button_;
166 // The ID of the certificate provided by the site. If the site does not
167 // provide a certificate then |cert_id_| is 0.
168 int cert_id_;
170 // The link to open the help center page that contains more information about
171 // the connection status icons.
172 views::Link* help_center_link_;
174 // The link to open the site settings page that provides full control over
175 // the origin's permissions.
176 views::Link* site_settings_link_;
178 views::View* connection_info_content_;
180 base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_;
182 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView);
185 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_