| 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/content_settings/content_setting_image_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
| 6 | 6 |
| 7 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/prerender/prerender_manager.h" | 9 #include "chrome/browser/prerender/prerender_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 45 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { | 48 class ContentSettingNotificationsImageModel : public ContentSettingImageModel { |
| 49 public: | 49 public: |
| 50 ContentSettingNotificationsImageModel(); | 50 ContentSettingNotificationsImageModel(); |
| 51 | 51 |
| 52 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; | 52 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class ContentSettingMIDISysExImageModel : public ContentSettingImageModel { |
| 56 public: |
| 57 ContentSettingMIDISysExImageModel(); |
| 58 |
| 59 virtual void UpdateFromWebContents(WebContents* web_contents) OVERRIDE; |
| 60 }; |
| 61 |
| 55 namespace { | 62 namespace { |
| 56 | 63 |
| 57 struct ContentSettingsTypeIdEntry { | 64 struct ContentSettingsTypeIdEntry { |
| 58 ContentSettingsType type; | 65 ContentSettingsType type; |
| 59 int id; | 66 int id; |
| 60 }; | 67 }; |
| 61 | 68 |
| 62 int GetIdForContentType(const ContentSettingsTypeIdEntry* entries, | 69 int GetIdForContentType(const ContentSettingsTypeIdEntry* entries, |
| 63 size_t num_entries, | 70 size_t num_entries, |
| 64 ContentSettingsType type) { | 71 ContentSettingsType type) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() | 297 ContentSettingNotificationsImageModel::ContentSettingNotificationsImageModel() |
| 291 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 298 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 292 } | 299 } |
| 293 | 300 |
| 294 void ContentSettingNotificationsImageModel::UpdateFromWebContents( | 301 void ContentSettingNotificationsImageModel::UpdateFromWebContents( |
| 295 WebContents* web_contents) { | 302 WebContents* web_contents) { |
| 296 // Notifications do not have a bubble. | 303 // Notifications do not have a bubble. |
| 297 set_visible(false); | 304 set_visible(false); |
| 298 } | 305 } |
| 299 | 306 |
| 307 ContentSettingMIDISysExImageModel::ContentSettingMIDISysExImageModel() |
| 308 : ContentSettingImageModel(CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 309 } |
| 310 |
| 311 void ContentSettingMIDISysExImageModel::UpdateFromWebContents( |
| 312 WebContents* web_contents) { |
| 313 set_visible(false); |
| 314 if (!web_contents) |
| 315 return; |
| 316 TabSpecificContentSettings* content_settings = |
| 317 TabSpecificContentSettings::FromWebContents(web_contents); |
| 318 if (!content_settings) |
| 319 return; |
| 320 const ContentSettingsUsagesState& usages_state = |
| 321 content_settings->midi_usages_state(); |
| 322 if (usages_state.state_map().empty()) |
| 323 return; |
| 324 set_visible(true); |
| 325 |
| 326 // If any embedded site has access the allowed icon takes priority over the |
| 327 // blocked icon. |
| 328 unsigned int state_flags = 0; |
| 329 usages_state.GetDetailedInfo(NULL, &state_flags); |
| 330 bool allowed = |
| 331 !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); |
| 332 set_icon(allowed ? IDR_ALLOWED_MIDI_SYSEX : IDR_BLOCKED_MIDI_SYSEX); |
| 333 set_tooltip(l10n_util::GetStringUTF8(allowed ? |
| 334 IDS_MIDI_SYSEX_ALLOWED_TOOLTIP : IDS_MIDI_SYSEX_BLOCKED_TOOLTIP)); |
| 335 } |
| 336 |
| 300 ContentSettingImageModel::ContentSettingImageModel( | 337 ContentSettingImageModel::ContentSettingImageModel( |
| 301 ContentSettingsType content_settings_type) | 338 ContentSettingsType content_settings_type) |
| 302 : content_settings_type_(content_settings_type), | 339 : content_settings_type_(content_settings_type), |
| 303 is_visible_(false), | 340 is_visible_(false), |
| 304 icon_(0), | 341 icon_(0), |
| 305 explanatory_string_id_(0) { | 342 explanatory_string_id_(0) { |
| 306 } | 343 } |
| 307 | 344 |
| 308 // static | 345 // static |
| 309 ContentSettingImageModel* | 346 ContentSettingImageModel* |
| 310 ContentSettingImageModel::CreateContentSettingImageModel( | 347 ContentSettingImageModel::CreateContentSettingImageModel( |
| 311 ContentSettingsType content_settings_type) { | 348 ContentSettingsType content_settings_type) { |
| 312 switch (content_settings_type) { | 349 switch (content_settings_type) { |
| 313 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | 350 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 314 return new ContentSettingGeolocationImageModel(); | 351 return new ContentSettingGeolocationImageModel(); |
| 315 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | 352 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 316 return new ContentSettingNotificationsImageModel(); | 353 return new ContentSettingNotificationsImageModel(); |
| 317 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: | 354 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: |
| 318 return new ContentSettingRPHImageModel(); | 355 return new ContentSettingRPHImageModel(); |
| 319 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | 356 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: |
| 320 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | 357 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 321 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | 358 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 322 return new ContentSettingMediaImageModel(content_settings_type); | 359 return new ContentSettingMediaImageModel(content_settings_type); |
| 360 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 361 return new ContentSettingMIDISysExImageModel(); |
| 323 default: | 362 default: |
| 324 return new ContentSettingBlockedImageModel(content_settings_type); | 363 return new ContentSettingBlockedImageModel(content_settings_type); |
| 325 } | 364 } |
| 326 } | 365 } |
| OLD | NEW |