| 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_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/strings/string16.h" | |
| 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | |
| 11 #include "components/content_settings/core/common/content_settings.h" | |
| 12 #include "components/content_settings/core/common/content_settings_types.h" | |
| 13 #include "components/security_state/core/security_state.h" | |
| 14 #include "content/public/browser/web_contents_observer.h" | |
| 15 #include "url/gurl.h" | |
| 16 | |
| 17 namespace content { | |
| 18 class WebContents; | |
| 19 } | |
| 20 | |
| 21 namespace net { | |
| 22 class X509Certificate; | |
| 23 } | |
| 24 | |
| 25 class ChromeSSLHostStateDelegate; | |
| 26 class ChooserContextBase; | |
| 27 class HostContentSettingsMap; | |
| 28 class Profile; | |
| 29 class WebsiteSettingsUI; | |
| 30 | |
| 31 // The |WebsiteSettings| provides information about a website's permissions, | |
| 32 // connection state and its identity. It owns a UI that displays the | |
| 33 // information and allows users to change the permissions. |WebsiteSettings| | |
| 34 // objects must be created on the heap. They destroy themselves after the UI is | |
| 35 // closed. | |
| 36 class WebsiteSettings : public TabSpecificContentSettings::SiteDataObserver, | |
| 37 public content::WebContentsObserver { | |
| 38 public: | |
| 39 // TODO(palmer): Figure out if it is possible to unify SiteConnectionStatus | |
| 40 // and SiteIdentityStatus. | |
| 41 // | |
| 42 // Status of a connection to a website. | |
| 43 enum SiteConnectionStatus { | |
| 44 SITE_CONNECTION_STATUS_UNKNOWN = 0, // No status available. | |
| 45 SITE_CONNECTION_STATUS_ENCRYPTED, // Connection is encrypted. | |
| 46 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE, // Non-secure passive | |
| 47 // content. | |
| 48 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE, // Non-secure active | |
| 49 // content. | |
| 50 SITE_CONNECTION_STATUS_UNENCRYPTED, // Connection is not encrypted. | |
| 51 SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, // Connection error occurred. | |
| 52 SITE_CONNECTION_STATUS_INTERNAL_PAGE, // Internal site. | |
| 53 }; | |
| 54 | |
| 55 // Validation status of a website's identity. | |
| 56 enum SiteIdentityStatus { | |
| 57 // No status about the website's identity available. | |
| 58 SITE_IDENTITY_STATUS_UNKNOWN = 0, | |
| 59 // The website provided a valid certificate. | |
| 60 SITE_IDENTITY_STATUS_CERT, | |
| 61 // The website provided a valid EV certificate. | |
| 62 SITE_IDENTITY_STATUS_EV_CERT, | |
| 63 // The website provided a valid certificate but no revocation check could be | |
| 64 // performed. | |
| 65 SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN, | |
| 66 // Site identity could not be verified because the site did not provide a | |
| 67 // certificate. This is the expected state for HTTP connections. | |
| 68 SITE_IDENTITY_STATUS_NO_CERT, | |
| 69 // An error occured while verifying the site identity. | |
| 70 SITE_IDENTITY_STATUS_ERROR, | |
| 71 // The site is a trusted internal chrome page. | |
| 72 SITE_IDENTITY_STATUS_INTERNAL_PAGE, | |
| 73 // The profile has accessed data using an administrator-provided | |
| 74 // certificate, so the administrator might be able to intercept data. | |
| 75 SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT, | |
| 76 // The website provided a valid certificate, but the certificate or chain | |
| 77 // is using a deprecated signature algorithm. | |
| 78 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM, | |
| 79 // The website has been flagged by Safe Browsing as dangerous for | |
| 80 // containing malware, social engineering, or unwanted software. | |
| 81 SITE_IDENTITY_STATUS_MALWARE, | |
| 82 SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING, | |
| 83 SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE, | |
| 84 }; | |
| 85 | |
| 86 // UMA statistics for WebsiteSettings. Do not reorder or remove existing | |
| 87 // fields. A Java counterpart will be generated for this enum. | |
| 88 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.pageinfo | |
| 89 enum WebsiteSettingsAction { | |
| 90 WEBSITE_SETTINGS_OPENED = 0, | |
| 91 // No longer used; indicated actions for the old version of Page Info that | |
| 92 // had a "Permissions" tab and a "Connection" tab. | |
| 93 // WEBSITE_SETTINGS_PERMISSIONS_TAB_SELECTED = 1, | |
| 94 // WEBSITE_SETTINGS_CONNECTION_TAB_SELECTED = 2, | |
| 95 // WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY = 3, | |
| 96 WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED = 4, | |
| 97 WEBSITE_SETTINGS_CHANGED_PERMISSION = 5, | |
| 98 WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED = 6, | |
| 99 // No longer used; indicated a UI viewer for SCTs. | |
| 100 // WEBSITE_SETTINGS_TRANSPARENCY_VIEWER_OPENED = 7, | |
| 101 WEBSITE_SETTINGS_CONNECTION_HELP_OPENED = 8, | |
| 102 WEBSITE_SETTINGS_SITE_SETTINGS_OPENED = 9, | |
| 103 WEBSITE_SETTINGS_SECURITY_DETAILS_OPENED = 10, | |
| 104 WEBSITE_SETTINGS_COUNT | |
| 105 }; | |
| 106 | |
| 107 struct ChooserUIInfo { | |
| 108 ContentSettingsType content_settings_type; | |
| 109 ChooserContextBase* (*get_context)(Profile*); | |
| 110 int blocked_icon_id; | |
| 111 int allowed_icon_id; | |
| 112 int label_string_id; | |
| 113 int delete_tooltip_string_id; | |
| 114 const char* ui_name_key; | |
| 115 }; | |
| 116 | |
| 117 // Creates a WebsiteSettings for the passed |url| using the given |ssl| status | |
| 118 // object to determine the status of the site's connection. The | |
| 119 // |WebsiteSettings| takes ownership of the |ui|. | |
| 120 WebsiteSettings(WebsiteSettingsUI* ui, | |
| 121 Profile* profile, | |
| 122 TabSpecificContentSettings* tab_specific_content_settings, | |
| 123 content::WebContents* web_contents, | |
| 124 const GURL& url, | |
| 125 const security_state::SecurityInfo& security_info); | |
| 126 ~WebsiteSettings() override; | |
| 127 | |
| 128 void RecordWebsiteSettingsAction(WebsiteSettingsAction action); | |
| 129 | |
| 130 // This method is called when ever a permission setting is changed. | |
| 131 void OnSitePermissionChanged(ContentSettingsType type, | |
| 132 ContentSetting value); | |
| 133 | |
| 134 // This method is called whenever access to an object is revoked. | |
| 135 void OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info, | |
| 136 const base::DictionaryValue& object); | |
| 137 | |
| 138 // This method is called by the UI when the UI is closing. | |
| 139 void OnUIClosing(); | |
| 140 | |
| 141 // This method is called when the revoke SSL error bypass button is pressed. | |
| 142 void OnRevokeSSLErrorBypassButtonPressed(); | |
| 143 | |
| 144 // Accessors. | |
| 145 SiteConnectionStatus site_connection_status() const { | |
| 146 return site_connection_status_; | |
| 147 } | |
| 148 | |
| 149 const GURL& site_url() const { return site_url_; } | |
| 150 | |
| 151 SiteIdentityStatus site_identity_status() const { | |
| 152 return site_identity_status_; | |
| 153 } | |
| 154 | |
| 155 base::string16 organization_name() const { | |
| 156 return organization_name_; | |
| 157 } | |
| 158 | |
| 159 // SiteDataObserver implementation. | |
| 160 void OnSiteDataAccessed() override; | |
| 161 | |
| 162 private: | |
| 163 // Initializes the |WebsiteSettings|. | |
| 164 void Init(const GURL& url, const security_state::SecurityInfo& security_info); | |
| 165 | |
| 166 // Sets (presents) the information about the site's permissions in the |ui_|. | |
| 167 void PresentSitePermissions(); | |
| 168 | |
| 169 // Sets (presents) the information about the site's data in the |ui_|. | |
| 170 void PresentSiteData(); | |
| 171 | |
| 172 // Sets (presents) the information about the site's identity and connection | |
| 173 // in the |ui_|. | |
| 174 void PresentSiteIdentity(); | |
| 175 | |
| 176 // The website settings UI displays information and controls for site- | |
| 177 // specific data (local stored objects like cookies), site-specific | |
| 178 // permissions (location, pop-up, plugin, etc. permissions) and site-specific | |
| 179 // information (identity, connection status, etc.). | |
| 180 WebsiteSettingsUI* ui_; | |
| 181 | |
| 182 // The flag that controls whether an infobar is displayed after the website | |
| 183 // settings UI is closed or not. | |
| 184 bool show_info_bar_; | |
| 185 | |
| 186 // The Omnibox URL of the website for which to display site permissions and | |
| 187 // site information. | |
| 188 GURL site_url_; | |
| 189 | |
| 190 // Status of the website's identity verification check. | |
| 191 SiteIdentityStatus site_identity_status_; | |
| 192 | |
| 193 // For secure connection |certificate_| is set to the server certificate. | |
| 194 scoped_refptr<net::X509Certificate> certificate_; | |
| 195 | |
| 196 // Status of the connection to the website. | |
| 197 SiteConnectionStatus site_connection_status_; | |
| 198 | |
| 199 // TODO(markusheintz): Move the creation of all the base::string16 typed UI | |
| 200 // strings below to the corresponding UI code, in order to prevent | |
| 201 // unnecessary UTF-8 string conversions. | |
| 202 | |
| 203 // Details about the website's identity. If the website's identity has been | |
| 204 // verified then |site_identity_details_| contains who verified the identity. | |
| 205 // This string will be displayed in the UI. | |
| 206 base::string16 site_identity_details_; | |
| 207 | |
| 208 // Set when the user has explicitly bypassed an SSL error for this host or | |
| 209 // explicitly denied it (the latter of which is not currently possible in the | |
| 210 // Chrome UI). When |show_ssl_decision_revoke_button| is true, the connection | |
| 211 // area of the page info will include an option for the user to revoke their | |
| 212 // decision to bypass the SSL error for this host. | |
| 213 bool show_ssl_decision_revoke_button_; | |
| 214 | |
| 215 // Details about the connection to the website. In case of an encrypted | |
| 216 // connection |site_connection_details_| contains encryption details, like | |
| 217 // encryption strength and ssl protocol version. This string will be | |
| 218 // displayed in the UI. | |
| 219 base::string16 site_connection_details_; | |
| 220 | |
| 221 // For websites that provided an EV certificate |orgainization_name_| | |
| 222 // contains the organization name of the certificate. In all other cases | |
| 223 // |organization_name| is an empty string. This string will be displayed in | |
| 224 // the UI. | |
| 225 base::string16 organization_name_; | |
| 226 | |
| 227 // The |HostContentSettingsMap| is the service that provides and manages | |
| 228 // content settings (aka. site permissions). | |
| 229 HostContentSettingsMap* content_settings_; | |
| 230 | |
| 231 // Service for managing SSL error page bypasses. Used to revoke bypass | |
| 232 // decisions by users. | |
| 233 ChromeSSLHostStateDelegate* chrome_ssl_host_state_delegate_; | |
| 234 | |
| 235 bool did_revoke_user_ssl_decisions_; | |
| 236 | |
| 237 Profile* profile_; | |
| 238 | |
| 239 security_state::SecurityLevel security_level_; | |
| 240 | |
| 241 DISALLOW_COPY_AND_ASSIGN(WebsiteSettings); | |
| 242 }; | |
| 243 | |
| 244 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_H_ | |
| OLD | NEW |