Add button to page info to revoke user certificate decisions.
[chromium-blink-merge.git] / chrome / browser / ui / website_settings / website_settings.h
blob5b571e6165262ab01d24a389546f608beb7e5e7a
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.
5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_H_
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h"
10 #include "base/task/cancelable_task_tracker.h"
11 #include "base/time/time.h"
12 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
13 #include "chrome/browser/history/history_service.h"
14 #include "chrome/common/content_settings.h"
15 #include "components/content_settings/core/common/content_settings_types.h"
16 #include "content/public/common/signed_certificate_timestamp_id_and_status.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "url/gurl.h"
20 namespace content {
21 class CertStore;
22 struct SSLStatus;
25 class ChromeSSLHostStateDelegate;
26 class InfoBarService;
27 class HostContentSettingsMap;
28 class Profile;
29 class WebsiteSettingsUI;
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:
38 // Status of a connection to a website.
39 enum SiteConnectionStatus {
40 SITE_CONNECTION_STATUS_UNKNOWN = 0, // No status available.
41 SITE_CONNECTION_STATUS_ENCRYPTED, // Connection is encrypted.
42 SITE_CONNECTION_STATUS_MIXED_CONTENT, // Site has unencrypted content.
43 SITE_CONNECTION_STATUS_UNENCRYPTED, // Connection is not encrypted.
44 SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, // Connection error occured.
45 SITE_CONNECTION_STATUS_INTERNAL_PAGE, // Internal site.
48 // Validation status of a website's identity.
49 enum SiteIdentityStatus {
50 // No status about the website's identity available.
51 SITE_IDENTITY_STATUS_UNKNOWN = 0,
52 // The website provided a valid certificate.
53 SITE_IDENTITY_STATUS_CERT,
54 // The website provided a valid EV certificate.
55 SITE_IDENTITY_STATUS_EV_CERT,
56 // The website provided a valid certificate but no revocation check could be
57 // performed.
58 SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN,
59 // Site identity could not be verified because the site did not provide a
60 // certificate. This is the expected state for HTTP connections.
61 SITE_IDENTITY_STATUS_NO_CERT,
62 // An error occured while verifying the site identity.
63 SITE_IDENTITY_STATUS_ERROR,
64 // The site is a trusted internal chrome page.
65 SITE_IDENTITY_STATUS_INTERNAL_PAGE,
66 // The profile has accessed data using an administrator-provided
67 // certificate, so the site might be able to intercept data.
68 SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT,
71 // Creates a WebsiteSettings for the passed |url| using the given |ssl| status
72 // object to determine the status of the site's connection. The
73 // |WebsiteSettings| takes ownership of the |ui|.
74 WebsiteSettings(WebsiteSettingsUI* ui,
75 Profile* profile,
76 TabSpecificContentSettings* tab_specific_content_settings,
77 InfoBarService* infobar_service,
78 const GURL& url,
79 const content::SSLStatus& ssl,
80 content::CertStore* cert_store);
81 virtual ~WebsiteSettings();
83 // This method is called when ever a permission setting is changed.
84 void OnSitePermissionChanged(ContentSettingsType type,
85 ContentSetting value);
87 // Callback used for requests to fetch the number of page visits from history
88 // service and the time of the first visit.
89 void OnGotVisitCountToHost(bool found_visits,
90 int visit_count,
91 base::Time first_visit);
93 // This method is called by the UI when the UI is closing.
94 void OnUIClosing();
96 // Accessors.
97 SiteConnectionStatus site_connection_status() const {
98 return site_connection_status_;
101 const GURL& site_url() const { return site_url_; }
103 SiteIdentityStatus site_identity_status() const {
104 return site_identity_status_;
107 base::string16 site_connection_details() const {
108 return site_connection_details_;
111 base::string16 site_identity_details() const {
112 return site_identity_details_;
115 base::string16 organization_name() const {
116 return organization_name_;
119 ChromeSSLHostStateDelegate* chrome_ssl_host_state_delegate() {
120 return chrome_ssl_host_state_delegate_;
123 // SiteDataObserver implementation.
124 virtual void OnSiteDataAccessed() OVERRIDE;
126 private:
127 // Initializes the |WebsiteSettings|.
128 void Init(Profile* profile,
129 const GURL& url,
130 const content::SSLStatus& ssl);
132 // Sets (presents) the information about the site's permissions in the |ui_|.
133 void PresentSitePermissions();
135 // Sets (presents) the information about the site's data in the |ui_|.
136 void PresentSiteData();
138 // Sets (presents) the information about the site's identity and connection
139 // in the |ui_|.
140 void PresentSiteIdentity();
142 // Sets (presents) history information about the site in the |ui_|. Passing
143 // base::Time() as value for |first_visit| will clear the history information
144 // in the UI.
145 void PresentHistoryInfo(base::Time first_visit);
147 // The website settings UI displays information and controls for site
148 // specific data (local stored objects like cookies), site specific
149 // permissions (location, popup, plugin, etc. permissions) and site specific
150 // information (identity, connection status, etc.).
151 WebsiteSettingsUI* ui_;
153 // The infobar service of the active tab.
154 InfoBarService* infobar_service_;
156 // The flag that controls whether an infobar is displayed after the website
157 // settings UI is closed or not.
158 bool show_info_bar_;
160 // The Omnibox URL of the website for which to display site permissions and
161 // site information.
162 GURL site_url_;
164 // Status of the website's identity verification check.
165 SiteIdentityStatus site_identity_status_;
167 // For secure connection |cert_id_| is set to the ID of the server
168 // certificate. For non secure connections |cert_id_| is 0.
169 int cert_id_;
170 // For secure connection, |signed_certificate_timestamp_ids_| is the list of
171 // all Signed Certificate Timestamps and their validation status.
172 // Empty if no SCTs accompanied the certificate
173 content::SignedCertificateTimestampIDStatusList
174 signed_certificate_timestamp_ids_;
176 // Status of the connection to the website.
177 SiteConnectionStatus site_connection_status_;
179 // TODO(markusheintz): Move the creation of all the base::string16 typed UI
180 // strings below to the corresponding UI code, in order to prevent
181 // unnecessary UTF-8 string conversions.
183 // Details about the website's identity. If the website's identity has been
184 // verified then |site_identity_details_| contains who verified the identity.
185 // This string will be displayed in the UI.
186 base::string16 site_identity_details_;
188 // Set when the user has explicitly bypassed an SSL error for this host or
189 // explicitly denied it (the latter of which is not currently possible in the
190 // Chrome UI) and has a flag set to remember ssl decisions (explicit flag or
191 // in the experimental group). When |show_ssl_decision_revoke_button| is
192 // true, the connection area of the page info will include an option for the
193 // user to revoke their decision to bypass the SSL error for this host.
194 bool show_ssl_decision_revoke_button_;
196 // Details about the connection to the website. In case of an encrypted
197 // connection |site_connection_details_| contains encryption details, like
198 // encryption strength and ssl protocol version. This string will be
199 // displayed in the UI.
200 base::string16 site_connection_details_;
202 // For websites that provided an EV certificate |orgainization_name_|
203 // contains the organization name of the certificate. In all other cases
204 // |organization_name| is an empty string. This string will be displayed in
205 // the UI.
206 base::string16 organization_name_;
208 // The |CertStore| provides all X509Certificates.
209 content::CertStore* cert_store_;
211 // The |HostContentSettingsMap| is the service that provides and manages
212 // content settings (aka. site permissions).
213 HostContentSettingsMap* content_settings_;
215 // Used to request the number of page visits.
216 base::CancelableTaskTracker visit_count_task_tracker_;
218 // Service for managing SSL error page bypasses. Used to revoke bypass
219 // decisions by users.
220 ChromeSSLHostStateDelegate* chrome_ssl_host_state_delegate_;
222 DISALLOW_COPY_AND_ASSIGN(WebsiteSettings);
225 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_H_