OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, | 146 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, |
147 content_settings_type_, std::string(), | 147 content_settings_type_, std::string(), |
148 CONTENT_SETTING_DEFAULT); | 148 CONTENT_SETTING_DEFAULT); |
149 } | 149 } |
150 | 150 |
151 void PermissionContextBase::CancelPermissionRequest( | 151 void PermissionContextBase::CancelPermissionRequest( |
152 content::WebContents* web_contents, | 152 content::WebContents* web_contents, |
153 const PermissionRequestID& id) { | 153 const PermissionRequestID& id) { |
154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
155 | 155 |
| 156 if (PermissionRequestManager::IsEnabled()) { |
| 157 PermissionRequest* cancelling = pending_requests_.get(id.ToString()); |
| 158 if (cancelling != nullptr && web_contents != nullptr && |
| 159 PermissionRequestManager::FromWebContents(web_contents) != nullptr) { |
| 160 PermissionRequestManager::FromWebContents(web_contents) |
| 161 ->CancelRequest(cancelling); |
| 162 } |
| 163 } else { |
156 #if defined(OS_ANDROID) | 164 #if defined(OS_ANDROID) |
157 GetQueueController()->CancelInfoBarRequest(id); | 165 GetQueueController()->CancelInfoBarRequest(id); |
158 #else | 166 #else |
159 PermissionRequest* cancelling = pending_requests_.get(id.ToString()); | 167 NOTREACHED(); |
160 if (cancelling != NULL && web_contents != NULL && | 168 #endif |
161 PermissionRequestManager::FromWebContents(web_contents) != NULL) { | |
162 PermissionRequestManager::FromWebContents(web_contents) | |
163 ->CancelRequest(cancelling); | |
164 } | 169 } |
165 #endif | |
166 } | 170 } |
167 | 171 |
168 void PermissionContextBase::DecidePermission( | 172 void PermissionContextBase::DecidePermission( |
169 content::WebContents* web_contents, | 173 content::WebContents* web_contents, |
170 const PermissionRequestID& id, | 174 const PermissionRequestID& id, |
171 const GURL& requesting_origin, | 175 const GURL& requesting_origin, |
172 const GURL& embedding_origin, | 176 const GURL& embedding_origin, |
173 bool user_gesture, | 177 bool user_gesture, |
174 const BrowserPermissionCallback& callback) { | 178 const BrowserPermissionCallback& callback) { |
175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 179 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 content_setting); | 311 content_setting); |
308 } | 312 } |
309 | 313 |
310 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 314 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
311 const std::string param = variations::GetVariationParamValue( | 315 const std::string param = variations::GetVariationParamValue( |
312 kPermissionsKillSwitchFieldStudy, | 316 kPermissionsKillSwitchFieldStudy, |
313 PermissionUtil::GetPermissionString(permission_type_)); | 317 PermissionUtil::GetPermissionString(permission_type_)); |
314 | 318 |
315 return param == kPermissionsKillSwitchBlockedValue; | 319 return param == kPermissionsKillSwitchBlockedValue; |
316 } | 320 } |
OLD | NEW |