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