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
{
64 // Site permission |type|.
65 ContentSettingsType type
;
66 // The current value for the permission |type| (e.g. ALLOW or BLOCK).
67 ContentSetting setting
;
68 // The global default settings for this permission |type|.
69 ContentSetting default_setting
;
70 // The settings source e.g. user, extensions, policy, ... .
71 content_settings::SettingSource source
;
74 // |IdentityInfo| contains information about the site's identity and
80 // The site's identity.
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
GetIdentityStatusText() const;
86 // Textual description of the site's identity status that is displayed to
88 std::string identity_status_description
;
89 // The ID is the server certificate of a secure connection or 0.
91 // Signed Certificate Timestamp ids and status
92 content::SignedCertificateTimestampIDStatusList
93 signed_certificate_timestamp_ids
;
94 // Status of the site's connection.
95 WebsiteSettings::SiteConnectionStatus connection_status
;
96 // Textual description of the site's connection status that is displayed to
98 std::string connection_status_description
;
101 typedef std::vector
<CookieInfo
> CookieInfoList
;
102 typedef std::vector
<PermissionInfo
> PermissionInfoList
;
104 virtual ~WebsiteSettingsUI();
106 // Returns the UI string for the given permission |type|.
107 static base::string16
PermissionTypeToUIString(ContentSettingsType type
);
109 // Returns the UI string for the given permission |value|, used in the
110 // permission-changing menu. Generally this will be a verb in the imperative
111 // form, e.g. "ask", "allow", "block".
112 static base::string16
PermissionValueToUIString(ContentSetting value
);
114 // Returns the UI string describing the action taken for a permission,
115 // including why that action was taken. E.g. "Allowed by you",
116 // "Blocked by default".
117 static base::string16
PermissionActionToUIString(
118 ContentSetting setting
,
119 ContentSetting default_setting
,
120 content_settings::SettingSource source
);
122 // Returns the icon resource ID for the given permission |type| and |setting|.
123 static int GetPermissionIconID(ContentSettingsType type
,
124 ContentSetting setting
);
126 // Returns the icon for the given permission |type| and |setting|.
127 static const gfx::Image
& GetPermissionIcon(ContentSettingsType type
,
128 ContentSetting setting
);
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_