| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 : PermissionManager() { | 58 : PermissionManager() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 LayoutTestPermissionManager::~LayoutTestPermissionManager() { | 61 LayoutTestPermissionManager::~LayoutTestPermissionManager() { |
| 62 } | 62 } |
| 63 | 63 |
| 64 int LayoutTestPermissionManager::RequestPermission( | 64 int LayoutTestPermissionManager::RequestPermission( |
| 65 PermissionType permission, | 65 PermissionType permission, |
| 66 RenderFrameHost* render_frame_host, | 66 RenderFrameHost* render_frame_host, |
| 67 const GURL& requesting_origin, | 67 const GURL& requesting_origin, |
| 68 bool user_gesture, |
| 68 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { | 69 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { |
| 69 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 70 | 71 |
| 71 callback.Run(GetPermissionStatus( | 72 callback.Run(GetPermissionStatus( |
| 72 permission, requesting_origin, | 73 permission, requesting_origin, |
| 73 WebContents::FromRenderFrameHost(render_frame_host) | 74 WebContents::FromRenderFrameHost(render_frame_host) |
| 74 ->GetLastCommittedURL().GetOrigin())); | 75 ->GetLastCommittedURL().GetOrigin())); |
| 75 return kNoPendingOperation; | 76 return kNoPendingOperation; |
| 76 } | 77 } |
| 77 | 78 |
| 78 int LayoutTestPermissionManager::RequestPermissions( | 79 int LayoutTestPermissionManager::RequestPermissions( |
| 79 const std::vector<PermissionType>& permissions, | 80 const std::vector<PermissionType>& permissions, |
| 80 content::RenderFrameHost* render_frame_host, | 81 content::RenderFrameHost* render_frame_host, |
| 81 const GURL& requesting_origin, | 82 const GURL& requesting_origin, |
| 83 bool user_gesture, |
| 82 const base::Callback< | 84 const base::Callback< |
| 83 void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) { | 85 void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) { |
| 84 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 85 | 87 |
| 86 std::vector<blink::mojom::PermissionStatus> result(permissions.size()); | 88 std::vector<blink::mojom::PermissionStatus> result(permissions.size()); |
| 87 const GURL& embedding_origin = | 89 const GURL& embedding_origin = |
| 88 WebContents::FromRenderFrameHost(render_frame_host) | 90 WebContents::FromRenderFrameHost(render_frame_host) |
| 89 ->GetLastCommittedURL().GetOrigin(); | 91 ->GetLastCommittedURL().GetOrigin(); |
| 90 for (const auto& permission : permissions) { | 92 for (const auto& permission : permissions) { |
| 91 result.push_back(GetPermissionStatus( | 93 result.push_back(GetPermissionStatus( |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Add the callback to |callbacks| which will be run after the loop to | 216 // Add the callback to |callbacks| which will be run after the loop to |
| 215 // prevent re-entrance issues. | 217 // prevent re-entrance issues. |
| 216 callbacks.push_back(base::Bind(subscription->callback, status)); | 218 callbacks.push_back(base::Bind(subscription->callback, status)); |
| 217 } | 219 } |
| 218 | 220 |
| 219 for (const auto& callback : callbacks) | 221 for (const auto& callback : callbacks) |
| 220 callback.Run(); | 222 callback.Run(); |
| 221 } | 223 } |
| 222 | 224 |
| 223 } // namespace content | 225 } // namespace content |
| OLD | NEW |