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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 const base::Callback<void(PermissionStatus)>& callback) { | 69 const base::Callback<void(PermissionStatus)>& callback) { |
70 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
71 | 71 |
72 callback.Run(GetPermissionStatus( | 72 callback.Run(GetPermissionStatus( |
73 permission, requesting_origin, | 73 permission, requesting_origin, |
74 WebContents::FromRenderFrameHost(render_frame_host) | 74 WebContents::FromRenderFrameHost(render_frame_host) |
75 ->GetLastCommittedURL().GetOrigin())); | 75 ->GetLastCommittedURL().GetOrigin())); |
76 return kNoPendingOperation; | 76 return kNoPendingOperation; |
77 } | 77 } |
78 | 78 |
| 79 int LayoutTestPermissionManager::RequestPermissions( |
| 80 const std::vector<PermissionType>& permissions, |
| 81 content::RenderFrameHost* render_frame_host, |
| 82 const GURL& requesting_origin, |
| 83 bool user_gesture, |
| 84 const base::Callback<void( |
| 85 const std::vector<PermissionStatus>&)>& callback) { |
| 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 87 |
| 88 std::vector<PermissionStatus> result(permissions.size()); |
| 89 const GURL& embedding_origin = |
| 90 WebContents::FromRenderFrameHost(render_frame_host) |
| 91 ->GetLastCommittedURL().GetOrigin(); |
| 92 for (const auto& permission : permissions) { |
| 93 result.push_back(GetPermissionStatus( |
| 94 permission, requesting_origin, embedding_origin)); |
| 95 } |
| 96 |
| 97 callback.Run(result); |
| 98 return kNoPendingOperation; |
| 99 } |
| 100 |
79 void LayoutTestPermissionManager::CancelPermissionRequest(int request_id) { | 101 void LayoutTestPermissionManager::CancelPermissionRequest(int request_id) { |
80 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 102 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
81 } | 103 } |
82 | 104 |
83 void LayoutTestPermissionManager::ResetPermission( | 105 void LayoutTestPermissionManager::ResetPermission( |
84 PermissionType permission, | 106 PermissionType permission, |
85 const GURL& requesting_origin, | 107 const GURL& requesting_origin, |
86 const GURL& embedding_origin) { | 108 const GURL& embedding_origin) { |
87 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 109 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
88 | 110 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // 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 |
193 // prevent re-entrance issues. | 215 // prevent re-entrance issues. |
194 callbacks.push_back(base::Bind(subscription->callback, status)); | 216 callbacks.push_back(base::Bind(subscription->callback, status)); |
195 } | 217 } |
196 | 218 |
197 for (const auto& callback : callbacks) | 219 for (const auto& callback : callbacks) |
198 callback.Run(); | 220 callback.Run(); |
199 } | 221 } |
200 | 222 |
201 } // namespace content | 223 } // namespace content |
OLD | NEW |