| 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/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | |
| 15 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 20 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 21 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 20 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" | 22 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" |
| 24 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 23 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 25 #include "chrome/browser/media/media_stream_capture_indicator.h" | 24 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
| 30 #include "components/content_settings/content/common/content_settings_messages.h
" | 29 #include "components/content_settings/content/common/content_settings_messages.h
" |
| 31 #include "components/content_settings/core/browser/content_settings_details.h" | 30 #include "components/content_settings/core/browser/content_settings_details.h" |
| 32 #include "components/content_settings/core/browser/content_settings_utils.h" | 31 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 33 #include "components/content_settings/core/browser/host_content_settings_map.h" | 32 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 34 #include "components/rappor/rappor_service.h" | |
| 35 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/browser/navigation_controller.h" | 34 #include "content/public/browser/navigation_controller.h" |
| 37 #include "content/public/browser/navigation_details.h" | 35 #include "content/public/browser/navigation_details.h" |
| 38 #include "content/public/browser/navigation_entry.h" | 36 #include "content/public/browser/navigation_entry.h" |
| 39 #include "content/public/browser/notification_registrar.h" | 37 #include "content/public/browser/notification_registrar.h" |
| 40 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/render_frame_host.h" | 39 #include "content/public/browser/render_frame_host.h" |
| 42 #include "content/public/browser/render_view_host.h" | 40 #include "content/public/browser/render_view_host.h" |
| 43 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/browser/web_contents_delegate.h" | 42 #include "content/public/browser/web_contents_delegate.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 345 |
| 348 if (!content_blocked_[type]) { | 346 if (!content_blocked_[type]) { |
| 349 content_blocked_[type] = true; | 347 content_blocked_[type] = true; |
| 350 // TODO: it would be nice to have a way of mocking this in tests. | 348 // TODO: it would be nice to have a way of mocking this in tests. |
| 351 content::NotificationService::current()->Notify( | 349 content::NotificationService::current()->Notify( |
| 352 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 350 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 353 content::Source<WebContents>(web_contents()), | 351 content::Source<WebContents>(web_contents()), |
| 354 content::NotificationService::NoDetails()); | 352 content::NotificationService::NoDetails()); |
| 355 | 353 |
| 356 if (type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { | 354 if (type == CONTENT_SETTINGS_TYPE_MIXEDSCRIPT) { |
| 357 content_settings::RecordMixedScriptAction( | 355 content_settings::RecordMixedScriptActionWithRAPPOR( |
| 358 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_SHIELD); | 356 content_settings::MIXED_SCRIPT_ACTION_DISPLAYED_SHIELD, |
| 359 | 357 GURL(base::UTF16ToUTF8(details))); |
| 360 rappor::RapporService* rappor_service = | |
| 361 g_browser_process->rappor_service(); | |
| 362 if (rappor_service) { | |
| 363 rappor_service->RecordSample( | |
| 364 "ContentSettings.MixedScript.DisplayedShield", | |
| 365 rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, | |
| 366 net::registry_controlled_domains::GetDomainAndRegistry( | |
| 367 base::UTF16ToUTF8(details), | |
| 368 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); | |
| 369 } | |
| 370 } | 358 } |
| 371 } | 359 } |
| 372 } | 360 } |
| 373 | 361 |
| 374 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { | 362 void TabSpecificContentSettings::OnContentAllowed(ContentSettingsType type) { |
| 375 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 363 DCHECK(type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
| 376 << "Geolocation settings handled by OnGeolocationPermissionSet"; | 364 << "Geolocation settings handled by OnGeolocationPermissionSet"; |
| 377 DCHECK(type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && | 365 DCHECK(type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC && |
| 378 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) | 366 type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) |
| 379 << "Media stream settings handled by OnMediaStreamPermissionSet"; | 367 << "Media stream settings handled by OnMediaStreamPermissionSet"; |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 | 810 |
| 823 void TabSpecificContentSettings::GeolocationDidNavigate( | 811 void TabSpecificContentSettings::GeolocationDidNavigate( |
| 824 const content::LoadCommittedDetails& details) { | 812 const content::LoadCommittedDetails& details) { |
| 825 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); | 813 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 826 } | 814 } |
| 827 | 815 |
| 828 void TabSpecificContentSettings::MidiDidNavigate( | 816 void TabSpecificContentSettings::MidiDidNavigate( |
| 829 const content::LoadCommittedDetails& details) { | 817 const content::LoadCommittedDetails& details) { |
| 830 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); | 818 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 831 } | 819 } |
| OLD | NEW |