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

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

Issue 2110343002: Reintroduce plumbing for user gesture into permission system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting Created 4 years, 5 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/logging.h" 10 #include "base/logging.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 PermissionContextBase::~PermissionContextBase() { 56 PermissionContextBase::~PermissionContextBase() {
57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 57 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
58 } 58 }
59 59
60 void PermissionContextBase::RequestPermission( 60 void PermissionContextBase::RequestPermission(
61 content::WebContents* web_contents, 61 content::WebContents* web_contents,
62 const PermissionRequestID& id, 62 const PermissionRequestID& id,
63 const GURL& requesting_frame, 63 const GURL& requesting_frame,
64 bool user_gesture,
64 const BrowserPermissionCallback& callback) { 65 const BrowserPermissionCallback& callback) {
65 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
66 67
67 // First check if this permission has been disabled. 68 // First check if this permission has been disabled.
68 if (IsPermissionKillSwitchOn()) { 69 if (IsPermissionKillSwitchOn()) {
69 // Log to the developer console. 70 // Log to the developer console.
70 web_contents->GetMainFrame()->AddMessageToConsole( 71 web_contents->GetMainFrame()->AddMessageToConsole(
71 content::CONSOLE_MESSAGE_LEVEL_LOG, 72 content::CONSOLE_MESSAGE_LEVEL_LOG,
72 base::StringPrintf( 73 base::StringPrintf(
73 "%s permission has been blocked.", 74 "%s permission has been blocked.",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 content_setting == CONTENT_SETTING_BLOCK) { 106 content_setting == CONTENT_SETTING_BLOCK) {
106 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, 107 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
107 false /* persist */, content_setting); 108 false /* persist */, content_setting);
108 return; 109 return;
109 } 110 }
110 111
111 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin, 112 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin,
112 embedding_origin, profile_); 113 embedding_origin, profile_);
113 114
114 DecidePermission(web_contents, id, requesting_origin, embedding_origin, 115 DecidePermission(web_contents, id, requesting_origin, embedding_origin,
115 callback); 116 user_gesture, callback);
116 } 117 }
117 118
118 ContentSetting PermissionContextBase::GetPermissionStatus( 119 ContentSetting PermissionContextBase::GetPermissionStatus(
119 const GURL& requesting_origin, 120 const GURL& requesting_origin,
120 const GURL& embedding_origin) const { 121 const GURL& embedding_origin) const {
121 122
122 // If the permission has been disabled through Finch, block all requests. 123 // If the permission has been disabled through Finch, block all requests.
123 if (IsPermissionKillSwitchOn()) 124 if (IsPermissionKillSwitchOn())
124 return CONTENT_SETTING_BLOCK; 125 return CONTENT_SETTING_BLOCK;
125 126
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ->CancelRequest(cancelling); 158 ->CancelRequest(cancelling);
158 } 159 }
159 #endif 160 #endif
160 } 161 }
161 162
162 void PermissionContextBase::DecidePermission( 163 void PermissionContextBase::DecidePermission(
163 content::WebContents* web_contents, 164 content::WebContents* web_contents,
164 const PermissionRequestID& id, 165 const PermissionRequestID& id,
165 const GURL& requesting_origin, 166 const GURL& requesting_origin,
166 const GURL& embedding_origin, 167 const GURL& embedding_origin,
168 bool user_gesture,
167 const BrowserPermissionCallback& callback) { 169 const BrowserPermissionCallback& callback) {
168 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 170 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
169 171
170 #if !defined(OS_ANDROID) 172 #if !defined(OS_ANDROID)
171 PermissionBubbleManager* bubble_manager = 173 PermissionBubbleManager* bubble_manager =
172 PermissionBubbleManager::FromWebContents(web_contents); 174 PermissionBubbleManager::FromWebContents(web_contents);
173 // TODO(felt): sometimes |bubble_manager| is null. This check is meant to 175 // TODO(felt): sometimes |bubble_manager| is null. This check is meant to
174 // prevent crashes. See crbug.com/457091. 176 // prevent crashes. See crbug.com/457091.
175 if (!bubble_manager) 177 if (!bubble_manager)
176 return; 178 return;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 content_setting); 284 content_setting);
283 } 285 }
284 286
285 bool PermissionContextBase::IsPermissionKillSwitchOn() const { 287 bool PermissionContextBase::IsPermissionKillSwitchOn() const {
286 const std::string param = variations::GetVariationParamValue( 288 const std::string param = variations::GetVariationParamValue(
287 kPermissionsKillSwitchFieldStudy, 289 kPermissionsKillSwitchFieldStudy,
288 PermissionUtil::GetPermissionString(permission_type_)); 290 PermissionUtil::GetPermissionString(permission_type_));
289 291
290 return param == kPermissionsKillSwitchBlockedValue; 292 return param == kPermissionsKillSwitchBlockedValue;
291 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698