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

Side by Side Diff: chrome/browser/permissions/permission_queue_controller.cc

Issue 2184823007: Add a feature which, when enabled, blocks permissions after X prompt dismissals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Improve test 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/permissions/permission_queue_controller.h" 5 #include "chrome/browser/permissions/permission_queue_controller.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 8 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h" 9 #include "chrome/browser/geolocation/geolocation_infobar_delegate_android.h"
10 #include "chrome/browser/infobars/infobar_service.h" 10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h" 11 #include "chrome/browser/media/midi_permission_infobar_delegate_android.h"
12 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h" 12 #include "chrome/browser/media/protected_media_identifier_infobar_delegate_andro id.h"
13 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h" 13 #include "chrome/browser/notifications/notification_permission_infobar_delegate. h"
14 #include "chrome/browser/permissions/permission_request.h" 14 #include "chrome/browser/permissions/permission_request.h"
15 #include "chrome/browser/permissions/permission_request_id.h" 15 #include "chrome/browser/permissions/permission_request_id.h"
16 #include "chrome/browser/permissions/permission_uma_util.h" 16 #include "chrome/browser/permissions/permission_uma_util.h"
17 #include "chrome/browser/permissions/permission_util.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/tab_contents/tab_util.h" 19 #include "chrome/browser/tab_contents/tab_util.h"
19 #include "components/content_settings/core/browser/host_content_settings_map.h" 20 #include "components/content_settings/core/browser/host_content_settings_map.h"
20 #include "components/content_settings/core/common/content_settings.h" 21 #include "components/content_settings/core/common/content_settings.h"
21 #include "components/infobars/core/infobar.h" 22 #include "components/infobars/core/infobar.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
24 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
25 #include "content/public/browser/notification_types.h" 26 #include "content/public/browser/notification_types.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 206 }
206 207
207 void PermissionQueueController::OnPermissionSet(const PermissionRequestID& id, 208 void PermissionQueueController::OnPermissionSet(const PermissionRequestID& id,
208 const GURL& requesting_frame, 209 const GURL& requesting_frame,
209 const GURL& embedder, 210 const GURL& embedder,
210 bool user_gesture, 211 bool user_gesture,
211 bool update_content_setting, 212 bool update_content_setting,
212 bool allowed) { 213 bool allowed) {
213 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 214 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
214 215
216 // Check if we should convert a dismiss decision into a block decision. This
217 // is gated on enabling the kBlockPromptsIfDismissedOften feature.
218 if (!update_content_setting &&
219 PermissionUtil::ShouldChangeDismissalToBlock(profile_, requesting_frame,
220 permission_type_)) {
221 update_content_setting = true;
222 allowed = false;
raymes 2016/07/28 08:07:50 I think there is a similar problem here. Thankfull
dominickn 2016/08/01 01:08:51 Acknowledged (see my comment above).
223 }
224
215 // TODO(miguelg): move the permission persistence to 225 // TODO(miguelg): move the permission persistence to
216 // PermissionContextBase once all the types are moved there. 226 // PermissionContextBase once all the types are moved there.
217 PermissionRequestGestureType gesture_type = 227 PermissionRequestGestureType gesture_type =
218 user_gesture ? PermissionRequestGestureType::GESTURE 228 user_gesture ? PermissionRequestGestureType::GESTURE
219 : PermissionRequestGestureType::NO_GESTURE; 229 : PermissionRequestGestureType::NO_GESTURE;
220 if (update_content_setting) { 230 if (update_content_setting) {
221 UpdateContentSetting(requesting_frame, embedder, allowed); 231 UpdateContentSetting(requesting_frame, embedder, allowed);
222 if (allowed) { 232 if (allowed) {
223 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, 233 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type,
224 requesting_frame, profile_); 234 requesting_frame, profile_);
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 411 }
402 412
403 ContentSetting content_setting = 413 ContentSetting content_setting =
404 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 414 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
405 415
406 HostContentSettingsMapFactory::GetForProfile(profile_) 416 HostContentSettingsMapFactory::GetForProfile(profile_)
407 ->SetContentSettingDefaultScope( 417 ->SetContentSettingDefaultScope(
408 requesting_frame.GetOrigin(), embedder.GetOrigin(), 418 requesting_frame.GetOrigin(), embedder.GetOrigin(),
409 content_settings_type_, std::string(), content_setting); 419 content_settings_type_, std::string(), content_setting);
410 } 420 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698