| OLD | NEW |
| (Empty) |
| 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 <memory> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/strings/string16.h" | |
| 13 #include "chrome/browser/ui/website_settings/website_settings.h" | |
| 14 #include "components/content_settings/core/common/content_settings.h" | |
| 15 #include "components/content_settings/core/common/content_settings_types.h" | |
| 16 #include "ui/gfx/native_widget_types.h" | |
| 17 | |
| 18 class Profile; | |
| 19 class WebsiteSettings; | |
| 20 | |
| 21 namespace gfx { | |
| 22 class Image; | |
| 23 } | |
| 24 | |
| 25 namespace net { | |
| 26 class X509Certificate; | |
| 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 associated 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 // The security summary is styled depending on the security state. At the | |
| 46 // moment, the only styling we apply is color, but it could also include e.g. | |
| 47 // bolding. | |
| 48 enum SecuritySummaryStyle { STYLE_UNSTYLED = 0, STYLE_COLOR = 1 << 1 }; | |
| 49 | |
| 50 struct SecurityDescription { | |
| 51 // A one-line summary of the security state. | |
| 52 base::string16 summary; | |
| 53 // A short paragraph with more details about the state, and how | |
| 54 // the user should treat it. | |
| 55 base::string16 details; | |
| 56 }; | |
| 57 | |
| 58 // |CookieInfo| contains information about the cookies from a specific source. | |
| 59 // A source can for example be a specific origin or an entire wildcard domain. | |
| 60 struct CookieInfo { | |
| 61 CookieInfo(); | |
| 62 | |
| 63 // The number of allowed cookies. | |
| 64 int allowed; | |
| 65 // The number of blocked cookies. | |
| 66 int blocked; | |
| 67 | |
| 68 // Whether these cookies are from the current top-level origin as seen by | |
| 69 // the user, or from third-party origins. | |
| 70 bool is_first_party; | |
| 71 }; | |
| 72 | |
| 73 // |PermissionInfo| contains information about a single permission |type| for | |
| 74 // the current website. | |
| 75 struct PermissionInfo { | |
| 76 PermissionInfo(); | |
| 77 // Site permission |type|. | |
| 78 ContentSettingsType type; | |
| 79 // The current value for the permission |type| (e.g. ALLOW or BLOCK). | |
| 80 ContentSetting setting; | |
| 81 // The global default settings for this permission |type|. | |
| 82 ContentSetting default_setting; | |
| 83 // The settings source e.g. user, extensions, policy, ... . | |
| 84 content_settings::SettingSource source; | |
| 85 // Whether the profile is off the record. | |
| 86 bool is_incognito; | |
| 87 }; | |
| 88 | |
| 89 // |ChosenObjectInfo| contains information about a single |object| of a | |
| 90 // chooser |type| that the current website has been granted access to. | |
| 91 struct ChosenObjectInfo { | |
| 92 ChosenObjectInfo(const WebsiteSettings::ChooserUIInfo& ui_info, | |
| 93 std::unique_ptr<base::DictionaryValue> object); | |
| 94 ~ChosenObjectInfo(); | |
| 95 // |ui_info| for this chosen object type. | |
| 96 const WebsiteSettings::ChooserUIInfo& ui_info; | |
| 97 // The opaque |object| representing the thing the user selected. | |
| 98 std::unique_ptr<base::DictionaryValue> object; | |
| 99 }; | |
| 100 | |
| 101 // |IdentityInfo| contains information about the site's identity and | |
| 102 // connection. | |
| 103 struct IdentityInfo { | |
| 104 IdentityInfo(); | |
| 105 ~IdentityInfo(); | |
| 106 | |
| 107 // The site's identity: the certificate's Organization Name for sites with | |
| 108 // Extended Validation certificates, or the URL's hostname for all other | |
| 109 // sites. | |
| 110 std::string site_identity; | |
| 111 // Status of the site's identity. | |
| 112 WebsiteSettings::SiteIdentityStatus identity_status; | |
| 113 // Helper to get security description info to display to the user. | |
| 114 std::unique_ptr<SecurityDescription> GetSecurityDescription() const; | |
| 115 // Textual description of the site's identity status that is displayed to | |
| 116 // the user. | |
| 117 std::string identity_status_description; | |
| 118 // The server certificate if a secure connection. | |
| 119 scoped_refptr<net::X509Certificate> certificate; | |
| 120 // Status of the site's connection. | |
| 121 WebsiteSettings::SiteConnectionStatus connection_status; | |
| 122 // Textual description of the site's connection status that is displayed to | |
| 123 // the user. | |
| 124 std::string connection_status_description; | |
| 125 // Set when the user has explicitly bypassed an SSL error for this host and | |
| 126 // has a flag set to remember ssl decisions (explicit flag or in the | |
| 127 // experimental group). When |show_ssl_decision_revoke_button| is true, the | |
| 128 // connection area of the page info will include an option for the user to | |
| 129 // revoke their decision to bypass the SSL error for this host. | |
| 130 bool show_ssl_decision_revoke_button; | |
| 131 }; | |
| 132 | |
| 133 using CookieInfoList = std::vector<CookieInfo>; | |
| 134 using PermissionInfoList = std::vector<PermissionInfo>; | |
| 135 using ChosenObjectInfoList = std::vector<std::unique_ptr<ChosenObjectInfo>>; | |
| 136 | |
| 137 virtual ~WebsiteSettingsUI(); | |
| 138 | |
| 139 // Returns the UI string for the given permission |type|. | |
| 140 static base::string16 PermissionTypeToUIString(ContentSettingsType type); | |
| 141 | |
| 142 // Returns the UI string for the given permission |value|, used in the | |
| 143 // permission-changing menu. Generally this will be a verb in the imperative | |
| 144 // form, e.g. "ask", "allow", "block". | |
| 145 static base::string16 PermissionValueToUIString(ContentSetting value); | |
| 146 | |
| 147 // Returns the UI string describing the action taken for a permission, | |
| 148 // including why that action was taken. E.g. "Allowed by you", | |
| 149 // "Blocked by default". If |setting| is default, specify the actual default | |
| 150 // setting using |default_setting|. | |
| 151 static base::string16 PermissionActionToUIString( | |
| 152 Profile* profile, | |
| 153 ContentSettingsType type, | |
| 154 ContentSetting setting, | |
| 155 ContentSetting default_setting, | |
| 156 content_settings::SettingSource source); | |
| 157 | |
| 158 // Returns the icon resource ID for the given permission |type| and |setting|. | |
| 159 static int GetPermissionIconID(ContentSettingsType type, | |
| 160 ContentSetting setting); | |
| 161 | |
| 162 // Returns the icon for the given permissionInfo |info|. If |info|'s current | |
| 163 // setting is CONTENT_SETTING_DEFAULT, it will return the icon for |info|'s | |
| 164 // default setting. | |
| 165 static const gfx::Image& GetPermissionIcon(const PermissionInfo& info); | |
| 166 | |
| 167 // Returns the UI string describing the given object |info|. | |
| 168 static base::string16 ChosenObjectToUIString(const ChosenObjectInfo& info); | |
| 169 | |
| 170 // Returns the icon for the given object |info|. | |
| 171 static const gfx::Image& GetChosenObjectIcon(const ChosenObjectInfo& info, | |
| 172 bool deleted); | |
| 173 | |
| 174 // Returns the identity icon ID for the given identity |status|. | |
| 175 static int GetIdentityIconID(WebsiteSettings::SiteIdentityStatus status); | |
| 176 | |
| 177 // Returns the identity icon for the given identity |status|. | |
| 178 static const gfx::Image& GetIdentityIcon( | |
| 179 WebsiteSettings::SiteIdentityStatus status); | |
| 180 | |
| 181 // Returns the connection icon ID for the given connection |status|. | |
| 182 static int GetConnectionIconID( | |
| 183 WebsiteSettings::SiteConnectionStatus status); | |
| 184 | |
| 185 // Returns the connection icon for the given connection |status|. | |
| 186 static const gfx::Image& GetConnectionIcon( | |
| 187 WebsiteSettings::SiteConnectionStatus status); | |
| 188 | |
| 189 // Sets cookie information. | |
| 190 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0; | |
| 191 | |
| 192 // Sets permission information. | |
| 193 virtual void SetPermissionInfo( | |
| 194 const PermissionInfoList& permission_info_list, | |
| 195 ChosenObjectInfoList chosen_object_info_list) = 0; | |
| 196 | |
| 197 // Sets site identity information. | |
| 198 virtual void SetIdentityInfo(const IdentityInfo& identity_info) = 0; | |
| 199 }; | |
| 200 | |
| 201 typedef WebsiteSettingsUI::CookieInfoList CookieInfoList; | |
| 202 typedef WebsiteSettingsUI::PermissionInfoList PermissionInfoList; | |
| 203 typedef WebsiteSettingsUI::ChosenObjectInfoList ChosenObjectInfoList; | |
| 204 | |
| 205 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_ | |
| OLD | NEW |