Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / website_settings / website_settings.h
blob6ff39e86f07002ffe0cc23dd59af4691eab90f2f
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 "components/content_settings/core/common/content_settings.h"
14 #include "components/content_settings/core/common/content_settings_types.h"
15 #include "components/history/core/browser/history_service.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 // TODO(palmer): Figure out if it is possible to unify SiteConnectionStatus
39 // and SiteIdentityStatus.
41 // Status of a connection to a website.
42 enum SiteConnectionStatus {
43 SITE_CONNECTION_STATUS_UNKNOWN = 0, // No status available.
44 SITE_CONNECTION_STATUS_ENCRYPTED, // Connection is encrypted.
45 SITE_CONNECTION_STATUS_MIXED_CONTENT, // Site has unencrypted content.
46 SITE_CONNECTION_STATUS_UNENCRYPTED, // Connection is not encrypted.
47 SITE_CONNECTION_STATUS_ENCRYPTED_ERROR, // Connection error occured.
48 SITE_CONNECTION_STATUS_INTERNAL_PAGE, // Internal site.
51 // Validation status of a website's identity.
52 enum SiteIdentityStatus {
53 // No status about the website's identity available.
54 SITE_IDENTITY_STATUS_UNKNOWN = 0,
55 // The website provided a valid certificate.
56 SITE_IDENTITY_STATUS_CERT,
57 // The website provided a valid EV certificate.
58 SITE_IDENTITY_STATUS_EV_CERT,
59 // The website provided a valid certificate but no revocation check could be
60 // performed.
61 SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN,
62 // Site identity could not be verified because the site did not provide a
63 // certificate. This is the expected state for HTTP connections.
64 SITE_IDENTITY_STATUS_NO_CERT,
65 // An error occured while verifying the site identity.
66 SITE_IDENTITY_STATUS_ERROR,
67 // The site is a trusted internal chrome page.
68 SITE_IDENTITY_STATUS_INTERNAL_PAGE,
69 // The profile has accessed data using an administrator-provided
70 // certificate, so the site might be able to intercept data.
71 SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT,
72 // The website provided a valid certificate, but the certificate or chain
73 // is using a deprecated signature algorithm.
74 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM,
77 // UMA statistics for WebsiteSettings. Do not reorder or remove existing
78 // fields.
79 enum WebsiteSettingsAction {
80 WEBSITE_SETTINGS_OPENED = 0,
81 WEBSITE_SETTINGS_PERMISSIONS_TAB_SELECTED = 1,
82 WEBSITE_SETTINGS_CONNECTION_TAB_SELECTED = 2,
83 WEBSITE_SETTINGS_CONNECTION_TAB_SHOWN_IMMEDIATELY = 3,
84 WEBSITE_SETTINGS_COOKIES_DIALOG_OPENED = 4,
85 WEBSITE_SETTINGS_CHANGED_PERMISSION = 5,
86 WEBSITE_SETTINGS_CERTIFICATE_DIALOG_OPENED = 6,
87 // No longer used; indicated a UI viewer for SCTs.
88 // WEBSITE_SETTINGS_TRANSPARENCY_VIEWER_OPENED = 7,
89 WEBSITE_SETTINGS_CONNECTION_HELP_OPENED = 8,
90 WEBSITE_SETTINGS_SITE_SETTINGS_OPENED = 9,
91 WEBSITE_SETTINGS_COUNT
94 // Creates a WebsiteSettings for the passed |url| using the given |ssl| status
95 // object to determine the status of the site's connection. The
96 // |WebsiteSettings| takes ownership of the |ui|.
97 WebsiteSettings(WebsiteSettingsUI* ui,
98 Profile* profile,
99 TabSpecificContentSettings* tab_specific_content_settings,
100 InfoBarService* infobar_service,
101 const GURL& url,
102 const content::SSLStatus& ssl,
103 content::CertStore* cert_store);
104 ~WebsiteSettings() override;
106 void RecordWebsiteSettingsAction(WebsiteSettingsAction action);
108 // This method is called when ever a permission setting is changed.
109 void OnSitePermissionChanged(ContentSettingsType type,
110 ContentSetting value);
112 // Callback used for requests to fetch the number of page visits from history
113 // service and the time of the first visit.
114 void OnGotVisitCountToHost(bool found_visits,
115 int visit_count,
116 base::Time first_visit);
118 // This method is called by the UI when the UI is closing.
119 void OnUIClosing();
121 // This method is called when the revoke SSL error bypass button is pressed.
122 void OnRevokeSSLErrorBypassButtonPressed();
124 // Accessors.
125 SiteConnectionStatus site_connection_status() const {
126 return site_connection_status_;
129 const GURL& site_url() const { return site_url_; }
131 SiteIdentityStatus site_identity_status() const {
132 return site_identity_status_;
135 base::string16 site_connection_details() const {
136 return site_connection_details_;
139 base::string16 site_identity_details() const {
140 return site_identity_details_;
143 base::string16 organization_name() const {
144 return organization_name_;
147 // SiteDataObserver implementation.
148 void OnSiteDataAccessed() override;
150 private:
151 // Initializes the |WebsiteSettings|.
152 void Init(Profile* profile,
153 const GURL& url,
154 const content::SSLStatus& ssl);
156 // Sets (presents) the information about the site's permissions in the |ui_|.
157 void PresentSitePermissions();
159 // Sets (presents) the information about the site's data in the |ui_|.
160 void PresentSiteData();
162 // Sets (presents) the information about the site's identity and connection
163 // in the |ui_|.
164 void PresentSiteIdentity();
166 // Sets (presents) history information about the site in the |ui_|. Passing
167 // base::Time() as value for |first_visit| will clear the history information
168 // in the UI.
169 void PresentHistoryInfo(base::Time first_visit);
171 // The website settings UI displays information and controls for site
172 // specific data (local stored objects like cookies), site specific
173 // permissions (location, popup, plugin, etc. permissions) and site specific
174 // information (identity, connection status, etc.).
175 WebsiteSettingsUI* ui_;
177 // The infobar service of the active tab.
178 InfoBarService* infobar_service_;
180 // The flag that controls whether an infobar is displayed after the website
181 // settings UI is closed or not.
182 bool show_info_bar_;
184 // The Omnibox URL of the website for which to display site permissions and
185 // site information.
186 GURL site_url_;
188 // Status of the website's identity verification check.
189 SiteIdentityStatus site_identity_status_;
191 // For secure connection |cert_id_| is set to the ID of the server
192 // certificate. For non secure connections |cert_id_| is 0.
193 int cert_id_;
194 // For secure connection, |signed_certificate_timestamp_ids_| is the list of
195 // all Signed Certificate Timestamps and their validation status.
196 // Empty if no SCTs accompanied the certificate
197 content::SignedCertificateTimestampIDStatusList
198 signed_certificate_timestamp_ids_;
200 // Status of the connection to the website.
201 SiteConnectionStatus site_connection_status_;
203 // TODO(markusheintz): Move the creation of all the base::string16 typed UI
204 // strings below to the corresponding UI code, in order to prevent
205 // unnecessary UTF-8 string conversions.
207 // Details about the website's identity. If the website's identity has been
208 // verified then |site_identity_details_| contains who verified the identity.
209 // This string will be displayed in the UI.
210 base::string16 site_identity_details_;
212 // Set when the user has explicitly bypassed an SSL error for this host or
213 // explicitly denied it (the latter of which is not currently possible in the
214 // Chrome UI) and has a flag set to remember ssl decisions (explicit flag or
215 // in the experimental group). When |show_ssl_decision_revoke_button| is
216 // true, the connection area of the page info will include an option for the
217 // user to revoke their decision to bypass the SSL error for this host.
218 bool show_ssl_decision_revoke_button_;
220 // Details about the connection to the website. In case of an encrypted
221 // connection |site_connection_details_| contains encryption details, like
222 // encryption strength and ssl protocol version. This string will be
223 // displayed in the UI.
224 base::string16 site_connection_details_;
226 // For websites that provided an EV certificate |orgainization_name_|
227 // contains the organization name of the certificate. In all other cases
228 // |organization_name| is an empty string. This string will be displayed in
229 // the UI.
230 base::string16 organization_name_;
232 // The |CertStore| provides all X509Certificates.
233 content::CertStore* cert_store_;
235 // The |HostContentSettingsMap| is the service that provides and manages
236 // content settings (aka. site permissions).
237 HostContentSettingsMap* content_settings_;
239 // Used to request the number of page visits.
240 base::CancelableTaskTracker visit_count_task_tracker_;
242 // Service for managing SSL error page bypasses. Used to revoke bypass
243 // decisions by users.
244 ChromeSSLHostStateDelegate* chrome_ssl_host_state_delegate_;
246 bool did_revoke_user_ssl_decisions_;
248 DISALLOW_COPY_AND_ASSIGN(WebsiteSettings);
251 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_H_