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

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: Remove unnecessary PermissionUtil changes 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 prompt_decision_log_.Get().ShouldChangeDismissalToBlock(
220 profile_, requesting_frame, permission_type_)) {
221 update_content_setting = true;
222 allowed = false;
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_);
225 } else { 235 } else {
226 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, 236 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type,
227 requesting_frame, profile_); 237 requesting_frame, profile_);
228 } 238 }
229 } else { 239 } else {
230 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, 240 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type,
231 requesting_frame, profile_); 241 requesting_frame, profile_);
232 } 242 }
raymes 2016/08/01 05:09:11 I actually suspect we can merge this code into Per
dominickn 2016/08/03 05:38:46 I think I can add it to my todo list, but it's a l
233 243
234 // Cancel this request first, then notify listeners. TODO(pkasting): Why 244 // Cancel this request first, then notify listeners. TODO(pkasting): Why
235 // is this order important? 245 // is this order important?
236 PendingInfobarRequests requests_to_notify; 246 PendingInfobarRequests requests_to_notify;
237 PendingInfobarRequests infobars_to_remove; 247 PendingInfobarRequests infobars_to_remove;
238 std::vector<PendingInfobarRequests::iterator> pending_requests_to_remove; 248 std::vector<PendingInfobarRequests::iterator> pending_requests_to_remove;
239 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin(); 249 for (PendingInfobarRequests::iterator i = pending_infobar_requests_.begin();
240 i != pending_infobar_requests_.end(); ++i) { 250 i != pending_infobar_requests_.end(); ++i) {
241 if (!i->IsForPair(requesting_frame, embedder)) 251 if (!i->IsForPair(requesting_frame, embedder))
242 continue; 252 continue;
(...skipping 158 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