Chromium Code Reviews| 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/content_settings/tab_specific_content_settings.h" | 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 CONTENT_SETTINGS_TYPE_GEOLOCATION), | 96 CONTENT_SETTINGS_TYPE_GEOLOCATION), |
| 97 midi_usages_state_( | 97 midi_usages_state_( |
| 98 HostContentSettingsMapFactory::GetForProfile( | 98 HostContentSettingsMapFactory::GetForProfile( |
| 99 Profile::FromBrowserContext(tab->GetBrowserContext())), | 99 Profile::FromBrowserContext(tab->GetBrowserContext())), |
| 100 CONTENT_SETTINGS_TYPE_MIDI_SYSEX), | 100 CONTENT_SETTINGS_TYPE_MIDI_SYSEX), |
| 101 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 101 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 102 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 102 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 103 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), | 103 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), |
| 104 load_plugins_link_enabled_(true), | 104 load_plugins_link_enabled_(true), |
| 105 microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), | 105 microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), |
| 106 subresource_filter_enabled_(false), | |
| 107 subresource_filter_blockage_indicated_(false), | |
| 106 observer_(this) { | 108 observer_(this) { |
| 107 ClearBlockedContentSettingsExceptForCookies(); | 109 ClearBlockedContentSettingsExceptForCookies(); |
| 108 ClearCookieSpecificContentSettings(); | 110 ClearCookieSpecificContentSettings(); |
| 109 | 111 |
| 110 observer_.Add(HostContentSettingsMapFactory::GetForProfile( | 112 observer_.Add(HostContentSettingsMapFactory::GetForProfile( |
| 111 Profile::FromBrowserContext(tab->GetBrowserContext()))); | 113 Profile::FromBrowserContext(tab->GetBrowserContext()))); |
| 112 } | 114 } |
| 113 | 115 |
| 114 TabSpecificContentSettings::~TabSpecificContentSettings() { | 116 TabSpecificContentSettings::~TabSpecificContentSettings() { |
| 115 FOR_EACH_OBSERVER( | 117 FOR_EACH_OBSERVER( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX || | 252 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX || |
| 251 content_type == CONTENT_SETTINGS_TYPE_KEYGEN) { | 253 content_type == CONTENT_SETTINGS_TYPE_KEYGEN) { |
| 252 const auto& it = content_settings_status_.find(content_type); | 254 const auto& it = content_settings_status_.find(content_type); |
| 253 if (it != content_settings_status_.end()) | 255 if (it != content_settings_status_.end()) |
| 254 return it->second.blocked; | 256 return it->second.blocked; |
| 255 } | 257 } |
| 256 | 258 |
| 257 return false; | 259 return false; |
| 258 } | 260 } |
| 259 | 261 |
| 262 bool TabSpecificContentSettings::IsSubresourceBlocked() const { | |
| 263 return subresource_filter_enabled_; | |
| 264 } | |
| 265 | |
| 260 bool TabSpecificContentSettings::IsBlockageIndicated( | 266 bool TabSpecificContentSettings::IsBlockageIndicated( |
| 261 ContentSettingsType content_type) const { | 267 ContentSettingsType content_type) const { |
| 262 const auto& it = content_settings_status_.find(content_type); | 268 const auto& it = content_settings_status_.find(content_type); |
| 263 if (it != content_settings_status_.end()) | 269 if (it != content_settings_status_.end()) |
| 264 return it->second.blockage_indicated_to_user; | 270 return it->second.blockage_indicated_to_user; |
| 265 return false; | 271 return false; |
| 266 } | 272 } |
| 267 | 273 |
| 274 bool TabSpecificContentSettings::IsSubresourceBlockageIndicated() | |
| 275 const { | |
|
msramek
2016/07/27 15:47:40
nit: fits on the previous line
melandory
2016/07/28 14:04:56
Done.
| |
| 276 return subresource_filter_blockage_indicated_; | |
| 277 } | |
| 278 | |
| 268 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( | 279 void TabSpecificContentSettings::SetBlockageHasBeenIndicated( |
| 269 ContentSettingsType content_type) { | 280 ContentSettingsType content_type) { |
| 270 content_settings_status_[content_type].blockage_indicated_to_user = true; | 281 content_settings_status_[content_type].blockage_indicated_to_user = true; |
| 271 } | 282 } |
| 272 | 283 |
| 284 void TabSpecificContentSettings::SetSubresourceBlockageIndicated() { | |
| 285 subresource_filter_blockage_indicated_ = true; | |
| 286 } | |
| 287 | |
| 273 bool TabSpecificContentSettings::IsContentAllowed( | 288 bool TabSpecificContentSettings::IsContentAllowed( |
| 274 ContentSettingsType content_type) const { | 289 ContentSettingsType content_type) const { |
| 275 // This method currently only returns meaningful values for the content type | 290 // This method currently only returns meaningful values for the content type |
| 276 // cookies, media, PPAPI broker, downloads, and MIDI sysex. | 291 // cookies, media, PPAPI broker, downloads, and MIDI sysex. |
| 277 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && | 292 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && |
| 278 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | 293 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |
| 279 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && | 294 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && |
| 280 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && | 295 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && |
| 281 content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS && | 296 content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS && |
| 282 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 297 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 ContentSettingsStatus& status = | 698 ContentSettingsStatus& status = |
| 684 content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; | 699 content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; |
| 685 status.blocked = blocked; | 700 status.blocked = blocked; |
| 686 status.blockage_indicated_to_user = false; | 701 status.blockage_indicated_to_user = false; |
| 687 content::NotificationService::current()->Notify( | 702 content::NotificationService::current()->Notify( |
| 688 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 703 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 689 content::Source<WebContents>(web_contents()), | 704 content::Source<WebContents>(web_contents()), |
| 690 content::NotificationService::NoDetails()); | 705 content::NotificationService::NoDetails()); |
| 691 } | 706 } |
| 692 | 707 |
| 708 void TabSpecificContentSettings::SetSubresourceBlocked(bool enabled) { | |
| 709 subresource_filter_enabled_ = enabled; | |
| 710 } | |
| 711 | |
| 693 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { | 712 void TabSpecificContentSettings::SetPepperBrokerAllowed(bool allowed) { |
| 694 if (allowed) { | 713 if (allowed) { |
| 695 OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); | 714 OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |
| 696 } else { | 715 } else { |
| 697 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); | 716 OnContentBlocked(CONTENT_SETTINGS_TYPE_PPAPI_BROKER); |
| 698 } | 717 } |
| 699 } | 718 } |
| 700 | 719 |
| 701 void TabSpecificContentSettings::OnContentSettingChanged( | 720 void TabSpecificContentSettings::OnContentSettingChanged( |
| 702 const ContentSettingsPattern& primary_pattern, | 721 const ContentSettingsPattern& primary_pattern, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 849 static_cast<MicrophoneCameraStateFlags>( | 868 static_cast<MicrophoneCameraStateFlags>( |
| 850 TabSpecificContentSettings::MICROPHONE_ACCESSED | | 869 TabSpecificContentSettings::MICROPHONE_ACCESSED | |
| 851 TabSpecificContentSettings::MICROPHONE_BLOCKED | | 870 TabSpecificContentSettings::MICROPHONE_BLOCKED | |
| 852 TabSpecificContentSettings::CAMERA_ACCESSED | | 871 TabSpecificContentSettings::CAMERA_ACCESSED | |
| 853 TabSpecificContentSettings::CAMERA_BLOCKED); | 872 TabSpecificContentSettings::CAMERA_BLOCKED); |
| 854 OnMediaStreamPermissionSet( | 873 OnMediaStreamPermissionSet( |
| 855 web_contents()->GetLastCommittedURL(), | 874 web_contents()->GetLastCommittedURL(), |
| 856 media_blocked, | 875 media_blocked, |
| 857 std::string(), std::string(), std::string(), std::string()); | 876 std::string(), std::string(), std::string(), std::string()); |
| 858 } | 877 } |
| OLD | NEW |