website_settings_popup_view.h revision 868fa2fe829687343ffae624259930155e16dbd8
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. 4 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_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "base/memory/scoped_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 "ui/views/bubble/bubble_delegate.h" 15#include "ui/views/controls/button/button.h" 16#include "ui/views/controls/link_listener.h" 17#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" 18 19class Browser; 20class GURL; 21class PermissionSelectorView; 22class PopupHeaderView; 23class Profile; 24 25namespace content { 26struct SSLStatus; 27class WebContents; 28} 29 30namespace views { 31class Link; 32class TabbedPane; 33class Widget; 34} 35 36// The views implementation of the website settings UI. 37class WebsiteSettingsPopupView 38 : public PermissionSelectorViewObserver, 39 public views::BubbleDelegateView, 40 public views::ButtonListener, 41 public views::LinkListener, 42 public views::TabbedPaneListener, 43 public WebsiteSettingsUI { 44 public: 45 virtual ~WebsiteSettingsPopupView(); 46 47 static void ShowPopup(views::View* anchor_view, 48 Profile* profile, 49 content::WebContents* web_contents, 50 const GURL& url, 51 const content::SSLStatus& ssl, 52 Browser* browser); 53 54 private: 55 WebsiteSettingsPopupView(views::View* anchor_view, 56 Profile* profile, 57 content::WebContents* web_contents, 58 const GURL& url, 59 const content::SSLStatus& ssl, 60 Browser* browser); 61 62 // PermissionSelectorViewObserver implementation. 63 virtual void OnPermissionChanged( 64 PermissionSelectorView* selector) OVERRIDE; 65 66 // views::BubbleDelegate implementation. 67 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; 68 69 // views::ButtonListener implementation. 70 virtual void ButtonPressed(views::Button* button, 71 const ui::Event& event) OVERRIDE; 72 73 // views::LinkListener implementation. 74 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 75 76 // views::TabbedPaneListener implementations. 77 virtual void TabSelectedAt(int index) OVERRIDE; 78 79 // views::View implementation. 80 virtual gfx::Size GetPreferredSize() OVERRIDE; 81 82 // WebsiteSettingsUI implementations. 83 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE; 84 virtual void SetPermissionInfo( 85 const PermissionInfoList& permission_info_list) OVERRIDE; 86 virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE; 87 virtual void SetFirstVisit(const string16& first_visit) OVERRIDE; 88 virtual void SetSelectedTab(TabId tab_id) OVERRIDE; 89 90 // Creates the contents of the "Permissions" tab. The ownership of the 91 // returned view is transferred to the caller. 92 views::View* CreatePermissionsTab() WARN_UNUSED_RESULT; 93 94 // Creates the contents of the "connection" tab. The ownership of the returned 95 // view is transferred to the caller. 96 views::View* CreateConnectionTab() WARN_UNUSED_RESULT; 97 98 // Each tab contains several sections with a |headline| followed by the 99 // section |contents| and an optional |link|. This method creates a section 100 // for the given |headline|, |contents| and |link|. |link| can be NULL if the 101 // section should not contain a link. 102 views::View* CreateSection(const string16& headline, 103 views::View* contents, 104 views::Link* link) WARN_UNUSED_RESULT; 105 106 // Resets the content of a section. All children of the |section_container| 107 // are cleared and destroyed first. Then the |icon|, |headline|, |text| and 108 // |link| are layout out properly. If the |headline| is an empty string then 109 // no headline will be displayed. The ownership of the passed |link| is 110 // transfered to the ResetConnectionSection method and the |link| is added to 111 // the views hierarchy. If the |link| is NULL then no link is be displayed. 112 void ResetConnectionSection(views::View* section_container, 113 const gfx::Image& icon, 114 const string16& headline, 115 const string16& text, 116 views::Link* link); 117 118 // The web contents of the current tab. The popup can't live longer than a 119 // tab. 120 content::WebContents* web_contents_; 121 122 // The Browser is used to load the help center page. 123 Browser* browser_; 124 125 // The presenter that controlls the Website Settings UI. 126 scoped_ptr<WebsiteSettings> presenter_; 127 128 PopupHeaderView* header_; // Owned by views hierarchy. 129 130 // The |TabbedPane| that contains the tabs of the Website Settings UI. 131 views::TabbedPane* tabbed_pane_; 132 133 // The view that contains the contents of the "Cookies and Site data" section 134 // from the "Permissions" tab. 135 views::View* site_data_content_; 136 // The link that opend the "Cookies" dialog. 137 views::Link* cookie_dialog_link_; 138 // The view that contains the contents of the "Permissions" section from the 139 // "Permissions" tab. 140 views::View* permissions_content_; 141 142 // The view that contains the connection tab contents. 143 views::View* connection_tab_; 144 // The view that contains the ui elements for displaying information about 145 // the site's identity. 146 views::View* identity_info_content_; 147 // The link to open the certificate viewer for displaying the certificate 148 // provided by the website. If the site does not provide a certificate then 149 // |certificate_dialog_link_| is NULL. 150 views::Link* certificate_dialog_link_; 151 // The id of the certificate provided by the site. If the site does not 152 // provide a certificate then |cert_id_| is 0. 153 int cert_id_; 154 155 // The link to open the help center page that contains more information about 156 // the connection status icons. 157 views::Link* help_center_link_; 158 159 views::View* connection_info_content_; 160 views::View* page_info_content_; 161 162 DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView); 163}; 164 165#endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_ 166