| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 blocked_by_policy_cookie); | 231 blocked_by_policy_cookie); |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool TabSpecificContentSettings::IsContentBlocked( | 234 bool TabSpecificContentSettings::IsContentBlocked( |
| 235 ContentSettingsType content_type) const { | 235 ContentSettingsType content_type) const { |
| 236 DCHECK_NE(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) | 236 DCHECK_NE(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) |
| 237 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 237 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
| 238 DCHECK_NE(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, content_type) | 238 DCHECK_NE(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, content_type) |
| 239 << "Notifications settings handled by " | 239 << "Notifications settings handled by " |
| 240 << "ContentSettingsNotificationsImageModel"; | 240 << "ContentSettingsNotificationsImageModel"; |
| 241 DCHECK_NE(CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, content_type) |
| 242 << "Automatic downloads handled by DownloadRequestLimiter"; |
| 241 | 243 |
| 242 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 244 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 243 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 245 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| 244 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || | 246 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || |
| 245 content_type == CONTENT_SETTINGS_TYPE_COOKIES || | 247 content_type == CONTENT_SETTINGS_TYPE_COOKIES || |
| 246 content_type == CONTENT_SETTINGS_TYPE_POPUPS || | 248 content_type == CONTENT_SETTINGS_TYPE_POPUPS || |
| 247 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || | 249 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || |
| 248 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 250 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
| 249 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || | 251 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || |
| 250 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || | 252 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || |
| 251 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS || | |
| 252 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 253 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 253 const auto& it = content_settings_status_.find(content_type); | 254 const auto& it = content_settings_status_.find(content_type); |
| 254 if (it != content_settings_status_.end()) | 255 if (it != content_settings_status_.end()) |
| 255 return it->second.blocked; | 256 return it->second.blocked; |
| 256 } | 257 } |
| 257 | 258 |
| 258 return false; | 259 return false; |
| 259 } | 260 } |
| 260 | 261 |
| 261 bool TabSpecificContentSettings::IsSubresourceBlocked() const { | 262 bool TabSpecificContentSettings::IsSubresourceBlocked() const { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 278 ContentSettingsType content_type) { | 279 ContentSettingsType content_type) { |
| 279 content_settings_status_[content_type].blockage_indicated_to_user = true; | 280 content_settings_status_[content_type].blockage_indicated_to_user = true; |
| 280 } | 281 } |
| 281 | 282 |
| 282 void TabSpecificContentSettings::SetSubresourceBlockageIndicated() { | 283 void TabSpecificContentSettings::SetSubresourceBlockageIndicated() { |
| 283 subresource_filter_blockage_indicated_ = true; | 284 subresource_filter_blockage_indicated_ = true; |
| 284 } | 285 } |
| 285 | 286 |
| 286 bool TabSpecificContentSettings::IsContentAllowed( | 287 bool TabSpecificContentSettings::IsContentAllowed( |
| 287 ContentSettingsType content_type) const { | 288 ContentSettingsType content_type) const { |
| 289 DCHECK_NE(CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, content_type) |
| 290 << "Automatic downloads handled by DownloadRequestLimiter"; |
| 291 |
| 288 // This method currently only returns meaningful values for the content type | 292 // This method currently only returns meaningful values for the content type |
| 289 // cookies, media, PPAPI broker, downloads, and MIDI sysex. | 293 // cookies, media, PPAPI broker, downloads, and MIDI sysex. |
| 290 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && | 294 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && |
| 291 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | 295 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |
| 292 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && | 296 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && |
| 293 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && | 297 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && |
| 294 content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS && | |
| 295 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 298 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 296 return false; | 299 return false; |
| 297 } | 300 } |
| 298 | 301 |
| 299 const auto& it = content_settings_status_.find(content_type); | 302 const auto& it = content_settings_status_.find(content_type); |
| 300 if (it != content_settings_status_.end()) | 303 if (it != content_settings_status_.end()) |
| 301 return it->second.allowed; | 304 return it->second.allowed; |
| 302 return false; | 305 return false; |
| 303 } | 306 } |
| 304 | 307 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 692 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 690 content::Source<WebContents>(web_contents()), | 693 content::Source<WebContents>(web_contents()), |
| 691 content::NotificationService::NoDetails()); | 694 content::NotificationService::NoDetails()); |
| 692 } | 695 } |
| 693 | 696 |
| 694 void TabSpecificContentSettings::FlashDownloadBlocked() { | 697 void TabSpecificContentSettings::FlashDownloadBlocked() { |
| 695 OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, | 698 OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, |
| 696 base::UTF8ToUTF16(content::kFlashPluginName)); | 699 base::UTF8ToUTF16(content::kFlashPluginName)); |
| 697 } | 700 } |
| 698 | 701 |
| 699 void TabSpecificContentSettings::SetDownloadsBlocked(bool blocked) { | |
| 700 ContentSettingsStatus& status = | |
| 701 content_settings_status_[CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS]; | |
| 702 status.blocked = blocked; | |
| 703 status.allowed = !blocked; | |
| 704 status.blockage_indicated_to_user = false; | |
| 705 content::NotificationService::current()->Notify( | |
| 706 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | |
| 707 content::Source<WebContents>(web_contents()), | |
| 708 content::NotificationService::NoDetails()); | |
| 709 } | |
| 710 | |
| 711 void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) { | 702 void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) { |
| 712 ContentSettingsStatus& status = | 703 ContentSettingsStatus& status = |
| 713 content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; | 704 content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; |
| 714 status.blocked = blocked; | 705 status.blocked = blocked; |
| 715 status.blockage_indicated_to_user = false; | 706 status.blockage_indicated_to_user = false; |
| 716 content::NotificationService::current()->Notify( | 707 content::NotificationService::current()->Notify( |
| 717 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 708 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 718 content::Source<WebContents>(web_contents()), | 709 content::Source<WebContents>(web_contents()), |
| 719 content::NotificationService::NoDetails()); | 710 content::NotificationService::NoDetails()); |
| 720 } | 711 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 static_cast<MicrophoneCameraStateFlags>( | 900 static_cast<MicrophoneCameraStateFlags>( |
| 910 TabSpecificContentSettings::MICROPHONE_ACCESSED | | 901 TabSpecificContentSettings::MICROPHONE_ACCESSED | |
| 911 TabSpecificContentSettings::MICROPHONE_BLOCKED | | 902 TabSpecificContentSettings::MICROPHONE_BLOCKED | |
| 912 TabSpecificContentSettings::CAMERA_ACCESSED | | 903 TabSpecificContentSettings::CAMERA_ACCESSED | |
| 913 TabSpecificContentSettings::CAMERA_BLOCKED); | 904 TabSpecificContentSettings::CAMERA_BLOCKED); |
| 914 OnMediaStreamPermissionSet( | 905 OnMediaStreamPermissionSet( |
| 915 web_contents()->GetLastCommittedURL(), | 906 web_contents()->GetLastCommittedURL(), |
| 916 media_blocked, | 907 media_blocked, |
| 917 std::string(), std::string(), std::string(), std::string()); | 908 std::string(), std::string(), std::string(), std::string()); |
| 918 } | 909 } |
| OLD | NEW |