| 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 "content/browser/permissions/permission_service_impl.h" | 5 #include "content/browser/permissions/permission_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 PermissionType type, | 331 PermissionType type, |
| 332 const url::Origin& origin) { | 332 const url::Origin& origin) { |
| 333 BrowserContext* browser_context = context_->GetBrowserContext(); | 333 BrowserContext* browser_context = context_->GetBrowserContext(); |
| 334 DCHECK(browser_context); | 334 DCHECK(browser_context); |
| 335 if (!browser_context->GetPermissionManager() || | 335 if (!browser_context->GetPermissionManager() || |
| 336 !AllowedByFeaturePolicy(context_->render_frame_host(), type)) { | 336 !AllowedByFeaturePolicy(context_->render_frame_host(), type)) { |
| 337 return PermissionStatus::DENIED; | 337 return PermissionStatus::DENIED; |
| 338 } | 338 } |
| 339 | 339 |
| 340 GURL requesting_origin(origin.Serialize()); | 340 GURL requesting_origin(origin.Serialize()); |
| 341 // If the embedding_origin is empty we'll use |origin| instead. | 341 if (context_->render_frame_host()) { |
| 342 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 342 return browser_context->GetPermissionManager()->GetPermissionStatusForFrame( |
| 343 return browser_context->GetPermissionManager()->GetPermissionStatus( | 343 type, context_->render_frame_host(), requesting_origin); |
| 344 type, requesting_origin, | 344 } else { |
| 345 embedding_origin.is_empty() ? requesting_origin : embedding_origin); | 345 return browser_context->GetPermissionManager() |
| 346 ->GetPermissionStatusForWorker(type, requesting_origin); |
| 347 } |
| 346 } | 348 } |
| 347 | 349 |
| 348 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, | 350 void PermissionServiceImpl::ResetPermissionStatus(PermissionType type, |
| 349 const url::Origin& origin) { | 351 const url::Origin& origin) { |
| 350 BrowserContext* browser_context = context_->GetBrowserContext(); | 352 BrowserContext* browser_context = context_->GetBrowserContext(); |
| 351 DCHECK(browser_context); | 353 DCHECK(browser_context); |
| 352 if (!browser_context->GetPermissionManager()) | 354 if (!browser_context->GetPermissionManager()) |
| 353 return; | 355 return; |
| 354 | 356 |
| 355 GURL requesting_origin(origin.Serialize()); | 357 GURL requesting_origin(origin.Serialize()); |
| 356 // If the embedding_origin is empty we'll use |origin| instead. | 358 // If the embedding_origin is empty we'll use |origin| instead. |
| 357 GURL embedding_origin = context_->GetEmbeddingOrigin(); | 359 GURL embedding_origin = context_->GetEmbeddingOrigin(); |
| 358 browser_context->GetPermissionManager()->ResetPermission( | 360 browser_context->GetPermissionManager()->ResetPermission( |
| 359 type, requesting_origin, | 361 type, requesting_origin, |
| 360 embedding_origin.is_empty() ? requesting_origin : embedding_origin); | 362 embedding_origin.is_empty() ? requesting_origin : embedding_origin); |
| 361 } | 363 } |
| 362 | 364 |
| 363 } // namespace content | 365 } // namespace content |
| OLD | NEW |