| 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/browsing_data/browsing_data_appcache_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" | 18 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" | 19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" |
| 20 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 20 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
| 21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 22 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" | 22 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" |
| 23 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 23 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 24 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 24 #include "chrome/browser/media/media_stream_capture_indicator.h" | 25 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
| 29 #include "components/content_settings/content/common/content_settings_messages.h
" | 30 #include "components/content_settings/content/common/content_settings_messages.h
" |
| 30 #include "components/content_settings/core/browser/content_settings_details.h" | 31 #include "components/content_settings/core/browser/content_settings_details.h" |
| 31 #include "components/content_settings/core/browser/content_settings_info.h" | 32 #include "components/content_settings/core/browser/content_settings_info.h" |
| 32 #include "components/content_settings/core/browser/content_settings_registry.h" | 33 #include "components/content_settings/core/browser/content_settings_registry.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 tab_specific_content_settings_ = NULL; | 83 tab_specific_content_settings_ = NULL; |
| 83 } | 84 } |
| 84 | 85 |
| 85 TabSpecificContentSettings::TabSpecificContentSettings(WebContents* tab) | 86 TabSpecificContentSettings::TabSpecificContentSettings(WebContents* tab) |
| 86 : content::WebContentsObserver(tab), | 87 : content::WebContentsObserver(tab), |
| 87 allowed_local_shared_objects_( | 88 allowed_local_shared_objects_( |
| 88 Profile::FromBrowserContext(tab->GetBrowserContext())), | 89 Profile::FromBrowserContext(tab->GetBrowserContext())), |
| 89 blocked_local_shared_objects_( | 90 blocked_local_shared_objects_( |
| 90 Profile::FromBrowserContext(tab->GetBrowserContext())), | 91 Profile::FromBrowserContext(tab->GetBrowserContext())), |
| 91 geolocation_usages_state_( | 92 geolocation_usages_state_( |
| 92 Profile::FromBrowserContext(tab->GetBrowserContext()) | 93 HostContentSettingsMapFactory::GetForProfile( |
| 93 ->GetHostContentSettingsMap(), | 94 Profile::FromBrowserContext(tab->GetBrowserContext())), |
| 94 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 95 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
| 95 prefs::kAcceptLanguages, | 96 prefs::kAcceptLanguages, |
| 96 Profile::FromBrowserContext(tab->GetBrowserContext())->GetPrefs()), | 97 Profile::FromBrowserContext(tab->GetBrowserContext())->GetPrefs()), |
| 97 midi_usages_state_( | 98 midi_usages_state_( |
| 98 Profile::FromBrowserContext(tab->GetBrowserContext()) | 99 HostContentSettingsMapFactory::GetForProfile( |
| 99 ->GetHostContentSettingsMap(), | 100 Profile::FromBrowserContext(tab->GetBrowserContext())), |
| 100 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, | 101 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, |
| 101 prefs::kAcceptLanguages, | 102 prefs::kAcceptLanguages, |
| 102 Profile::FromBrowserContext(tab->GetBrowserContext())->GetPrefs()), | 103 Profile::FromBrowserContext(tab->GetBrowserContext())->GetPrefs()), |
| 103 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 104 pending_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 104 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), | 105 previous_protocol_handler_(ProtocolHandler::EmptyProtocolHandler()), |
| 105 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), | 106 pending_protocol_handler_setting_(CONTENT_SETTING_DEFAULT), |
| 106 load_plugins_link_enabled_(true), | 107 load_plugins_link_enabled_(true), |
| 107 microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), | 108 microphone_camera_state_(MICROPHONE_CAMERA_NOT_ACCESSED), |
| 108 observer_(this) { | 109 observer_(this) { |
| 109 ClearBlockedContentSettingsExceptForCookies(); | 110 ClearBlockedContentSettingsExceptForCookies(); |
| 110 ClearCookieSpecificContentSettings(); | 111 ClearCookieSpecificContentSettings(); |
| 111 | 112 |
| 112 observer_.Add(Profile::FromBrowserContext(tab->GetBrowserContext()) | 113 observer_.Add(HostContentSettingsMapFactory::GetForProfile( |
| 113 ->GetHostContentSettingsMap()); | 114 Profile::FromBrowserContext(tab->GetBrowserContext()))); |
| 114 } | 115 } |
| 115 | 116 |
| 116 TabSpecificContentSettings::~TabSpecificContentSettings() { | 117 TabSpecificContentSettings::~TabSpecificContentSettings() { |
| 117 FOR_EACH_OBSERVER( | 118 FOR_EACH_OBSERVER( |
| 118 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); | 119 SiteDataObserver, observer_list_, ContentSettingsDestroyed()); |
| 119 } | 120 } |
| 120 | 121 |
| 121 TabSpecificContentSettings* TabSpecificContentSettings::GetForFrame( | 122 TabSpecificContentSettings* TabSpecificContentSettings::GetForFrame( |
| 122 int render_process_id, | 123 int render_process_id, |
| 123 int render_frame_id) { | 124 int render_frame_id) { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 NavigationEntry* entry = controller.GetVisibleEntry(); | 706 NavigationEntry* entry = controller.GetVisibleEntry(); |
| 706 GURL entry_url; | 707 GURL entry_url; |
| 707 if (entry) | 708 if (entry) |
| 708 entry_url = entry->GetURL(); | 709 entry_url = entry->GetURL(); |
| 709 if (details.update_all() || | 710 if (details.update_all() || |
| 710 // The visible NavigationEntry is the URL in the URL field of a tab. | 711 // The visible NavigationEntry is the URL in the URL field of a tab. |
| 711 // Currently this should be matched by the |primary_pattern|. | 712 // Currently this should be matched by the |primary_pattern|. |
| 712 details.primary_pattern().Matches(entry_url)) { | 713 details.primary_pattern().Matches(entry_url)) { |
| 713 Profile* profile = | 714 Profile* profile = |
| 714 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 715 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 715 const HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); | 716 const HostContentSettingsMap* map = |
| 717 HostContentSettingsMapFactory::GetForProfile(profile); |
| 716 | 718 |
| 717 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 719 if (content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
| 718 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 720 content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
| 719 const GURL media_origin = media_stream_access_origin(); | 721 const GURL media_origin = media_stream_access_origin(); |
| 720 ContentSetting setting = map->GetContentSetting(media_origin, | 722 ContentSetting setting = map->GetContentSetting(media_origin, |
| 721 media_origin, | 723 media_origin, |
| 722 content_type, | 724 content_type, |
| 723 std::string()); | 725 std::string()); |
| 724 ContentSettingsStatus& status = content_settings_status_[content_type]; | 726 ContentSettingsStatus& status = content_settings_status_[content_type]; |
| 725 status.allowed = setting == CONTENT_SETTING_ALLOW; | 727 status.allowed = setting == CONTENT_SETTING_ALLOW; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 | 818 |
| 817 void TabSpecificContentSettings::GeolocationDidNavigate( | 819 void TabSpecificContentSettings::GeolocationDidNavigate( |
| 818 const content::LoadCommittedDetails& details) { | 820 const content::LoadCommittedDetails& details) { |
| 819 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); | 821 geolocation_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 820 } | 822 } |
| 821 | 823 |
| 822 void TabSpecificContentSettings::MidiDidNavigate( | 824 void TabSpecificContentSettings::MidiDidNavigate( |
| 823 const content::LoadCommittedDetails& details) { | 825 const content::LoadCommittedDetails& details) { |
| 824 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); | 826 midi_usages_state_.DidNavigate(GetCommittedDetails(details)); |
| 825 } | 827 } |
| OLD | NEW |