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 "content/public/common/signed_certificate_timestamp_id_and_status.h"
16 #include "ui/views/bubble/bubble_delegate.h"
17 #include "ui/views/controls/button/button.h"
18 #include "ui/views/controls/button/label_button.h"
19 #include "ui/views/controls/link_listener.h"
20 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
24 class PermissionSelectorView
;
25 class PopupHeaderView
;
40 // The views implementation of the website settings UI.
41 class WebsiteSettingsPopupView
42 : public PermissionSelectorViewObserver
,
43 public views::BubbleDelegateView
,
44 public views::ButtonListener
,
45 public views::LinkListener
,
46 public views::TabbedPaneListener
,
47 public WebsiteSettingsUI
{
49 ~WebsiteSettingsPopupView() override
;
51 static void ShowPopup(views::View
* anchor_view
,
53 content::WebContents
* web_contents
,
55 const content::SSLStatus
& ssl
,
58 static bool IsPopupShowing();
61 WebsiteSettingsPopupView(views::View
* anchor_view
,
63 content::WebContents
* web_contents
,
65 const content::SSLStatus
& ssl
,
68 // PermissionSelectorViewObserver implementation.
69 void OnPermissionChanged(
70 const WebsiteSettingsUI::PermissionInfo
& permission
) override
;
72 // views::BubbleDelegateView implementation.
73 void OnWidgetDestroying(views::Widget
* widget
) override
;
75 // views::ButtonListener implementation.
76 void ButtonPressed(views::Button
* button
, const ui::Event
& event
) override
;
78 // views::LinkListener implementation.
79 void LinkClicked(views::Link
* source
, int event_flags
) override
;
81 // views::TabbedPaneListener implementations.
82 void TabSelectedAt(int index
) override
;
84 // views::View implementation.
85 gfx::Size
GetPreferredSize() const override
;
87 // WebsiteSettingsUI implementations.
88 void SetCookieInfo(const CookieInfoList
& cookie_info_list
) override
;
89 void SetPermissionInfo(
90 const PermissionInfoList
& permission_info_list
) override
;
91 void SetIdentityInfo(const IdentityInfo
& identity_info
) override
;
92 void SetFirstVisit(const base::string16
& first_visit
) override
;
93 void SetSelectedTab(TabId tab_id
) override
;
95 // Creates the contents of the "Permissions" tab. The ownership of the
96 // returned view is transferred to the caller.
97 views::View
* CreatePermissionsTab() WARN_UNUSED_RESULT
;
99 // Creates the contents of the "connection" tab. The ownership of the returned
100 // view is transferred to the caller.
101 views::View
* CreateConnectionTab() WARN_UNUSED_RESULT
;
103 // Each tab contains several sections with a |headline| followed by the
104 // section |contents| and an optional |link|. This method creates a section
105 // for the given |headline|, |contents| and |link|. |link| can be NULL if the
106 // section should not contain a link.
107 views::View
* CreateSection(const base::string16
& headline
,
108 views::View
* contents
,
109 views::Link
* link
) WARN_UNUSED_RESULT
;
111 // Resets the content of a section. All children of the |section_container|
112 // are cleared and destroyed first. Then the |icon|, |headline|, |text|,
113 // |link|, and |secondary_link| are laid out properly. If the |headline| is an
114 // empty string then no headline will be displayed. Ownership of |link| and
115 // |secondary_link| is transfered to the ResetConnectionSection method and the
116 // links are added to the views hierarchy. NULL links are not displayed.
117 void ResetConnectionSection(views::View
* section_container
,
118 const gfx::Image
& icon
,
119 const base::string16
& headline
,
120 const base::string16
& text
,
122 views::Link
* secondary_link
,
123 views::LabelButton
* reset_decisions_button
);
125 // Used to asynchronously handle clicks since these calls may cause the
126 // destruction of the settings view and the base class window still needs to
127 // be alive to finish handling the mouse or keyboard click.
128 void HandleLinkClickedAsync(views::Link
* source
);
130 // The web contents of the current tab. The popup can't live longer than a
132 content::WebContents
* web_contents_
;
134 // The Browser is used to load the help center page.
137 // The presenter that controls the Website Settings UI.
138 scoped_ptr
<WebsiteSettings
> presenter_
;
140 PopupHeaderView
* header_
; // Owned by views hierarchy.
142 // The |TabbedPane| that contains the tabs of the Website Settings UI.
143 views::TabbedPane
* tabbed_pane_
;
145 // The view that contains the permissions tab contents.
146 views::View
* permissions_tab_
;
147 // The view that contains the contents of the "Cookies and Site data" section
148 // from the "Permissions" tab.
149 views::View
* site_data_content_
;
150 // The link that opens the "Cookies" dialog.
151 views::Link
* cookie_dialog_link_
;
152 // The view that contains the contents of the "Permissions" section from the
153 // "Permissions" tab.
154 views::View
* permissions_content_
;
156 // The view that contains the connection tab contents.
157 views::View
* connection_tab_
;
158 // The view that contains the UI elements for displaying information about
159 // the site's identity.
160 views::View
* identity_info_content_
;
161 // The link to open the certificate viewer for displaying the certificate
162 // provided by the website. If the site does not provide a certificate then
163 // |certificate_dialog_link_| is NULL.
164 views::Link
* certificate_dialog_link_
;
165 // The link to open the signed certificate timestamps viewer for displaying
166 // Certificate Transparency info. If no such SCTs accompany the certificate
167 // then |signed_certificate_timestamps_link_| is NULL.
168 views::Link
* signed_certificate_timestamps_link_
;
169 // The button to reset the Allow/Deny certificate errors decision for the
171 views::LabelButton
* reset_decisions_button_
;
173 // The ID of the certificate provided by the site. If the site does not
174 // provide a certificate then |cert_id_| is 0.
176 // The IDs and validation status of Signed Certificate Timestamps provided
177 // by the site. Empty if no SCTs accompany the certificate.
178 content::SignedCertificateTimestampIDStatusList
179 signed_certificate_timestamp_ids_
;
181 // The link to open the help center page that contains more information about
182 // the connection status icons.
183 views::Link
* help_center_link_
;
185 // The link to open the site settings page that provides full control over
186 // the origin's permissions.
187 views::Link
* site_settings_link_
;
189 views::View
* connection_info_content_
;
190 views::View
* page_info_content_
;
192 base::WeakPtrFactory
<WebsiteSettingsPopupView
> weak_factory_
;
194 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView
);
197 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_