| 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_context.h" | 5 #include "content/browser/permissions/permission_service_context.h" |
| 6 | 6 |
| 7 #include "content/browser/permissions/permission_service_impl.h" | 7 #include "content/browser/permissions/permission_service_impl.h" |
| 8 #include "content/public/browser/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
| 9 #include "content/public/browser/render_frame_host.h" | 9 #include "content/public/browser/render_frame_host.h" |
| 10 #include "content/public/browser/render_process_host.h" | |
| 11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 12 | 11 |
| 13 namespace content { | 12 namespace content { |
| 14 | 13 |
| 15 PermissionServiceContext::PermissionServiceContext( | 14 PermissionServiceContext::PermissionServiceContext( |
| 16 RenderFrameHost* render_frame_host) | 15 RenderFrameHost* render_frame_host) |
| 17 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), | 16 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), |
| 18 render_frame_host_(render_frame_host), | 17 render_frame_host_(render_frame_host) { |
| 19 render_process_host_(nullptr) { | |
| 20 } | |
| 21 | |
| 22 PermissionServiceContext::PermissionServiceContext( | |
| 23 RenderProcessHost* render_process_host) | |
| 24 : WebContentsObserver(nullptr), | |
| 25 render_frame_host_(nullptr), | |
| 26 render_process_host_(render_process_host) { | |
| 27 } | 18 } |
| 28 | 19 |
| 29 PermissionServiceContext::~PermissionServiceContext() { | 20 PermissionServiceContext::~PermissionServiceContext() { |
| 30 } | 21 } |
| 31 | 22 |
| 32 void PermissionServiceContext::CreateService( | 23 void PermissionServiceContext::CreateService( |
| 33 mojo::InterfaceRequest<PermissionService> request) { | 24 mojo::InterfaceRequest<PermissionService> request) { |
| 34 PermissionServiceImpl* service = | 25 PermissionServiceImpl* service = |
| 35 new PermissionServiceImpl(this); | 26 new PermissionServiceImpl(this); |
| 36 | 27 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 62 | 53 |
| 63 void PermissionServiceContext::CancelPendingRequests( | 54 void PermissionServiceContext::CancelPendingRequests( |
| 64 RenderFrameHost* render_frame_host) const { | 55 RenderFrameHost* render_frame_host) const { |
| 65 if (render_frame_host != render_frame_host_) | 56 if (render_frame_host != render_frame_host_) |
| 66 return; | 57 return; |
| 67 | 58 |
| 68 for (auto* service : services_) | 59 for (auto* service : services_) |
| 69 service->CancelPendingRequests(); | 60 service->CancelPendingRequests(); |
| 70 } | 61 } |
| 71 | 62 |
| 72 BrowserContext* PermissionServiceContext::GetBrowserContext() const { | |
| 73 if (!web_contents()) { | |
| 74 DCHECK(render_process_host_); | |
| 75 return render_process_host_->GetBrowserContext(); | |
| 76 } | |
| 77 return web_contents()->GetBrowserContext(); | |
| 78 } | |
| 79 | |
| 80 GURL PermissionServiceContext::GetEmbeddingOrigin() const { | |
| 81 return web_contents() ? web_contents()->GetLastCommittedURL().GetOrigin() | |
| 82 : GURL(); | |
| 83 } | |
| 84 | |
| 85 } // namespace content | 63 } // namespace content |
| OLD | NEW |