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

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: Rebase Created 4 years, 4 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
« no previous file with comments | « chrome/browser/permissions/permission_util_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 726
726 void ContentSettingMediaStreamBubbleModel::UpdateSettings( 727 void ContentSettingMediaStreamBubbleModel::UpdateSettings(
727 ContentSetting setting) { 728 ContentSetting setting) {
728 if (profile()) { 729 if (profile()) {
729 TabSpecificContentSettings* tab_content_settings = 730 TabSpecificContentSettings* tab_content_settings =
730 TabSpecificContentSettings::FromWebContents(web_contents()); 731 TabSpecificContentSettings::FromWebContents(web_contents());
731 // The same urls must be used as in other places (e.g. the infobar) in 732 // The same urls must be used as in other places (e.g. the infobar) in
732 // order to override the existing rule. Otherwise a new rule is created. 733 // order to override the existing rule. Otherwise a new rule is created.
733 // TODO(markusheintz): Extract to a helper so that there is only a single 734 // TODO(markusheintz): Extract to a helper so that there is only a single
734 // place to touch. 735 // place to touch.
736 HostContentSettingsMap* map =
737 HostContentSettingsMapFactory::GetForProfile(profile());
735 if (MicrophoneAccessed()) { 738 if (MicrophoneAccessed()) {
736 PermissionUtil::SetContentSettingAndRecordRevocation(profile(), 739 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
740 profile(), tab_content_settings->media_stream_access_origin(), GURL(),
741 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
742 PermissionSourceUI::PAGE_ACTION);
743 map->SetContentSettingDefaultScope(
737 tab_content_settings->media_stream_access_origin(), GURL(), 744 tab_content_settings->media_stream_access_origin(), GURL(),
738 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting); 745 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting);
739 } 746 }
740 if (CameraAccessed()) { 747 if (CameraAccessed()) {
741 PermissionUtil::SetContentSettingAndRecordRevocation(profile(), 748 PermissionUtil::ScopedRevocationReporter scoped_revocation_reporter(
749 profile(), tab_content_settings->media_stream_access_origin(), GURL(),
750 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
751 PermissionSourceUI::PAGE_ACTION);
752 map->SetContentSettingDefaultScope(
742 tab_content_settings->media_stream_access_origin(), GURL(), 753 tab_content_settings->media_stream_access_origin(), GURL(),
743 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting); 754 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting);
744 } 755 }
745 } 756 }
746 } 757 }
747 758
748 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType( 759 void ContentSettingMediaStreamBubbleModel::UpdateDefaultDeviceForType(
749 content::MediaStreamType type, 760 content::MediaStreamType type,
750 const std::string& device) { 761 const std::string& device) {
751 PrefService* prefs = profile()->GetPrefs(); 762 PrefService* prefs = profile()->GetPrefs();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() { 946 void ContentSettingDomainListBubbleModel::OnCustomLinkClicked() {
936 if (!web_contents()) 947 if (!web_contents())
937 return; 948 return;
938 // Reset this embedder's entry to default for each of the requesting 949 // Reset this embedder's entry to default for each of the requesting
939 // origins currently on the page. 950 // origins currently on the page.
940 const GURL& embedder_url = web_contents()->GetURL(); 951 const GURL& embedder_url = web_contents()->GetURL();
941 TabSpecificContentSettings* content_settings = 952 TabSpecificContentSettings* content_settings =
942 TabSpecificContentSettings::FromWebContents(web_contents()); 953 TabSpecificContentSettings::FromWebContents(web_contents());
943 const ContentSettingsUsagesState::StateMap& state_map = 954 const ContentSettingsUsagesState::StateMap& state_map =
944 content_settings->geolocation_usages_state().state_map(); 955 content_settings->geolocation_usages_state().state_map();
945 956 HostContentSettingsMap* map =
957 HostContentSettingsMapFactory::GetForProfile(profile());
946 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 958 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
947 PermissionUtil::SetContentSettingAndRecordRevocation(profile(), 959 PermissionUtil::ScopedRevocationReporter(
948 map_entry.first, embedder_url, CONTENT_SETTINGS_TYPE_GEOLOCATION, 960 profile(), map_entry.first, embedder_url,
949 std::string(), CONTENT_SETTING_DEFAULT); 961 CONTENT_SETTINGS_TYPE_GEOLOCATION, PermissionSourceUI::PAGE_ACTION);
962 map->SetContentSettingDefaultScope(map_entry.first, embedder_url,
963 CONTENT_SETTINGS_TYPE_GEOLOCATION,
964 std::string(), CONTENT_SETTING_DEFAULT);
950 } 965 }
951 } 966 }
952 967
953 // ContentSettingMixedScriptBubbleModel ---------------------------------------- 968 // ContentSettingMixedScriptBubbleModel ----------------------------------------
954 969
955 class ContentSettingMixedScriptBubbleModel 970 class ContentSettingMixedScriptBubbleModel
956 : public ContentSettingSimpleBubbleModel { 971 : public ContentSettingSimpleBubbleModel {
957 public: 972 public:
958 ContentSettingMixedScriptBubbleModel(Delegate* delegate, 973 ContentSettingMixedScriptBubbleModel(Delegate* delegate,
959 WebContents* web_contents, 974 WebContents* web_contents,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() { 1229 void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() {
1215 if (!web_contents()) 1230 if (!web_contents())
1216 return; 1231 return;
1217 // Reset this embedder's entry to default for each of the requesting 1232 // Reset this embedder's entry to default for each of the requesting
1218 // origins currently on the page. 1233 // origins currently on the page.
1219 const GURL& embedder_url = web_contents()->GetURL(); 1234 const GURL& embedder_url = web_contents()->GetURL();
1220 TabSpecificContentSettings* content_settings = 1235 TabSpecificContentSettings* content_settings =
1221 TabSpecificContentSettings::FromWebContents(web_contents()); 1236 TabSpecificContentSettings::FromWebContents(web_contents());
1222 const ContentSettingsUsagesState::StateMap& state_map = 1237 const ContentSettingsUsagesState::StateMap& state_map =
1223 content_settings->midi_usages_state().state_map(); 1238 content_settings->midi_usages_state().state_map();
1224 1239 HostContentSettingsMap* map =
1240 HostContentSettingsMapFactory::GetForProfile(profile());
1225 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) { 1241 for (const std::pair<GURL, ContentSetting>& map_entry : state_map) {
1226 PermissionUtil::SetContentSettingAndRecordRevocation( 1242 PermissionUtil::ScopedRevocationReporter(
1227 profile(), map_entry.first, embedder_url, 1243 profile(), map_entry.first, embedder_url,
1228 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, std::string(), 1244 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, PermissionSourceUI::PAGE_ACTION);
1229 CONTENT_SETTING_DEFAULT); 1245 map->SetContentSettingDefaultScope(map_entry.first, embedder_url,
1246 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
1247 std::string(), CONTENT_SETTING_DEFAULT);
1230 } 1248 }
1231 } 1249 }
1232 1250
1233 // ContentSettingBubbleModel --------------------------------------------------- 1251 // ContentSettingBubbleModel ---------------------------------------------------
1234 1252
1235 // static 1253 // static
1236 ContentSettingBubbleModel* 1254 ContentSettingBubbleModel*
1237 ContentSettingBubbleModel::CreateContentSettingBubbleModel( 1255 ContentSettingBubbleModel::CreateContentSettingBubbleModel(
1238 Delegate* delegate, 1256 Delegate* delegate,
1239 WebContents* web_contents, 1257 WebContents* web_contents,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 ContentSettingBubbleModel::AsSimpleBubbleModel() { 1357 ContentSettingBubbleModel::AsSimpleBubbleModel() {
1340 // In general, bubble models might not inherit from the simple bubble model. 1358 // In general, bubble models might not inherit from the simple bubble model.
1341 return nullptr; 1359 return nullptr;
1342 } 1360 }
1343 1361
1344 ContentSettingMediaStreamBubbleModel* 1362 ContentSettingMediaStreamBubbleModel*
1345 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { 1363 ContentSettingBubbleModel::AsMediaStreamBubbleModel() {
1346 // In general, bubble models might not inherit from the media bubble model. 1364 // In general, bubble models might not inherit from the media bubble model.
1347 return nullptr; 1365 return nullptr;
1348 } 1366 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698