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