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_
11 #include "base/strings/string16.h"
12 #include "chrome/browser/ui/website_settings/website_settings.h"
13 #include "chrome/common/content_settings.h"
14 #include "chrome/common/content_settings_types.h"
15 #include "content/public/common/signed_certificate_timestamp_id_and_status.h"
16 #include "ui/gfx/native_widget_types.h"
21 class WebsiteSettings;
30 // The class |WebsiteSettingsUI| specifies the platform independent
31 // interface of the website settings UI. The website settings UI displays
32 // information and controls for site specific data (local stored objects like
33 // cookies), site specific permissions (location, popup, plugin, etc.
34 // permissions) and site specific information (identity, connection status,
36 class WebsiteSettingsUI {
38 // The Website Settings UI contains several tabs. Each tab is assiciated with
39 // a unique tab id. The enum |TabId| contains all the ids for the tabs.
41 TAB_ID_PERMISSIONS = 0,
46 // |CookieInfo| contains information about the cookies from a specific source.
47 // A source can for example be a specific origin or an entire domain.
51 // String describing the cookie source.
52 std::string cookie_source;
53 // The number of allowed cookies.
55 // The number of blocked cookies.
59 // |PermissionInfo| contains information about a single permission |type| for
60 // the current website.
61 struct PermissionInfo {
63 // Site permission |type|.
64 ContentSettingsType type;
65 // The current value for the permission |type| (e.g. ALLOW or BLOCK).
66 ContentSetting setting;
67 // The global default settings for this permission |type|.
68 ContentSetting default_setting;
69 // The settings source e.g. user, extensions, policy, ... .
70 content_settings::SettingSource source;
73 // |IdentityInfo| contains information about the site's identity and
79 // The site's identity.
80 std::string site_identity;
81 // Status of the site's identity.
82 WebsiteSettings::SiteIdentityStatus identity_status;
83 // Helper to get the status text to display to the user.
84 base::string16 GetIdentityStatusText() const;
85 // Textual description of the site's identity status that is displayed to
87 std::string identity_status_description;
88 // The ID is the server certificate of a secure connection or 0.
90 // Signed Certificate Timestamp ids and status
91 content::SignedCertificateTimestampIDStatusList
92 signed_certificate_timestamp_ids;
93 // Status of the site's connection.
94 WebsiteSettings::SiteConnectionStatus connection_status;
95 // Textual description of the site's connection status that is displayed to
97 std::string connection_status_description;
100 typedef std::vector<CookieInfo> CookieInfoList;
101 typedef std::vector<PermissionInfo> PermissionInfoList;
103 virtual ~WebsiteSettingsUI();
105 // Returns the UI string for the given permission |type|.
106 static base::string16 PermissionTypeToUIString(ContentSettingsType type);
108 // Returns the UI string for the given permission |value|, used in the
109 // permission-changing menu. Generally this will be a verb in the imperative
110 // form, e.g. "ask", "allow", "block".
111 static base::string16 PermissionValueToUIString(ContentSetting value);
113 // Returns the UI string describing the action taken for a permission,
114 // including why that action was taken. E.g. "Allowed by you",
115 // "Blocked by default".
116 static base::string16 PermissionActionToUIString(
117 ContentSetting setting,
118 ContentSetting default_setting,
119 content_settings::SettingSource source);
121 // Returns the icon resource ID for the given permission |type| and |setting|.
122 static int GetPermissionIconID(ContentSettingsType type,
123 ContentSetting setting);
125 // Returns the icon for the given permissionInfo |info|. If |info|'s current
126 // setting is CONTENT_SETTING_DEFAULT, it will return the icon for |info|'s
128 static const gfx::Image& GetPermissionIcon(const PermissionInfo& info);
130 // Returns the identity icon ID for the given identity |status|.
131 static int GetIdentityIconID(WebsiteSettings::SiteIdentityStatus status);
133 // Returns the identity icon for the given identity |status|.
134 static const gfx::Image& GetIdentityIcon(
135 WebsiteSettings::SiteIdentityStatus status);
137 // Returns the connection icon ID for the given connection |status|.
138 static int GetConnectionIconID(
139 WebsiteSettings::SiteConnectionStatus status);
141 // Returns the connection icon for the given connection |status|.
142 static const gfx::Image& GetConnectionIcon(
143 WebsiteSettings::SiteConnectionStatus status);
145 // Returns the icon ID to show along with the first visit information.
146 static int GetFirstVisitIconID(const base::string16& first_visit);
148 // Returns the icon to show along with the first visit information.
149 static const gfx::Image& GetFirstVisitIcon(const base::string16& first_visit);
151 // Sets cookie information.
152 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
154 // Sets permision 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 // Sets the first visited data. |first_visit| can be an empty string.
162 virtual void SetFirstVisit(const base::string16& first_visit) = 0;
164 // Selects the tab with the given |tab_id|.
165 virtual void SetSelectedTab(TabId tab_id) = 0;
168 typedef WebsiteSettingsUI::CookieInfoList CookieInfoList;
169 typedef WebsiteSettingsUI::PermissionInfoList PermissionInfoList;
171 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_