1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// Use of this source code is governed by a BSD-style license that can be 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// found in the LICENSE file. 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_ 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_ 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "base/basictypes.h" 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "base/compiler_specific.h" 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "base/memory/scoped_ptr.h" 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "base/memory/weak_ptr.h" 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "base/strings/string16.h" 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "chrome/browser/ui/views/website_settings/permission_selector_view_observer.h" 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "chrome/browser/ui/website_settings/website_settings_ui.h" 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "content/public/common/signed_certificate_timestamp_id_and_status.h" 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "ui/views/bubble/bubble_delegate.h" 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "ui/views/controls/button/button.h" 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "ui/views/controls/button/label_button.h" 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "ui/views/controls/link_listener.h" 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "ui/views/controls/tabbed_pane/tabbed_pane_listener.h" 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass Browser; 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass GURL; 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass PermissionSelectorView; 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass PopupHeaderView; 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass Profile; 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnamespace content { 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct SSLStatus; 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass WebContents; 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgnamespace views { 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass LabelButton; 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass Link; 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass TabbedPane; 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass Widget; 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org// The views implementation of the website settings UI. 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgclass WebsiteSettingsPopupView 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org : public PermissionSelectorViewObserver, 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org public views::BubbleDelegateView, 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org public views::ButtonListener, 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org public views::LinkListener, 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org public views::TabbedPaneListener, 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org public WebsiteSettingsUI { 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org public: 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual ~WebsiteSettingsPopupView(); 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static void ShowPopup(views::View* anchor_view, 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Profile* profile, 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org content::WebContents* web_contents, 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GURL& url, 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const content::SSLStatus& ssl, 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Browser* browser); 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org static bool IsPopupShowing(); 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org private: 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org WebsiteSettingsPopupView(views::View* anchor_view, 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Profile* profile, 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org content::WebContents* web_contents, 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GURL& url, 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const content::SSLStatus& ssl, 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Browser* browser); 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // PermissionSelectorViewObserver implementation. 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void OnPermissionChanged( 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const WebsiteSettingsUI::PermissionInfo& permission) OVERRIDE; 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // views::BubbleDelegateView implementation. 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE; 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // views::ButtonListener implementation. 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void ButtonPressed(views::Button* button, 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const ui::Event& event) OVERRIDE; 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // views::LinkListener implementation. 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // views::TabbedPaneListener implementations. 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void TabSelectedAt(int index) OVERRIDE; 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // views::View implementation. 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual gfx::Size GetPreferredSize() const OVERRIDE; 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // WebsiteSettingsUI implementations. 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) OVERRIDE; 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void SetPermissionInfo( 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const PermissionInfoList& permission_info_list) OVERRIDE; 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void SetIdentityInfo(const IdentityInfo& identity_info) OVERRIDE; 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void SetFirstVisit(const base::string16& first_visit) OVERRIDE; 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org virtual void SetSelectedTab(TabId tab_id) OVERRIDE; 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Creates the contents of the "Permissions" tab. The ownership of the 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // returned view is transferred to the caller. 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* CreatePermissionsTab() WARN_UNUSED_RESULT; 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Creates the contents of the "connection" tab. The ownership of the returned 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // view is transferred to the caller. 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* CreateConnectionTab() WARN_UNUSED_RESULT; 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Each tab contains several sections with a |headline| followed by the 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // section |contents| and an optional |link|. This method creates a section 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // for the given |headline|, |contents| and |link|. |link| can be NULL if the 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // section should not contain a link. 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* CreateSection(const base::string16& headline, 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* contents, 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* link) WARN_UNUSED_RESULT; 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Resets the content of a section. All children of the |section_container| 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // are cleared and destroyed first. Then the |icon|, |headline|, |text| and 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // |link| are layout out properly. If the |headline| is an empty string then 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // no headline will be displayed. The ownership of the passed |link| is 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // transfered to the ResetConnectionSection method and the |link| is added to 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the views hierarchy. If the |link| is NULL then no link is be displayed. 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void ResetConnectionSection(views::View* section_container, 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const gfx::Image& icon, 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const base::string16& headline, 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const base::string16& text, 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* link, 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* secondary_link, 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::LabelButton* reset_decisions_button); 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The web contents of the current tab. The popup can't live longer than a 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // tab. 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org content::WebContents* web_contents_; 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The Browser is used to load the help center page. 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org Browser* browser_; 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The presenter that controlls the Website Settings UI. 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org scoped_ptr<WebsiteSettings> presenter_; 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org PopupHeaderView* header_; // Owned by views hierarchy. 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The |TabbedPane| that contains the tabs of the Website Settings UI. 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::TabbedPane* tabbed_pane_; 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The view that contains the contents of the "Cookies and Site data" section 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // from the "Permissions" tab. 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* site_data_content_; 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The link that opend the "Cookies" dialog. 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* cookie_dialog_link_; 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The view that contains the contents of the "Permissions" section from the 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // "Permissions" tab. 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* permissions_content_; 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The view that contains the connection tab contents. 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* connection_tab_; 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The view that contains the ui elements for displaying information about 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the site's identity. 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* identity_info_content_; 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The link to open the certificate viewer for displaying the certificate 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // provided by the website. If the site does not provide a certificate then 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // |certificate_dialog_link_| is NULL. 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* certificate_dialog_link_; 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The link to open the signed certificate timestamps viewer for displaying 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // Certificate Transparency info. If no such SCTs accompany the certificate 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // then |signed_certificate_timestamps_link_| is NULL. 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* signed_certificate_timestamps_link_; 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The button to reset the Allow/Deny certificate errors decision for the 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // current host. 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::LabelButton* reset_decisions_button_; 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The id of the certificate provided by the site. If the site does not 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // provide a certificate then |cert_id_| is 0. 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int cert_id_; 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The IDs and validation status of Signed Certificate TImestamps provided 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // by the site. Empty if no SCTs accompany the certificate. 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org content::SignedCertificateTimestampIDStatusList 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org signed_certificate_timestamp_ids_; 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // The link to open the help center page that contains more information about 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org // the connection status icons. 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::Link* help_center_link_; 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* connection_info_content_; 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org views::View* page_info_content_; 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org base::WeakPtrFactory<WebsiteSettingsPopupView> weak_factory_; 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org DISALLOW_COPY_AND_ASSIGN(WebsiteSettingsPopupView); 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif // CHROME_BROWSER_UI_VIEWS_WEBSITE_SETTINGS_WEBSITE_SETTINGS_POPUP_VIEW_H_ 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org