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 "ui/gfx/native_widget_types.h"
20 class WebsiteSettings;
29 // The class |WebsiteSettingsUI| specifies the platform independent
30 // interface of the website settings UI. The website settings UI displays
31 // information and controls for site specific data (local stored objects like
32 // cookies), site specific permissions (location, popup, plugin, etc.
33 // permissions) and site specific information (identity, connection status,
35 class WebsiteSettingsUI {
37 // The Website Settings UI contains several tabs. Each tab is assiciated with
38 // a unique tab id. The enum |TabId| contains all the ids for the tabs.
40 TAB_ID_PERMISSIONS = 0,
45 // |CookieInfo| contains information about the cookies from a specific source.
46 // A source can for example be a specific origin or an entire domain.
50 // String describing the cookie source.
51 std::string cookie_source;
52 // The number of allowed cookies.
54 // The number of blocked cookies.
58 // |PermissionInfo| contains information about a single permission |type| for
59 // the current website.
60 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
78 // The site's identity.
79 std::string site_identity;
80 // Status of the site's identity.
81 WebsiteSettings::SiteIdentityStatus identity_status;
82 // Helper to get the status text to display to the user.
83 string16 GetIdentityStatusText() const;
84 // Textual description of the site's identity status that is displayed to
86 std::string identity_status_description;
87 // The ID is the server certificate of a secure connection or 0.
89 // Status of the site's connection.
90 WebsiteSettings::SiteConnectionStatus connection_status;
91 // Textual description of the site's connection status that is displayed to
93 std::string connection_status_description;
96 typedef std::vector<CookieInfo> CookieInfoList;
97 typedef std::vector<PermissionInfo> PermissionInfoList;
99 virtual ~WebsiteSettingsUI();
101 // Returns the UI string for the given permission |type|.
102 static string16 PermissionTypeToUIString(ContentSettingsType type);
104 // Returns the UI string for the given permission |value|, used in the
105 // permission-changing menu. Generally this will be a verb in the imperative
106 // form, e.g. "ask", "allow", "block".
107 static string16 PermissionValueToUIString(ContentSetting value);
109 // Returns the UI string describing the action taken for a permission,
110 // including why that action was taken. E.g. "Allowed by you",
111 // "Blocked by default".
112 static string16 PermissionActionToUIString(
113 ContentSetting setting,
114 ContentSetting default_setting,
115 content_settings::SettingSource source);
117 // Returns the icon resource ID for the given permission |type| and |setting|.
118 static int GetPermissionIconID(ContentSettingsType type,
119 ContentSetting setting);
121 // Returns the icon for the given permission |type| and |setting|.
122 static const gfx::Image& GetPermissionIcon(ContentSettingsType type,
123 ContentSetting setting);
125 // Returns the identity icon ID for the given identity |status|.
126 static int GetIdentityIconID(WebsiteSettings::SiteIdentityStatus status);
128 // Returns the identity icon for the given identity |status|.
129 static const gfx::Image& GetIdentityIcon(
130 WebsiteSettings::SiteIdentityStatus status);
132 // Returns the connection icon ID for the given connection |status|.
133 static int GetConnectionIconID(
134 WebsiteSettings::SiteConnectionStatus status);
136 // Returns the connection icon for the given connection |status|.
137 static const gfx::Image& GetConnectionIcon(
138 WebsiteSettings::SiteConnectionStatus status);
140 // Returns the icon ID to show along with the first visit information.
141 static int GetFirstVisitIconID(const string16& first_visit);
143 // Returns the icon to show along with the first visit information.
144 static const gfx::Image& GetFirstVisitIcon(const string16& first_visit);
146 // Sets cookie information.
147 virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
149 // Sets permision information.
150 virtual void SetPermissionInfo(
151 const PermissionInfoList& permission_info_list) = 0;
153 // Sets site identity information.
154 virtual void SetIdentityInfo(const IdentityInfo& identity_info) = 0;
156 // Sets the first visited data. |first_visit| can be an empty string.
157 virtual void SetFirstVisit(const string16& first_visit) = 0;
159 // Selects the tab with the given |tab_id|.
160 virtual void SetSelectedTab(TabId tab_id) = 0;
163 typedef WebsiteSettingsUI::CookieInfoList CookieInfoList;
164 typedef WebsiteSettingsUI::PermissionInfoList PermissionInfoList;
166 #endif // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_