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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/browser_process.h" | |
14 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
18 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 20 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
20 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 21 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
22 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" | 23 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" |
23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 24 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
25 #include "chrome/browser/download/download_request_limiter.h" | |
24 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" | 26 #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
25 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" | 27 #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" |
26 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
29 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
30 #include "chrome/common/renderer_configuration.mojom.h" | 32 #include "chrome/common/renderer_configuration.mojom.h" |
31 #include "components/content_settings/core/browser/content_settings_details.h" | 33 #include "components/content_settings/core/browser/content_settings_details.h" |
32 #include "components/content_settings/core/browser/content_settings_info.h" | 34 #include "components/content_settings/core/browser/content_settings_info.h" |
33 #include "components/content_settings/core/browser/content_settings_registry.h" | 35 #include "components/content_settings/core/browser/content_settings_registry.h" |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 } | 234 } |
233 | 235 |
234 bool TabSpecificContentSettings::IsContentBlocked( | 236 bool TabSpecificContentSettings::IsContentBlocked( |
235 ContentSettingsType content_type) const { | 237 ContentSettingsType content_type) const { |
236 DCHECK_NE(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) | 238 DCHECK_NE(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) |
237 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 239 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
238 DCHECK_NE(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, content_type) | 240 DCHECK_NE(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, content_type) |
239 << "Notifications settings handled by " | 241 << "Notifications settings handled by " |
240 << "ContentSettingsNotificationsImageModel"; | 242 << "ContentSettingsNotificationsImageModel"; |
241 | 243 |
244 // Automatic downloads are handled by DownloadRequestLimiter. | |
245 if (content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { | |
Bernhard Bauer
2017/01/25 19:01:14
If you are now bypassing TabSpecificContentSetting
alshabalin
2017/02/07 16:16:29
Done.
| |
246 return g_browser_process->download_request_limiter()->GetDownloadStatus( | |
247 web_contents()) == DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED; | |
248 } | |
249 | |
242 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 250 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
243 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 251 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
244 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || | 252 content_type == CONTENT_SETTINGS_TYPE_PLUGINS || |
245 content_type == CONTENT_SETTINGS_TYPE_COOKIES || | 253 content_type == CONTENT_SETTINGS_TYPE_COOKIES || |
246 content_type == CONTENT_SETTINGS_TYPE_POPUPS || | 254 content_type == CONTENT_SETTINGS_TYPE_POPUPS || |
247 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || | 255 content_type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT || |
248 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 256 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
249 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || | 257 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA || |
250 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || | 258 content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER || |
251 content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS || | |
252 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 259 content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
253 const auto& it = content_settings_status_.find(content_type); | 260 const auto& it = content_settings_status_.find(content_type); |
254 if (it != content_settings_status_.end()) | 261 if (it != content_settings_status_.end()) |
255 return it->second.blocked; | 262 return it->second.blocked; |
256 } | 263 } |
257 | 264 |
258 return false; | 265 return false; |
259 } | 266 } |
260 | 267 |
261 bool TabSpecificContentSettings::IsSubresourceBlocked() const { | 268 bool TabSpecificContentSettings::IsSubresourceBlocked() const { |
(...skipping 16 matching lines...) Expand all Loading... | |
278 ContentSettingsType content_type) { | 285 ContentSettingsType content_type) { |
279 content_settings_status_[content_type].blockage_indicated_to_user = true; | 286 content_settings_status_[content_type].blockage_indicated_to_user = true; |
280 } | 287 } |
281 | 288 |
282 void TabSpecificContentSettings::SetSubresourceBlockageIndicated() { | 289 void TabSpecificContentSettings::SetSubresourceBlockageIndicated() { |
283 subresource_filter_blockage_indicated_ = true; | 290 subresource_filter_blockage_indicated_ = true; |
284 } | 291 } |
285 | 292 |
286 bool TabSpecificContentSettings::IsContentAllowed( | 293 bool TabSpecificContentSettings::IsContentAllowed( |
287 ContentSettingsType content_type) const { | 294 ContentSettingsType content_type) const { |
295 // Automatic downloads are handled by DownloadRequestLimiter. | |
296 if (content_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS) { | |
297 return g_browser_process->download_request_limiter()->GetDownloadStatus( | |
298 web_contents()) == DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS; | |
299 } | |
300 | |
288 // This method currently only returns meaningful values for the content type | 301 // This method currently only returns meaningful values for the content type |
289 // cookies, media, PPAPI broker, downloads, and MIDI sysex. | 302 // cookies, media, PPAPI broker, downloads, and MIDI sysex. |
290 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && | 303 if (content_type != CONTENT_SETTINGS_TYPE_COOKIES && |
291 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | 304 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |
292 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && | 305 content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA && |
293 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && | 306 content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER && |
294 content_type != CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS && | |
295 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 307 content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
296 return false; | 308 return false; |
297 } | 309 } |
298 | 310 |
299 const auto& it = content_settings_status_.find(content_type); | 311 const auto& it = content_settings_status_.find(content_type); |
300 if (it != content_settings_status_.end()) | 312 if (it != content_settings_status_.end()) |
301 return it->second.allowed; | 313 return it->second.allowed; |
302 return false; | 314 return false; |
303 } | 315 } |
304 | 316 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 701 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
690 content::Source<WebContents>(web_contents()), | 702 content::Source<WebContents>(web_contents()), |
691 content::NotificationService::NoDetails()); | 703 content::NotificationService::NoDetails()); |
692 } | 704 } |
693 | 705 |
694 void TabSpecificContentSettings::FlashDownloadBlocked() { | 706 void TabSpecificContentSettings::FlashDownloadBlocked() { |
695 OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, | 707 OnContentBlockedWithDetail(CONTENT_SETTINGS_TYPE_PLUGINS, |
696 base::UTF8ToUTF16(content::kFlashPluginName)); | 708 base::UTF8ToUTF16(content::kFlashPluginName)); |
697 } | 709 } |
698 | 710 |
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) { | 711 void TabSpecificContentSettings::SetPopupsBlocked(bool blocked) { |
712 ContentSettingsStatus& status = | 712 ContentSettingsStatus& status = |
713 content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; | 713 content_settings_status_[CONTENT_SETTINGS_TYPE_POPUPS]; |
714 status.blocked = blocked; | 714 status.blocked = blocked; |
715 status.blockage_indicated_to_user = false; | 715 status.blockage_indicated_to_user = false; |
716 content::NotificationService::current()->Notify( | 716 content::NotificationService::current()->Notify( |
717 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 717 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
718 content::Source<WebContents>(web_contents()), | 718 content::Source<WebContents>(web_contents()), |
719 content::NotificationService::NoDetails()); | 719 content::NotificationService::NoDetails()); |
720 } | 720 } |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 static_cast<MicrophoneCameraStateFlags>( | 909 static_cast<MicrophoneCameraStateFlags>( |
910 TabSpecificContentSettings::MICROPHONE_ACCESSED | | 910 TabSpecificContentSettings::MICROPHONE_ACCESSED | |
911 TabSpecificContentSettings::MICROPHONE_BLOCKED | | 911 TabSpecificContentSettings::MICROPHONE_BLOCKED | |
912 TabSpecificContentSettings::CAMERA_ACCESSED | | 912 TabSpecificContentSettings::CAMERA_ACCESSED | |
913 TabSpecificContentSettings::CAMERA_BLOCKED); | 913 TabSpecificContentSettings::CAMERA_BLOCKED); |
914 OnMediaStreamPermissionSet( | 914 OnMediaStreamPermissionSet( |
915 web_contents()->GetLastCommittedURL(), | 915 web_contents()->GetLastCommittedURL(), |
916 media_blocked, | 916 media_blocked, |
917 std::string(), std::string(), std::string(), std::string()); | 917 std::string(), std::string(), std::string(), std::string()); |
918 } | 918 } |
OLD | NEW |