OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/website_settings/website_settings_ui.h" | 5 #include "chrome/browser/ui/website_settings/website_settings_ui.h" |
6 | 6 |
7 #include "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 default: | 173 default: |
174 NOTREACHED(); | 174 NOTREACHED(); |
175 return string16(); | 175 return string16(); |
176 } | 176 } |
177 int button_text_id = button_text_ids[effective_setting]; | 177 int button_text_id = button_text_ids[effective_setting]; |
178 DCHECK_NE(button_text_id, kInvalidResourceID); | 178 DCHECK_NE(button_text_id, kInvalidResourceID); |
179 return l10n_util::GetStringUTF16(button_text_id); | 179 return l10n_util::GetStringUTF16(button_text_id); |
180 } | 180 } |
181 | 181 |
182 // static | 182 // static |
183 const gfx::Image& WebsiteSettingsUI::GetPermissionIcon( | 183 int WebsiteSettingsUI::GetPermissionIconID(ContentSettingsType type, |
184 ContentSettingsType type, | 184 ContentSetting setting) { |
185 ContentSetting setting) { | |
186 bool use_blocked = (setting == CONTENT_SETTING_BLOCK); | 185 bool use_blocked = (setting == CONTENT_SETTING_BLOCK); |
187 int resource_id = IDR_INFO; | 186 int resource_id = IDR_INFO; |
188 switch (type) { | 187 switch (type) { |
189 case CONTENT_SETTINGS_TYPE_IMAGES: | 188 case CONTENT_SETTINGS_TYPE_IMAGES: |
190 resource_id = use_blocked ? IDR_BLOCKED_IMAGES | 189 resource_id = use_blocked ? IDR_BLOCKED_IMAGES |
191 : IDR_ALLOWED_IMAGES; | 190 : IDR_ALLOWED_IMAGES; |
192 break; | 191 break; |
193 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 192 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: |
194 resource_id = use_blocked ? IDR_BLOCKED_JAVASCRIPT | 193 resource_id = use_blocked ? IDR_BLOCKED_JAVASCRIPT |
195 : IDR_ALLOWED_JAVASCRIPT; | 194 : IDR_ALLOWED_JAVASCRIPT; |
(...skipping 26 matching lines...) Expand all Loading... |
222 : IDR_ALLOWED_MOUSE_CURSOR; | 221 : IDR_ALLOWED_MOUSE_CURSOR; |
223 break; | 222 break; |
224 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 223 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
225 resource_id = use_blocked ? IDR_BLOCKED_MEDIA | 224 resource_id = use_blocked ? IDR_BLOCKED_MEDIA |
226 : IDR_ASK_MEDIA; | 225 : IDR_ASK_MEDIA; |
227 break; | 226 break; |
228 default: | 227 default: |
229 NOTREACHED(); | 228 NOTREACHED(); |
230 break; | 229 break; |
231 } | 230 } |
232 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 231 return resource_id; |
233 return rb.GetNativeImageNamed(resource_id); | |
234 } | 232 } |
235 | 233 |
236 // static | 234 // static |
237 const gfx::Image& WebsiteSettingsUI::GetIdentityIcon( | 235 const gfx::Image& WebsiteSettingsUI::GetPermissionIcon( |
| 236 ContentSettingsType type, |
| 237 ContentSetting setting) { |
| 238 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 239 return rb.GetNativeImageNamed(GetPermissionIconID(type, setting)); |
| 240 } |
| 241 |
| 242 // static |
| 243 int WebsiteSettingsUI::GetIdentityIconID( |
238 WebsiteSettings::SiteIdentityStatus status) { | 244 WebsiteSettings::SiteIdentityStatus status) { |
239 int resource_id = IDR_PAGEINFO_INFO; | 245 int resource_id = IDR_PAGEINFO_INFO; |
240 switch (status) { | 246 switch (status) { |
241 case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: | 247 case WebsiteSettings::SITE_IDENTITY_STATUS_UNKNOWN: |
242 break; | 248 break; |
243 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: | 249 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT: |
244 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: | 250 case WebsiteSettings::SITE_IDENTITY_STATUS_EV_CERT: |
245 resource_id = IDR_PAGEINFO_GOOD; | 251 resource_id = IDR_PAGEINFO_GOOD; |
246 break; | 252 break; |
247 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: | 253 case WebsiteSettings::SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN: |
248 resource_id = IDR_PAGEINFO_WARNING_MINOR; | 254 resource_id = IDR_PAGEINFO_WARNING_MINOR; |
249 break; | 255 break; |
250 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT: | 256 case WebsiteSettings::SITE_IDENTITY_STATUS_NO_CERT: |
251 resource_id = IDR_PAGEINFO_WARNING_MAJOR; | 257 resource_id = IDR_PAGEINFO_WARNING_MAJOR; |
252 break; | 258 break; |
253 case WebsiteSettings::SITE_IDENTITY_STATUS_ERROR: | 259 case WebsiteSettings::SITE_IDENTITY_STATUS_ERROR: |
254 resource_id = IDR_PAGEINFO_BAD; | 260 resource_id = IDR_PAGEINFO_BAD; |
255 break; | 261 break; |
256 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT: | 262 case WebsiteSettings::SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT: |
257 resource_id = IDR_CONTROLLED_SETTING_MANDATORY_LARGE; | 263 resource_id = IDR_CONTROLLED_SETTING_MANDATORY_LARGE; |
258 break; | 264 break; |
259 default: | 265 default: |
260 NOTREACHED(); | 266 NOTREACHED(); |
261 break; | 267 break; |
262 } | 268 } |
263 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 269 return resource_id; |
264 return rb.GetNativeImageNamed(resource_id); | |
265 } | 270 } |
266 | 271 |
267 // static | 272 // static |
268 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( | 273 const gfx::Image& WebsiteSettingsUI::GetIdentityIcon( |
| 274 WebsiteSettings::SiteIdentityStatus status) { |
| 275 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 276 return rb.GetNativeImageNamed(GetIdentityIconID(status)); |
| 277 } |
| 278 |
| 279 // static |
| 280 int WebsiteSettingsUI::GetConnectionIconID( |
269 WebsiteSettings::SiteConnectionStatus status) { | 281 WebsiteSettings::SiteConnectionStatus status) { |
270 int resource_id = IDR_PAGEINFO_INFO; | 282 int resource_id = IDR_PAGEINFO_INFO; |
271 switch (status) { | 283 switch (status) { |
272 case WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN: | 284 case WebsiteSettings::SITE_CONNECTION_STATUS_UNKNOWN: |
273 break; | 285 break; |
274 case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED: | 286 case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED: |
275 resource_id = IDR_PAGEINFO_GOOD; | 287 resource_id = IDR_PAGEINFO_GOOD; |
276 break; | 288 break; |
277 case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_CONTENT: | 289 case WebsiteSettings::SITE_CONNECTION_STATUS_MIXED_CONTENT: |
278 resource_id = IDR_PAGEINFO_WARNING_MINOR; | 290 resource_id = IDR_PAGEINFO_WARNING_MINOR; |
279 break; | 291 break; |
280 case WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED: | 292 case WebsiteSettings::SITE_CONNECTION_STATUS_UNENCRYPTED: |
281 resource_id = IDR_PAGEINFO_WARNING_MAJOR; | 293 resource_id = IDR_PAGEINFO_WARNING_MAJOR; |
282 break; | 294 break; |
283 case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR: | 295 case WebsiteSettings::SITE_CONNECTION_STATUS_ENCRYPTED_ERROR: |
284 resource_id = IDR_PAGEINFO_BAD; | 296 resource_id = IDR_PAGEINFO_BAD; |
285 break; | 297 break; |
286 default: | 298 default: |
287 NOTREACHED(); | 299 NOTREACHED(); |
288 break; | 300 break; |
289 } | 301 } |
| 302 return resource_id; |
| 303 } |
| 304 |
| 305 // static |
| 306 const gfx::Image& WebsiteSettingsUI::GetConnectionIcon( |
| 307 WebsiteSettings::SiteConnectionStatus status) { |
290 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 308 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
291 return rb.GetNativeImageNamed(resource_id); | 309 return rb.GetNativeImageNamed(GetConnectionIconID(status)); |
| 310 } |
| 311 |
| 312 // static |
| 313 int WebsiteSettingsUI::GetFirstVisitIconID(const string16& first_visit) { |
| 314 // FIXME(markusheintz): Display a minor warning icon if the page is visited |
| 315 // the first time. |
| 316 return IDR_PAGEINFO_INFO; |
292 } | 317 } |
293 | 318 |
294 // static | 319 // static |
295 const gfx::Image& WebsiteSettingsUI::GetFirstVisitIcon( | 320 const gfx::Image& WebsiteSettingsUI::GetFirstVisitIcon( |
296 const string16& first_visit) { | 321 const string16& first_visit) { |
297 // FIXME(markusheintz): Display a minor warning icon if the page is visited | |
298 // the first time. | |
299 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 322 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
300 return rb.GetNativeImageNamed(IDR_PAGEINFO_INFO); | 323 return rb.GetNativeImageNamed(GetFirstVisitIconID(first_visit)); |
301 } | 324 } |
OLD | NEW |