OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/shell/browser/layout_test/layout_test_permission_manager.h" | 5 #include "content/shell/browser/layout_test/layout_test_permission_manager.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 base::AutoLock lock(permissions_lock_); | 114 base::AutoLock lock(permissions_lock_); |
115 | 115 |
116 auto it = permissions_.find( | 116 auto it = permissions_.find( |
117 PermissionDescription(permission, requesting_origin, embedding_origin)); | 117 PermissionDescription(permission, requesting_origin, embedding_origin)); |
118 if (it == permissions_.end()) | 118 if (it == permissions_.end()) |
119 return; | 119 return; |
120 permissions_.erase(it); | 120 permissions_.erase(it); |
121 } | 121 } |
122 | 122 |
123 blink::mojom::PermissionStatus LayoutTestPermissionManager::GetPermissionStatus( | 123 blink::mojom::PermissionStatus |
| 124 LayoutTestPermissionManager::GetPermissionStatusForFrame( |
124 PermissionType permission, | 125 PermissionType permission, |
125 const GURL& requesting_origin, | 126 content::RenderFrameHost* render_frame_host, |
126 const GURL& embedding_origin) { | 127 const GURL& requesting_origin) { |
127 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 128 return GetPermissionStatus(permission, requesting_origin, |
128 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 129 WebContents::FromRenderFrameHost(render_frame_host) |
| 130 ->GetLastCommittedURL() |
| 131 .GetOrigin()); |
| 132 } |
129 | 133 |
130 base::AutoLock lock(permissions_lock_); | 134 blink::mojom::PermissionStatus |
131 | 135 LayoutTestPermissionManager::GetPermissionStatusForWorker( |
132 auto it = permissions_.find( | 136 PermissionType permission, |
133 PermissionDescription(permission, requesting_origin, embedding_origin)); | 137 const GURL& requesting_origin) { |
134 if (it == permissions_.end()) | 138 return GetPermissionStatus(permission, requesting_origin, requesting_origin); |
135 return blink::mojom::PermissionStatus::DENIED; | |
136 return it->second; | |
137 } | 139 } |
138 | 140 |
139 int LayoutTestPermissionManager::SubscribePermissionStatusChange( | 141 int LayoutTestPermissionManager::SubscribePermissionStatusChange( |
140 PermissionType permission, | 142 PermissionType permission, |
141 const GURL& requesting_origin, | 143 const GURL& requesting_origin, |
142 const GURL& embedding_origin, | 144 const GURL& embedding_origin, |
143 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { | 145 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { |
144 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 146 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
145 | 147 |
146 auto subscription = base::MakeUnique<Subscription>(); | 148 auto subscription = base::MakeUnique<Subscription>(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 213 |
212 // Add the callback to |callbacks| which will be run after the loop to | 214 // Add the callback to |callbacks| which will be run after the loop to |
213 // prevent re-entrance issues. | 215 // prevent re-entrance issues. |
214 callbacks.push_back(base::Bind(subscription->callback, status)); | 216 callbacks.push_back(base::Bind(subscription->callback, status)); |
215 } | 217 } |
216 | 218 |
217 for (const auto& callback : callbacks) | 219 for (const auto& callback : callbacks) |
218 callback.Run(); | 220 callback.Run(); |
219 } | 221 } |
220 | 222 |
| 223 blink::mojom::PermissionStatus LayoutTestPermissionManager::GetPermissionStatus( |
| 224 PermissionType permission, |
| 225 const GURL& requesting_origin, |
| 226 const GURL& embedding_origin) { |
| 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 228 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 229 |
| 230 base::AutoLock lock(permissions_lock_); |
| 231 |
| 232 auto it = permissions_.find( |
| 233 PermissionDescription(permission, requesting_origin, embedding_origin)); |
| 234 if (it == permissions_.end()) |
| 235 return blink::mojom::PermissionStatus::DENIED; |
| 236 return it->second; |
| 237 } |
| 238 |
221 } // namespace content | 239 } // namespace content |
OLD | NEW |