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_PAGE_INFO_WEBSITE_SETTINGS_H_ | |
6 #define CHROME_BROWSER_UI_PAGE_INFO_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.page_info | |
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, ContentSetting value); | |
132 | |
133 // This method is called whenever access to an object is revoked. | |
134 void OnSiteChosenObjectDeleted(const ChooserUIInfo& ui_info, | |
135 const base::DictionaryValue& object); | |
136 | |
137 // This method is called by the UI when the UI is closing. | |
138 void OnUIClosing(); | |
139 | |
140 // This method is called when the revoke SSL error bypass button is pressed. | |
141 void OnRevokeSSLErrorBypassButtonPressed(); | |
142 | |
143 // Accessors. | |
144 SiteConnectionStatus site_connection_status() const { | |
145 return site_connection_status_; | |
146 } | |
147 | |
148 const GURL& site_url() const { return site_url_; } | |
149 | |
150 SiteIdentityStatus site_identity_status() const { | |
151 return site_identity_status_; | |
152 } | |
153 | |
154 base::string16 organization_name() const { return organization_name_; } | |
155 | |
156 // SiteDataObserver implementation. | |
157 void OnSiteDataAccessed() override; | |
158 | |
159 private: | |
160 // Initializes the |WebsiteSettings|. | |
161 void Init(const GURL& url, const security_state::SecurityInfo& security_info); | |
162 | |
163 // Sets (presents) the information about the site's permissions in the |ui_|. | |
164 void PresentSitePermissions(); | |
165 | |
166 // Sets (presents) the information about the site's data in the |ui_|. | |
167 void PresentSiteData(); | |
168 | |
169 // Sets (presents) the information about the site's identity and connection | |
170 // in the |ui_|. | |
171 void PresentSiteIdentity(); | |
172 | |
173 // The website settings UI displays information and controls for site- | |
174 // specific data (local stored objects like cookies), site-specific | |
175 // permissions (location, pop-up, plugin, etc. permissions) and site-specific | |
176 // information (identity, connection status, etc.). | |
177 WebsiteSettingsUI* ui_; | |
178 | |
179 // The flag that controls whether an infobar is displayed after the website | |
180 // settings UI is closed or not. | |
181 bool show_info_bar_; | |
182 | |
183 // The Omnibox URL of the website for which to display site permissions and | |
184 // site information. | |
185 GURL site_url_; | |
186 | |
187 // Status of the website's identity verification check. | |
188 SiteIdentityStatus site_identity_status_; | |
189 | |
190 // For secure connection |certificate_| is set to the server certificate. | |
191 scoped_refptr<net::X509Certificate> certificate_; | |
192 | |
193 // Status of the connection to the website. | |
194 SiteConnectionStatus site_connection_status_; | |
195 | |
196 // TODO(markusheintz): Move the creation of all the base::string16 typed UI | |
197 // strings below to the corresponding UI code, in order to prevent | |
198 // unnecessary UTF-8 string conversions. | |
199 | |
200 // Details about the website's identity. If the website's identity has been | |
201 // verified then |site_identity_details_| contains who verified the identity. | |
202 // This string will be displayed in the UI. | |
203 base::string16 site_identity_details_; | |
204 | |
205 // Set when the user has explicitly bypassed an SSL error for this host or | |
206 // explicitly denied it (the latter of which is not currently possible in the | |
207 // Chrome UI). When |show_ssl_decision_revoke_button| is true, the connection | |
208 // area of the page info will include an option for the user to revoke their | |
209 // decision to bypass the SSL error for this host. | |
210 bool show_ssl_decision_revoke_button_; | |
211 | |
212 // Details about the connection to the website. In case of an encrypted | |
213 // connection |site_connection_details_| contains encryption details, like | |
214 // encryption strength and ssl protocol version. This string will be | |
215 // displayed in the UI. | |
216 base::string16 site_connection_details_; | |
217 | |
218 // For websites that provided an EV certificate |orgainization_name_| | |
219 // contains the organization name of the certificate. In all other cases | |
220 // |organization_name| is an empty string. This string will be displayed in | |
221 // the UI. | |
222 base::string16 organization_name_; | |
223 | |
224 // The |HostContentSettingsMap| is the service that provides and manages | |
225 // content settings (aka. site permissions). | |
226 HostContentSettingsMap* content_settings_; | |
227 | |
228 // Service for managing SSL error page bypasses. Used to revoke bypass | |
229 // decisions by users. | |
230 ChromeSSLHostStateDelegate* chrome_ssl_host_state_delegate_; | |
231 | |
232 bool did_revoke_user_ssl_decisions_; | |
233 | |
234 Profile* profile_; | |
235 | |
236 security_state::SecurityLevel security_level_; | |
237 | |
238 DISALLOW_COPY_AND_ASSIGN(WebsiteSettings); | |
239 }; | |
240 | |
241 #endif // CHROME_BROWSER_UI_PAGE_INFO_WEBSITE_SETTINGS_H_ | |
OLD | NEW |