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

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: 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_id.h" 14 #include "chrome/browser/permissions/permission_request_id.h"
15 #include "chrome/browser/permissions/permission_uma_util.h" 15 #include "chrome/browser/permissions/permission_uma_util.h"
16 #include "chrome/browser/permissions/permission_util.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/tab_contents/tab_util.h" 18 #include "chrome/browser/tab_contents/tab_util.h"
18 #include "components/content_settings/core/browser/host_content_settings_map.h" 19 #include "components/content_settings/core/browser/host_content_settings_map.h"
19 #include "components/content_settings/core/common/content_settings.h" 20 #include "components/content_settings/core/common/content_settings.h"
20 #include "components/infobars/core/infobar.h" 21 #include "components/infobars/core/infobar.h"
21 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 198 }
198 199
199 void PermissionQueueController::OnPermissionSet( 200 void PermissionQueueController::OnPermissionSet(
200 const PermissionRequestID& id, 201 const PermissionRequestID& id,
201 const GURL& requesting_frame, 202 const GURL& requesting_frame,
202 const GURL& embedder, 203 const GURL& embedder,
203 bool update_content_setting, 204 bool update_content_setting,
204 bool allowed) { 205 bool allowed) {
205 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 206 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
206 207
208 // Check if we should convert a dismiss decision into a block decision. This
209 // is gated on enabling the kBlockPromptsIfDismissedOften feature.
210 if (!update_content_setting &&
211 PermissionUtil::ShouldChangeDismissalToBlock(profile_, requesting_frame,
212 permission_type_)) {
213 update_content_setting = true;
214 allowed = false;
215 }
216
207 // TODO(miguelg): move the permission persistence to 217 // TODO(miguelg): move the permission persistence to
208 // PermissionContextBase once all the types are moved there. 218 // PermissionContextBase once all the types are moved there.
209 if (update_content_setting) { 219 if (update_content_setting) {
210 UpdateContentSetting(requesting_frame, embedder, allowed); 220 UpdateContentSetting(requesting_frame, embedder, allowed);
211 if (allowed) 221 if (allowed)
212 PermissionUmaUtil::PermissionGranted(permission_type_, requesting_frame, 222 PermissionUmaUtil::PermissionGranted(permission_type_, requesting_frame,
213 profile_); 223 profile_);
214 else 224 else
215 PermissionUmaUtil::PermissionDenied(permission_type_, requesting_frame, 225 PermissionUmaUtil::PermissionDenied(permission_type_, requesting_frame,
216 profile_); 226 profile_);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 399 }
390 400
391 ContentSetting content_setting = 401 ContentSetting content_setting =
392 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; 402 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK;
393 403
394 HostContentSettingsMapFactory::GetForProfile(profile_) 404 HostContentSettingsMapFactory::GetForProfile(profile_)
395 ->SetContentSettingDefaultScope( 405 ->SetContentSettingDefaultScope(
396 requesting_frame.GetOrigin(), embedder.GetOrigin(), 406 requesting_frame.GetOrigin(), embedder.GetOrigin(),
397 content_settings_type_, std::string(), content_setting); 407 content_settings_type_, std::string(), content_setting);
398 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698