Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / website_settings / website_settings_ui.h
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.
4
5 #ifndef CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_
6 #define CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_
7
8 #include <string>
9 #include <vector>
10
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"
17
18
19 class GURL;
20 class Profile;
21 class WebsiteSettings;
22 namespace content {
23 struct SSLStatus;
24 }
25
26 namespace gfx {
27 class Image;
28 }
29
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,
35 // etc.).
36 class WebsiteSettingsUI {
37  public:
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.
40   enum TabId {
41     TAB_ID_PERMISSIONS = 0,
42     TAB_ID_CONNECTION,
43     NUM_TAB_IDS,
44   };
45
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.
48   struct CookieInfo {
49     CookieInfo();
50
51     // String describing the cookie source.
52     std::string cookie_source;
53     // The number of allowed cookies.
54     int allowed;
55     // The number of blocked cookies.
56     int blocked;
57   };
58
59   // |PermissionInfo| contains information about a single permission |type| for
60   // the current website.
61   struct PermissionInfo {
62     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;
71   };
72
73   // |IdentityInfo| contains information about the site's identity and
74   // connection.
75   struct IdentityInfo {
76     IdentityInfo();
77     ~IdentityInfo();
78
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
86     // the user.
87     std::string identity_status_description;
88     // The ID is the server certificate of a secure connection or 0.
89     int cert_id;
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
96     // the user.
97     std::string connection_status_description;
98   };
99
100   typedef std::vector<CookieInfo> CookieInfoList;
101   typedef std::vector<PermissionInfo> PermissionInfoList;
102
103   virtual ~WebsiteSettingsUI();
104
105   // Returns the UI string for the given permission |type|.
106   static base::string16 PermissionTypeToUIString(ContentSettingsType type);
107
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);
112
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);
120
121   // Returns the icon resource ID for the given permission |type| and |setting|.
122   static int GetPermissionIconID(ContentSettingsType type,
123                                  ContentSetting setting);
124
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
127   // default setting.
128   static const gfx::Image& GetPermissionIcon(const PermissionInfo& info);
129
130   // Returns the identity icon ID for the given identity |status|.
131   static int GetIdentityIconID(WebsiteSettings::SiteIdentityStatus status);
132
133   // Returns the identity icon for the given identity |status|.
134   static const gfx::Image& GetIdentityIcon(
135       WebsiteSettings::SiteIdentityStatus status);
136
137   // Returns the connection icon ID for the given connection |status|.
138   static int GetConnectionIconID(
139       WebsiteSettings::SiteConnectionStatus status);
140
141   // Returns the connection icon for the given connection |status|.
142   static const gfx::Image& GetConnectionIcon(
143       WebsiteSettings::SiteConnectionStatus status);
144
145   // Returns the icon ID to show along with the first visit information.
146   static int GetFirstVisitIconID(const base::string16& first_visit);
147
148   // Returns the icon to show along with the first visit information.
149   static const gfx::Image& GetFirstVisitIcon(const base::string16& first_visit);
150
151   // Sets cookie information.
152   virtual void SetCookieInfo(const CookieInfoList& cookie_info_list) = 0;
153
154   // Sets permision information.
155   virtual void SetPermissionInfo(
156       const PermissionInfoList& permission_info_list) = 0;
157
158   // Sets site identity information.
159   virtual void SetIdentityInfo(const IdentityInfo& identity_info) = 0;
160
161   // Sets the first visited data. |first_visit| can be an empty string.
162   virtual void SetFirstVisit(const base::string16& first_visit) = 0;
163
164   // Selects the tab with the given |tab_id|.
165   virtual void SetSelectedTab(TabId tab_id) = 0;
166 };
167
168 typedef WebsiteSettingsUI::CookieInfoList CookieInfoList;
169 typedef WebsiteSettingsUI::PermissionInfoList PermissionInfoList;
170
171 #endif  // CHROME_BROWSER_UI_WEBSITE_SETTINGS_WEBSITE_SETTINGS_UI_H_