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" | |
10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 PermissionServiceContext::PermissionServiceContext( | 15 PermissionServiceContext::PermissionServiceContext( |
15 RenderFrameHost* render_frame_host) | 16 RenderFrameHost* render_frame_host) |
16 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), | 17 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), |
17 render_frame_host_(render_frame_host) { | 18 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) { | |
18 } | 27 } |
19 | 28 |
20 PermissionServiceContext::~PermissionServiceContext() { | 29 PermissionServiceContext::~PermissionServiceContext() { |
21 } | 30 } |
22 | 31 |
23 void PermissionServiceContext::CreateService( | 32 void PermissionServiceContext::CreateService( |
24 mojo::InterfaceRequest<PermissionService> request) { | 33 mojo::InterfaceRequest<PermissionService> request) { |
25 PermissionServiceImpl* service = | 34 PermissionServiceImpl* service = |
26 new PermissionServiceImpl(this); | 35 new PermissionServiceImpl(this); |
27 | 36 |
(...skipping 25 matching lines...) Expand all Loading... | |
53 | 62 |
54 void PermissionServiceContext::CancelPendingRequests( | 63 void PermissionServiceContext::CancelPendingRequests( |
55 RenderFrameHost* render_frame_host) const { | 64 RenderFrameHost* render_frame_host) const { |
56 if (render_frame_host != render_frame_host_) | 65 if (render_frame_host != render_frame_host_) |
57 return; | 66 return; |
58 | 67 |
59 for (auto* service : services_) | 68 for (auto* service : services_) |
60 service->CancelPendingRequests(); | 69 service->CancelPendingRequests(); |
61 } | 70 } |
62 | 71 |
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(); | |
Tom Sepez
2014/12/01 18:42:38
nit: ":" on previous line.
| |
83 } | |
84 | |
63 } // namespace content | 85 } // namespace content |
OLD | NEW |