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/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/views/website_settings/permission_selector_view_observer.h"
13 #include "chrome/browser/ui/website_settings/website_settings_ui.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "ui/views/bubble/bubble_delegate.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/link_listener.h"
18 #include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h"
21 class PopupHeaderView
;
36 // The views implementation of the website settings UI.
37 class WebsiteSettingsPopupView
: public content::WebContentsObserver
,
38 public PermissionSelectorViewObserver
,
39 public views::BubbleDelegateView
,
40 public views::ButtonListener
,
41 public views::LinkListener
,
42 public views::TabbedPaneListener
,
43 public WebsiteSettingsUI
{
45 ~WebsiteSettingsPopupView() override
;
47 // If |anchor_view| is null, |anchor_rect| is used to anchor the bubble.
48 static void ShowPopup(views::View
* anchor_view
,
49 const gfx::Rect
& anchor_rect
,
51 content::WebContents
* web_contents
,
53 const content::SSLStatus
& ssl
);
55 static bool IsPopupShowing();
58 WebsiteSettingsPopupView(views::View
* anchor_view
,
59 gfx::NativeView parent_window
,
61 content::WebContents
* web_contents
,
63 const content::SSLStatus
& ssl
);
65 // WebContentsObserver implementation.
66 void RenderFrameDeleted(content::RenderFrameHost
* render_frame_host
) override
;
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 SetSelectedTab(TabId tab_id
) override
;
94 // Creates the contents of the "Permissions" tab. The ownership of the
95 // returned view is transferred to the caller.
96 views::View
* CreatePermissionsTab() WARN_UNUSED_RESULT
;
98 // Creates the contents of the "connection" tab. The ownership of the returned
99 // view is transferred to the caller.
100 views::View
* CreateConnectionTab() WARN_UNUSED_RESULT
;
102 // Each tab contains several sections with a |headline| followed by the
103 // section |contents| and an optional |link|. This method creates a section
104 // for the given |headline|, |contents| and |link|. |link| can be NULL if the
105 // section should not contain a link.
106 views::View
* CreateSection(const base::string16
& headline
,
107 views::View
* contents
,
108 views::Link
* link
) WARN_UNUSED_RESULT
;
110 // Resets the content of a section. All children of the |section_container|
111 // are cleared and destroyed first. Then the |icon|, |headline|, |text|,
112 // |link|, and |secondary_link| are laid out properly. If the |headline| is an
113 // empty string then no headline will be displayed. Ownership of |link| and
114 // |secondary_link| is transfered to the ResetConnectionSection method and the
115 // links are added to the views hierarchy. NULL links are not displayed.
116 void ResetConnectionSection(views::View
* section_container
,
117 const gfx::Image
& icon
,
118 const base::string16
& headline
,
119 const base::string16
& text
,
121 views::LabelButton
* reset_decisions_button
);
123 // Used to asynchronously handle clicks since these calls may cause the
124 // destruction of the settings view and the base class window still needs to
125 // be alive to finish handling the mouse or keyboard click.
126 void HandleLinkClickedAsync(views::Link
* source
);
128 // The web contents of the current tab. The popup can't live longer than a
130 content::WebContents
* web_contents_
;
132 // The presenter that controls the Website Settings UI.
133 scoped_ptr
<WebsiteSettings
> presenter_
;
135 PopupHeaderView
* header_
; // Owned by views hierarchy.
137 // The |TabbedPane| that contains the tabs of the Website Settings UI.
138 views::TabbedPane
* tabbed_pane_
;
140 // The view that contains the permissions tab contents.
141 views::View
* permissions_tab_
;
142 // The view that contains the contents of the "Cookies and Site data" section
143 // from the "Permissions" tab.
144 views::View
* site_data_content_
;
145 // The link that opens the "Cookies" dialog.
146 views::Link
* cookie_dialog_link_
;
147 // The view that contains the contents of the "Permissions" section from the
148 // "Permissions" tab.
149 views::View
* permissions_content_
;
151 // The view that contains the connection tab contents.
152 views::View
* connection_tab_
;
153 // The view that contains the UI elements for displaying information about
154 // the site's identity.
155 views::View
* identity_info_content_
;
156 // The link to open the certificate viewer for displaying the certificate
157 // provided by the website. If the site does not provide a certificate then
158 // |certificate_dialog_link_| is NULL.
159 views::Link
* certificate_dialog_link_
;
160 // The button to reset the Allow/Deny certificate errors decision for the
162 views::LabelButton
* reset_decisions_button_
;
163 // The view that contains the contents of the "What Do These Mean?" section
164 // from the "Connection" tab.
165 views::View
* help_center_content_
;
167 // The ID of the certificate provided by the site. If the site does not
168 // provide a certificate then |cert_id_| is 0.
171 // The link to open the help center page that contains more information about
172 // the connection status icons.
173 views::Link
* help_center_link_
;
175 // The link to open the site settings page that provides full control over
176 // the origin's permissions.
177 views::Link
* site_settings_link_
;
179 views::View
* connection_info_content_
;
181 base::WeakPtrFactory
<WebsiteSettingsPopupView
> weak_factory_
;
183 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView
);
186 #endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_