Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_bubble_model.cc

Issue 1803973002: Content Settings: Add RevocationObserver to measure when permissions are revoked (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ui/content_settings/content_setting_bubble_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" 14 #include "chrome/browser/content_settings/chrome_content_settings_utils.h"
15 #include "chrome/browser/content_settings/cookie_settings_factory.h" 15 #include "chrome/browser/content_settings/cookie_settings_factory.h"
16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 16 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 17 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 18 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
19 #include "chrome/browser/infobars/infobar_service.h" 19 #include "chrome/browser/infobars/infobar_service.h"
20 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 20 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
21 #include "chrome/browser/permissions/permission_util.h"
21 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 22 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 24 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
24 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 25 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
25 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega te.h" 26 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega te.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 "chrome/grit/generated_resources.h" 30 #include "chrome/grit/generated_resources.h"
30 #include "components/content_settings/content/common/content_settings_messages.h " 31 #include "components/content_settings/content/common/content_settings_messages.h "
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 radio_group.radio_items.push_back(radio_allow_label); 716 radio_group.radio_items.push_back(radio_allow_label);
716 radio_group.radio_items.push_back(radio_block_label); 717 radio_group.radio_items.push_back(radio_block_label);
717 718
718 set_radio_group(radio_group); 719 set_radio_group(radio_group);
719 set_radio_group_enabled(true); 720 set_radio_group_enabled(true);
720 } 721 }
721 722
722 void ContentSettingMediaStreamBubbleModel::UpdateSettings( 723 void ContentSettingMediaStreamBubbleModel::UpdateSettings(
723 ContentSetting setting) { 724 ContentSetting setting) {
724 if (profile()) { 725 if (profile()) {
725 HostContentSettingsMap* content_settings =
726 HostContentSettingsMapFactory::GetForProfile(profile());
727 TabSpecificContentSettings* tab_content_settings = 726 TabSpecificContentSettings* tab_content_settings =
728 TabSpecificContentSettings::FromWebContents(web_contents()); 727 TabSpecificContentSettings::FromWebContents(web_contents());
729 // The same urls must be used as in other places (e.g. the infobar) in 728 // The same urls must be used as in other places (e.g. the infobar) in
730 // order to override the existing rule. Otherwise a new rule is created. 729 // order to override the existing rule. Otherwise a new rule is created.
731 // TODO(markusheintz): Extract to a helper so that there is only a single 730 // TODO(markusheintz): Extract to a helper so that there is only a single
732 // place to touch. 731 // place to touch.
733 if (MicrophoneAccessed()) { 732 if (MicrophoneAccessed()) {
734 content_settings->SetContentSettingDefaultScope( 733 PermissionUtil::SetContentSettingAndRecordRevocation(profile(),
735 tab_content_settings->media_stream_access_origin(), GURL(), 734 tab_content_settings->media_stream_access_origin(), GURL(),
736 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting); 735 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting);
737 } 736 }
738 if (CameraAccessed()) { 737 if (CameraAccessed()) {
739 content_settings->SetContentSettingDefaultScope( 738 PermissionUtil::SetContentSettingAndRecordRevocation(profile(),
740 tab_content_settings->media_stream_access_origin(), GURL(), 739 tab_content_settings->media_stream_access_origin(), GURL(),
741 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting); 740 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting);
742 } 741 }
743 } 742 }
744 } 743 }
745 744
746 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType( 745 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType(
747 content::MediaStreamType type, 746 content::MediaStreamType type,
748 const std::string& device) { 747 const std::string& device) {
749 PrefService* prefs = profile()->GetPrefs(); 748 PrefService* prefs = profile()->GetPrefs();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { 932 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() {
934 if (!web_contents()) 933 if (!web_contents())
935 return; 934 return;
936 // Reset this embedder's entry to default for each of the requesting 935 // Reset this embedder's entry to default for each of the requesting
937 // origins currently on the page. 936 // origins currently on the page.
938 const GURL& embedder_url = web_contents()->GetURL(); 937 const GURL& embedder_url = web_contents()->GetURL();
939 TabSpecificContentSettings* content_settings = 938 TabSpecificContentSettings* content_settings =
940 TabSpecificContentSettings::FromWebContents(web_contents()); 939 TabSpecificContentSettings::FromWebContents(web_contents());
941 const ContentSettingsUsagesState::StateMap& state_map = 940 const ContentSettingsUsagesState::StateMap& state_map =
942 content_settings->geolocation_usages_state().state_map(); 941 content_settings->geolocation_usages_state().state_map();
943 HostContentSettingsMap* settings_map =
944 HostContentSettingsMapFactory::GetForProfile(profile());
945 942
946 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 943 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
947 settings_map->SetContentSettingDefaultScope( 944 PermissionUtil::SetContentSettingAndRecordRevocation(profile(),
948 map_entry.first, embedder_url, CONTENT_SETTINGS_TYPE_GEOLOCATION, 945 map_entry.first, embedder_url, CONTENT_SETTINGS_TYPE_GEOLOCATION,
949 std::string(), CONTENT_SETTING_DEFAULT); 946 std::string(), CONTENT_SETTING_DEFAULT);
950 } 947 }
951 } 948 }
952 949
953 // ContentSettingMixedScriptBubbleModel ---------------------------------------- 950 // ContentSettingMixedScriptBubbleModel ----------------------------------------
954 951
955 class ContentSettingMixedScriptBubbleModel 952 class ContentSettingMixedScriptBubbleModel
956 : public ContentSettingSimpleBubbleModel { 953 : public ContentSettingSimpleBubbleModel {
957 public: 954 public:
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() { 1189 void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() {
1193 if (!web_contents()) 1190 if (!web_contents())
1194 return; 1191 return;
1195 // Reset this embedder's entry to default for each of the requesting 1192 // Reset this embedder's entry to default for each of the requesting
1196 // origins currently on the page. 1193 // origins currently on the page.
1197 const GURL& embedder_url = web_contents()->GetURL(); 1194 const GURL& embedder_url = web_contents()->GetURL();
1198 TabSpecificContentSettings* content_settings = 1195 TabSpecificContentSettings* content_settings =
1199 TabSpecificContentSettings::FromWebContents(web_contents()); 1196 TabSpecificContentSettings::FromWebContents(web_contents());
1200 const ContentSettingsUsagesState::StateMap& state_map = 1197 const ContentSettingsUsagesState::StateMap& state_map =
1201 content_settings->midi_usages_state().state_map(); 1198 content_settings->midi_usages_state().state_map();
1202 HostContentSettingsMap* settings_map =
1203 HostContentSettingsMapFactory::GetForProfile(profile());
1204 1199
1205 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1200 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1206 settings_map->SetContentSettingDefaultScope( 1201 PermissionUtil::SetContentSettingAndRecordRevocation(
1207 map_entry.first, embedder_url, CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 1202 profile(), map_entry.first, embedder_url,
1208 std::string(), CONTENT_SETTING_DEFAULT); 1203 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(),
1204 CONTENT_SETTING_DEFAULT);
1209 } 1205 }
1210 } 1206 }
1211 1207
1212 // ContentSettingBubbleModel --------------------------------------------------- 1208 // ContentSettingBubbleModel ---------------------------------------------------
1213 1209
1214 // static 1210 // static
1215 ContentSettingBubbleModel* 1211 ContentSettingBubbleModel*
1216 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1212 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1217 Delegate* delegate, 1213 Delegate* delegate,
1218 WebContents* web_contents, 1214 WebContents* web_contents,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1318 ContentSettingBubbleModel::AsSimpleBubbleModel() { 1314 ContentSettingBubbleModel::AsSimpleBubbleModel() {
1319 // In general, bubble models might not inherit from the simple bubble model. 1315 // In general, bubble models might not inherit from the simple bubble model.
1320 return nullptr; 1316 return nullptr;
1321 } 1317 }
1322 1318
1323 ContentSettingMediaStreamBubbleModel* 1319 ContentSettingMediaStreamBubbleModel*
1324 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1320 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1325 // In general, bubble models might not inherit from the media bubble model. 1321 // In general, bubble models might not inherit from the media bubble model.
1326 return nullptr; 1322 return nullptr;
1327 } 1323 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_util_unittest.cc ('k') | chrome/browser/ui/website_settings/website_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698