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_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_
      6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/strings/string16.h"
     12 #include "chrome/browser/ui/website_settings/website_settings.h"
     13 #include "components/content_settings/core/common/content_settings.h"
     14 #include "components/content_settings/core/common/content_settings_types.h"
     15 #include "content/public/common/signed_certificate_timestamp_id_and_status.h"
     16 #include "ui/gfx/native_widget_types.h"
     17 
     18 
     19 class GURL;
     20 class Profile;
     21 class WebsiteSettings;
     22 namespace content {
     23 struct SSLStatus;
     24 }
     25 
     26 namespace gfx {
     27 class Image;
     28 }
     29 
     30 // The class |WebsiteSettingsUI| specifies the platform independent
     31 // interface of the website settings UI. The website settings UI displays
     32 // information and controls for site specific data (local stored objects like
     33 // cookies), site specific permissions (location, popup, plugin, etc.
     34 // permissions) and site specific information (identity, connection status,
     35 // etc.).
     36 class WebsiteSettingsUI {
     37  public:
     38   // The Website Settings UI contains several tabs. Each tab is assiciated with
     39   // a unique tab id. The enum |TabId| contains all the ids for the tabs.
     40   enum TabId {
     41     TAB_ID_PERMISSIONS = 0,
     42     TAB_ID_CONNECTION,
     43     NUM_TAB_IDS,
     44   };
     45 
     46   // |CookieInfo| contains information about the cookies from a specific source.
     47   // A source can for example be a specific origin or an entire domain.
     48   struct CookieInfo {
     49     CookieInfo();
     50 
     51     // String describing the cookie source.
     52     std::string cookie_source;
     53     // The number of allowed cookies.
     54     int allowed;
     55     // The number of blocked cookies.
     56     int blocked;
     57   };
     58 
     59   // |PermissionInfo| contains information about a single permission |type| for
     60   // the current website.
     61   struct PermissionInfo {
     62     PermissionInfo();
     63     // Site permission |type|.
     64     ContentSettingsType type;
     65     // The current value for the permission |type| (e.g. ALLOW or BLOCK).
     66     ContentSetting setting;
     67     // The global default settings for this permission |type|.
     68     ContentSetting default_setting;
     69     // The settings source e.g. user, extensions, policy, ... .
     70     content_settings::SettingSource source;
     71   };
     72 
     73   // |IdentityInfo| contains information about the site's identity and
     74   // connection.
     75   struct IdentityInfo {
     76     IdentityInfo();
     77     ~IdentityInfo();
     78 
     79     // The site's identity.
     80     std::string site_identity;
     81     // Status of the site's identity.
     82     WebsiteSettings::SiteIdentityStatus identity_status;
     83     // Helper to get the status text to display to the user.
     84     base::string16 GetIdentityStatusText() const;
     85     // Textual description of the site's identity status that is displayed to
     86     // the user.
     87     std::string identity_status_description;
     88     // The ID is the server certificate of a secure connection or 0.
     89     int cert_id;
     90     // Signed Certificate Timestamp ids and status
     91     content::SignedCertificateTimestampIDStatusList
     92         signed_certificate_timestamp_ids;
     93     // Status of the site's connection.
     94     WebsiteSettings::SiteConnectionStatus connection_status;
     95     // Textual description of the site's connection status that is displayed to
     96     // the user.
     97     std::string connection_status_description;
     98     // Set when the user has explicitly bypassed an SSL error for this host and
     99     // has a flag set to remember ssl decisions (explicit flag or in the
    100     // experimental group).  When |show_ssl_decision_revoke_button| is true, the
    101     // connection area of the page info will include an option for the user to
    102     // revoke their decision to bypass the SSL error for this host.
    103     bool show_ssl_decision_revoke_button;
    104   };
    105 
    106   typedef std::vector<CookieInfo> CookieInfoList;
    107   typedef std::vector<PermissionInfo> PermissionInfoList;
    108 
    109   virtual ~WebsiteSettingsUI();
    110 
    111   // Returns the UI string for the given permission |type|.
    112   static base::string16 PermissionTypeToUIString(ContentSettingsType type);
    113 
    114   // Returns the UI string for the given permission |value|, used in the
    115   // permission-changing menu. Generally this will be a verb in the imperative
    116   // form, e.g. "ask", "allow", "block".
    117   static base::string16 PermissionValueToUIString(ContentSetting value);
    118 
    119   // Returns the UI string describing the action taken for a permission,
    120   // including why that action was taken. E.g. "Allowed by you",
    121   // "Blocked by default".
    122   static base::string16 PermissionActionToUIString(
    123       ContentSetting setting,
    124       ContentSetting default_setting,
    125       content_settings::SettingSource source);
    126 
    127   // Returns the icon resource ID for the given permission |type| and |setting|.
    128   static int GetPermissionIconID(ContentSettingsType type,
    129                                  ContentSetting setting);
    130 
    131   // Returns the icon for the given permissionInfo |info|.  If |info|'s current
    132   // setting is CONTENT_SETTING_DEFAULT, it will return the icon for |info|'s
    133   // default setting.
    134   static const gfx::Image& GetPermissionIcon(const PermissionInfo& info);
    135 
    136   // Returns the identity icon ID for the given identity |status|.
    137   static int GetIdentityIconID(WebsiteSettings::SiteIdentityStatus status);
    138 
    139   // Returns the identity icon for the given identity |status|.
    140   static const gfx::Image& GetIdentityIcon(
    141       WebsiteSettings::SiteIdentityStatus status);
    142 
    143   // Returns the connection icon ID for the given connection |status|.
    144   static int GetConnectionIconID(
    145       WebsiteSettings::SiteConnectionStatus status);
    146 
    147   // Returns the connection icon for the given connection |status|.
    148   static const gfx::Image& GetConnectionIcon(
    149       WebsiteSettings::SiteConnectionStatus status);
    150 
    151   // Returns the icon ID to show along with the first visit information.
    152   static int GetFirstVisitIconID(const base::string16& first_visit);
    153 
    154   // Returns the icon to show along with the first visit information.
    155   static const gfx::Image& GetFirstVisitIcon(const base::string16& first_visit);
    156 
    157   // Sets cookie information.
    158   virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
    159 
    160   // Sets permision information.
    161   virtual void SetPermissionInfo(
    162       const PermissionInfoList& permission_info_list) = 0;
    163 
    164   // Sets site identity information.
    165   virtual void SetIdentityInfo(const IdentityInfo& identity_info) = 0;
    166 
    167   // Sets the first visited data. |first_visit| can be an empty string.
    168   virtual void SetFirstVisit(const base::string16& first_visit) = 0;
    169 
    170   // Selects the tab with the given |tab_id|.
    171   virtual void SetSelectedTab(TabId tab_id) = 0;
    172 };
    173 
    174 typedef WebsiteSettingsUI::CookieInfoList CookieInfoList;
    175 typedef WebsiteSettingsUI::PermissionInfoList PermissionInfoList;
    176 
    177 #endif  // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_
    178