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

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

Issue 2386193004: Make all PermissionDecisionAutoBlocker methods static. (Closed)
Patch Set: Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_context_base.h" 5 #include "chrome/browser/permissions/permission_context_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 30 matching lines...) Expand all
41 "PermissionsKillSwitch"; 41 "PermissionsKillSwitch";
42 // static 42 // static
43 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] = 43 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] =
44 "blocked"; 44 "blocked";
45 45
46 PermissionContextBase::PermissionContextBase( 46 PermissionContextBase::PermissionContextBase(
47 Profile* profile, 47 Profile* profile,
48 const content::PermissionType permission_type, 48 const content::PermissionType permission_type,
49 const ContentSettingsType content_settings_type) 49 const ContentSettingsType content_settings_type)
50 : profile_(profile), 50 : profile_(profile),
51 decision_auto_blocker_(new PermissionDecisionAutoBlocker(profile)),
52 permission_type_(permission_type), 51 permission_type_(permission_type),
53 content_settings_type_(content_settings_type), 52 content_settings_type_(content_settings_type),
54 weak_factory_(this) { 53 weak_factory_(this) {
55 #if defined(OS_ANDROID) 54 #if defined(OS_ANDROID)
56 permission_queue_controller_.reset(new PermissionQueueController( 55 permission_queue_controller_.reset(new PermissionQueueController(
57 profile_, permission_type_, content_settings_type_)); 56 profile_, permission_type_, content_settings_type_));
58 #endif 57 #endif
58 PermissionDecisionAutoBlocker::UpdateFromVariations();
kcarattini 2016/10/04 05:26:05 How often do you expect the value to change? You c
dominickn 2016/10/04 06:18:54 I think having it within PermissionContextBase mak
raymes 2016/10/05 05:02:32 This will only really happen once at browser (prof
dominickn 2016/10/05 05:55:30 Acknowledged.
59 } 59 }
60 60
61 PermissionContextBase::~PermissionContextBase() { 61 PermissionContextBase::~PermissionContextBase() {
62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
63 } 63 }
64 64
65 void PermissionContextBase::RequestPermission( 65 void PermissionContextBase::RequestPermission(
66 content::WebContents* web_contents, 66 content::WebContents* web_contents,
67 const PermissionRequestID& id, 67 const PermissionRequestID& id,
68 const GURL& requesting_frame, 68 const GURL& requesting_frame,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 requesting_origin, profile_); 231 requesting_origin, profile_);
232 } else { 232 } else {
233 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, 233 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type,
234 requesting_origin, profile_); 234 requesting_origin, profile_);
235 } 235 }
236 #endif 236 #endif
237 237
238 // Check if we should convert a dismiss decision into a block decision. This 238 // Check if we should convert a dismiss decision into a block decision. This
239 // is gated on enabling the kBlockPromptsIfDismissedOften feature. 239 // is gated on enabling the kBlockPromptsIfDismissedOften feature.
240 if (content_setting == CONTENT_SETTING_DEFAULT && 240 if (content_setting == CONTENT_SETTING_DEFAULT &&
241 decision_auto_blocker_->ShouldChangeDismissalToBlock(requesting_origin, 241 PermissionDecisionAutoBlocker::ShouldChangeDismissalToBlock(
242 permission_type_)) { 242 requesting_origin, permission_type_, profile_)) {
243 persist = true; 243 persist = true;
244 content_setting = CONTENT_SETTING_BLOCK; 244 content_setting = CONTENT_SETTING_BLOCK;
245 } 245 }
246 246
247 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 247 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
248 persist, content_setting); 248 persist, content_setting);
249 } 249 }
250 250
251 #if defined(OS_ANDROID) 251 #if defined(OS_ANDROID)
252 PermissionQueueController* PermissionContextBase::GetQueueController() { 252 PermissionQueueController* PermissionContextBase::GetQueueController() {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 content_setting); 299 content_setting);
300 } 300 }
301 301
302 bool PermissionContextBase::IsPermissionKillSwitchOn() const { 302 bool PermissionContextBase::IsPermissionKillSwitchOn() const {
303 const std::string param = variations::GetVariationParamValue( 303 const std::string param = variations::GetVariationParamValue(
304 kPermissionsKillSwitchFieldStudy, 304 kPermissionsKillSwitchFieldStudy,
305 PermissionUtil::GetPermissionString(permission_type_)); 305 PermissionUtil::GetPermissionString(permission_type_));
306 306
307 return param == kPermissionsKillSwitchBlockedValue; 307 return param == kPermissionsKillSwitchBlockedValue;
308 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698