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

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

Issue 2165733003: Add revocation reporter to permission util (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add-source-ui-to-permission-report
Patch Set: Add missing return Created 4 years, 5 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/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" 15 #include "chrome/browser/content_settings/chrome_content_settings_utils.h"
16 #include "chrome/browser/content_settings/cookie_settings_factory.h" 16 #include "chrome/browser/content_settings/cookie_settings_factory.h"
17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
19 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" 19 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
20 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 21 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
22 #include "chrome/browser/permissions/permission_uma_util.h"
22 #include "chrome/browser/permissions/permission_util.h" 23 #include "chrome/browser/permissions/permission_util.h"
23 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 24 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 26 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
26 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 27 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
27 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega te.h" 28 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega te.h"
28 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
29 #include "chrome/common/pref_names.h" 30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/render_messages.h" 31 #include "chrome/common/render_messages.h"
31 #include "chrome/grit/generated_resources.h" 32 #include "chrome/grit/generated_resources.h"
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 724
724 void ContentSettingMediaStreamBubbleModel::UpdateSettings( 725 void ContentSettingMediaStreamBubbleModel::UpdateSettings(
725 ContentSetting setting) { 726 ContentSetting setting) {
726 if (profile()) { 727 if (profile()) {
727 TabSpecificContentSettings* tab_content_settings = 728 TabSpecificContentSettings* tab_content_settings =
728 TabSpecificContentSettings::FromWebContents(web_contents()); 729 TabSpecificContentSettings::FromWebContents(web_contents());
729 // The same urls must be used as in other places (e.g. the infobar) in 730 // 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. 731 // 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 732 // TODO(markusheintz): Extract to a helper so that there is only a single
732 // place to touch. 733 // place to touch.
734 HostContentSettingsMap* map =
735 HostContentSettingsMapFactory::GetForProfile(profile());
733 if (MicrophoneAccessed()) { 736 if (MicrophoneAccessed()) {
734 PermissionUtil::SetContentSettingAndRecordRevocation(profile(), 737 PermissionUtil::RevocationReporter scoped_revocation_reporter(
738 profile(), tab_content_settings->media_stream_access_origin(), GURL(),
739 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(),
740 PermissionSourceUI::PAGE_ACTION);
741 map->SetContentSettingDefaultScope(
735 tab_content_settings->media_stream_access_origin(), GURL(), 742 tab_content_settings->media_stream_access_origin(), GURL(),
736 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting); 743 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting);
737 } 744 }
738 if (CameraAccessed()) { 745 if (CameraAccessed()) {
739 PermissionUtil::SetContentSettingAndRecordRevocation(profile(), 746 PermissionUtil::RevocationReporter scoped_revocation_reporter(
747 profile(), tab_content_settings->media_stream_access_origin(), GURL(),
748 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(),
749 PermissionSourceUI::PAGE_ACTION);
750 map->SetContentSettingDefaultScope(
740 tab_content_settings->media_stream_access_origin(), GURL(), 751 tab_content_settings->media_stream_access_origin(), GURL(),
741 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting); 752 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting);
742 } 753 }
743 } 754 }
744 } 755 }
745 756
746 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType( 757 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType(
747 content::MediaStreamType type, 758 content::MediaStreamType type,
748 const std::string& device) { 759 const std::string& device) {
749 PrefService* prefs = profile()->GetPrefs(); 760 PrefService* prefs = profile()->GetPrefs();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { 944 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() {
934 if (!web_contents()) 945 if (!web_contents())
935 return; 946 return;
936 // Reset this embedder's entry to default for each of the requesting 947 // Reset this embedder's entry to default for each of the requesting
937 // origins currently on the page. 948 // origins currently on the page.
938 const GURL& embedder_url = web_contents()->GetURL(); 949 const GURL& embedder_url = web_contents()->GetURL();
939 TabSpecificContentSettings* content_settings = 950 TabSpecificContentSettings* content_settings =
940 TabSpecificContentSettings::FromWebContents(web_contents()); 951 TabSpecificContentSettings::FromWebContents(web_contents());
941 const ContentSettingsUsagesState::StateMap& state_map = 952 const ContentSettingsUsagesState::StateMap& state_map =
942 content_settings->geolocation_usages_state().state_map(); 953 content_settings->geolocation_usages_state().state_map();
943 954 HostContentSettingsMap* map =
955 HostContentSettingsMapFactory::GetForProfile(profile());
944 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 956 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
945 PermissionUtil::SetContentSettingAndRecordRevocation(profile(), 957 PermissionUtil::RevocationReporter(profile(), map_entry.first, embedder_url,
946 map_entry.first, embedder_url, CONTENT_SETTINGS_TYPE_GEOLOCATION, 958 CONTENT_SETTINGS_TYPE_GEOLOCATION,
947 std::string(), CONTENT_SETTING_DEFAULT); 959 std::string(),
raymes 2016/07/21 23:08:01 Will the resource_identifier argument be used in a
stefanocs 2016/07/22 00:44:28 Done. Probably not, so I am removing this for now.
960 PermissionSourceUI::PAGE_ACTION);
961 map->SetContentSettingDefaultScope(map_entry.first, embedder_url,
962 CONTENT_SETTINGS_TYPE_GEOLOCATION,
963 std::string(), CONTENT_SETTING_DEFAULT);
948 } 964 }
949 } 965 }
950 966
951 // ContentSettingMixedScriptBubbleModel ---------------------------------------- 967 // ContentSettingMixedScriptBubbleModel ----------------------------------------
952 968
953 class ContentSettingMixedScriptBubbleModel 969 class ContentSettingMixedScriptBubbleModel
954 : public ContentSettingSimpleBubbleModel { 970 : public ContentSettingSimpleBubbleModel {
955 public: 971 public:
956 ContentSettingMixedScriptBubbleModel(Delegate* delegate, 972 ContentSettingMixedScriptBubbleModel(Delegate* delegate,
957 WebContents* web_contents, 973 WebContents* web_contents,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() { 1222 void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() {
1207 if (!web_contents()) 1223 if (!web_contents())
1208 return; 1224 return;
1209 // Reset this embedder's entry to default for each of the requesting 1225 // Reset this embedder's entry to default for each of the requesting
1210 // origins currently on the page. 1226 // origins currently on the page.
1211 const GURL& embedder_url = web_contents()->GetURL(); 1227 const GURL& embedder_url = web_contents()->GetURL();
1212 TabSpecificContentSettings* content_settings = 1228 TabSpecificContentSettings* content_settings =
1213 TabSpecificContentSettings::FromWebContents(web_contents()); 1229 TabSpecificContentSettings::FromWebContents(web_contents());
1214 const ContentSettingsUsagesState::StateMap& state_map = 1230 const ContentSettingsUsagesState::StateMap& state_map =
1215 content_settings->midi_usages_state().state_map(); 1231 content_settings->midi_usages_state().state_map();
1216 1232 HostContentSettingsMap* map =
1233 HostContentSettingsMapFactory::GetForProfile(profile());
1217 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1234 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1218 PermissionUtil::SetContentSettingAndRecordRevocation( 1235 PermissionUtil::RevocationReporter(profile(), map_entry.first, embedder_url,
1219 profile(), map_entry.first, embedder_url, 1236 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
1220 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), 1237 std::string(),
1221 CONTENT_SETTING_DEFAULT); 1238 PermissionSourceUI::PAGE_ACTION);
1239 map->SetContentSettingDefaultScope(map_entry.first, embedder_url,
1240 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
1241 std::string(), CONTENT_SETTING_DEFAULT);
1222 } 1242 }
1223 } 1243 }
1224 1244
1225 // ContentSettingBubbleModel --------------------------------------------------- 1245 // ContentSettingBubbleModel ---------------------------------------------------
1226 1246
1227 // static 1247 // static
1228 ContentSettingBubbleModel* 1248 ContentSettingBubbleModel*
1229 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1249 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1230 Delegate* delegate, 1250 Delegate* delegate,
1231 WebContents* web_contents, 1251 WebContents* web_contents,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 ContentSettingBubbleModel::AsSimpleBubbleModel() { 1351 ContentSettingBubbleModel::AsSimpleBubbleModel() {
1332 // In general, bubble models might not inherit from the simple bubble model. 1352 // In general, bubble models might not inherit from the simple bubble model.
1333 return nullptr; 1353 return nullptr;
1334 } 1354 }
1335 1355
1336 ContentSettingMediaStreamBubbleModel* 1356 ContentSettingMediaStreamBubbleModel*
1337 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1357 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1338 // In general, bubble models might not inherit from the media bubble model. 1358 // In general, bubble models might not inherit from the media bubble model.
1339 return nullptr; 1359 return nullptr;
1340 } 1360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698