Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / website_settings / website_settings_ui.h
blobeb499ad3c2850f01cfe519469c04e7528b01033b
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_UI_H_
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_
8 #include <string>
9 #include <vector>
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/website_settings/website_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 "ui/gfx/native_widget_types.h"
17 class GURL;
18 class Profile;
19 class WebsiteSettings;
21 namespace gfx {
22 class Image;
25 // The class |WebsiteSettingsUI| specifies the platform independent
26 // interface of the website settings UI. The website settings UI displays
27 // information and controls for site specific data (local stored objects like
28 // cookies), site specific permissions (location, popup, plugin, etc.
29 // permissions) and site specific information (identity, connection status,
30 // etc.).
31 class WebsiteSettingsUI {
32 public:
33 // The Website Settings UI contains several tabs. Each tab is associated with
34 // a unique tab id. The enum |TabId| contains all the ids for the tabs.
35 enum TabId {
36 TAB_ID_PERMISSIONS = 0,
37 TAB_ID_CONNECTION,
38 NUM_TAB_IDS,
41 // |CookieInfo| contains information about the cookies from a specific source.
42 // A source can for example be a specific origin or an entire wildcard domain.
43 struct CookieInfo {
44 CookieInfo();
46 // String describing the cookie source.
47 std::string cookie_source;
48 // The number of allowed cookies.
49 int allowed;
50 // The number of blocked cookies.
51 int blocked;
53 // Whether these cookies are from the current top-level origin as seen by
54 // the user, or from third-party origins.
55 bool is_first_party;
58 // |PermissionInfo| contains information about a single permission |type| for
59 // the current website.
60 struct PermissionInfo {
61 PermissionInfo();
62 // Site permission |type|.
63 ContentSettingsType type;
64 // The current value for the permission |type| (e.g. ALLOW or BLOCK).
65 ContentSetting setting;
66 // The global default settings for this permission |type|.
67 ContentSetting default_setting;
68 // The settings source e.g. user, extensions, policy, ... .
69 content_settings::SettingSource source;
72 // |IdentityInfo| contains information about the site's identity and
73 // connection.
74 struct IdentityInfo {
75 IdentityInfo();
76 ~IdentityInfo();
78 // The site's identity: the certificate's Organization Name for sites with
79 // Extended Validation certificates, or the URL's hostname for all other
80 // sites.
81 std::string site_identity;
82 // Status of the site's identity.
83 WebsiteSettings::SiteIdentityStatus identity_status;
84 // Helper to get the status text to display to the user.
85 base::string16 GetSecuritySummary() const;
86 // Textual description of the site's identity status that is displayed to
87 // the user.
88 std::string identity_status_description;
89 // The ID is the server certificate of a secure connection or 0.
90 int cert_id;
91 // Status of the site's connection.
92 WebsiteSettings::SiteConnectionStatus connection_status;
93 // Textual description of the site's connection status that is displayed to
94 // the user.
95 std::string connection_status_description;
96 // Set when the user has explicitly bypassed an SSL error for this host and
97 // has a flag set to remember ssl decisions (explicit flag or in the
98 // experimental group). When |show_ssl_decision_revoke_button| is true, the
99 // connection area of the page info will include an option for the user to
100 // revoke their decision to bypass the SSL error for this host.
101 bool show_ssl_decision_revoke_button;
104 typedef std::vector<CookieInfo> CookieInfoList;
106 typedef std::vector<PermissionInfo> PermissionInfoList;
108 virtual ~WebsiteSettingsUI();
110 // Returns the UI string for the given permission |type|.
111 static base::string16 PermissionTypeToUIString(ContentSettingsType type);
113 // Returns the UI string for the given permission |value|, used in the
114 // permission-changing menu. Generally this will be a verb in the imperative
115 // form, e.g. "ask", "allow", "block".
116 static base::string16 PermissionValueToUIString(ContentSetting value);
118 // Returns the UI string describing the action taken for a permission,
119 // including why that action was taken. E.g. "Allowed by you",
120 // "Blocked by default".
121 static base::string16 PermissionActionToUIString(
122 ContentSettingsType type,
123 ContentSetting setting,
124 ContentSetting default_setting,
125 content_settings::SettingSource source);
127 // Returns the icon resource ID for the given permission |type| and |setting|.
128 static int GetPermissionIconID(ContentSettingsType type,
129 ContentSetting setting);
131 // Returns the icon for the given permissionInfo |info|. If |info|'s current
132 // setting is CONTENT_SETTING_DEFAULT, it will return the icon for |info|'s
133 // default setting.
134 static const gfx::Image& GetPermissionIcon(const PermissionInfo& info);
136 // Returns the identity icon ID for the given identity |status|.
137 static int GetIdentityIconID(WebsiteSettings::SiteIdentityStatus status);
139 // Returns the identity icon for the given identity |status|.
140 static const gfx::Image& GetIdentityIcon(
141 WebsiteSettings::SiteIdentityStatus status);
143 // Returns the connection icon ID for the given connection |status|.
144 static int GetConnectionIconID(
145 WebsiteSettings::SiteConnectionStatus status);
147 // Returns the connection icon for the given connection |status|.
148 static const gfx::Image& GetConnectionIcon(
149 WebsiteSettings::SiteConnectionStatus status);
151 // Sets cookie information.
152 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
154 // Sets permission information.
155 virtual void SetPermissionInfo(
156 const PermissionInfoList& permission_info_list) = 0;
158 // Sets site identity information.
159 virtual void SetIdentityInfo(const IdentityInfo& identity_info) = 0;
161 // Selects the tab with the given |tab_id|.
162 virtual void SetSelectedTab(TabId tab_id) = 0;
165 typedef WebsiteSettingsUI::CookieInfoList CookieInfoList;
166 typedef WebsiteSettingsUI::PermissionInfoList PermissionInfoList;
168 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_