Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: content/shell/browser/layout_test/layout_test_permission_manager.cc

Issue 1260193009: renderer: implement multiple permission requesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissions-request-multiple
Patch Set: Fix review comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 LayoutTestPermissionManager::~LayoutTestPermissionManager() { 61 LayoutTestPermissionManager::~LayoutTestPermissionManager() {
62 } 62 }
63 63
64 void LayoutTestPermissionManager::RequestPermission( 64 void LayoutTestPermissionManager::RequestPermission(
65 PermissionType permission, 65 PermissionType permission,
66 RenderFrameHost* render_frame_host, 66 RenderFrameHost* render_frame_host,
67 int request_id, 67 int request_id,
68 const GURL& requesting_origin, 68 const GURL& requesting_origin,
69 bool user_gesture, 69 bool user_gesture,
70 const base::Callback<void(PermissionStatus)>& callback) { 70 const RequestCallback& callback) {
mlamouri (slow - plz ping) 2015/09/02 11:36:42 nit: keep the plain callback type.
Lalit Maganti 2015/09/02 14:24:51 Done.
71 DCHECK_CURRENTLY_ON(BrowserThread::UI); 71 DCHECK_CURRENTLY_ON(BrowserThread::UI);
72 72
73 callback.Run(GetPermissionStatus( 73 callback.Run(GetPermissionStatus(
74 permission, requesting_origin, 74 permission, requesting_origin,
75 WebContents::FromRenderFrameHost(render_frame_host) 75 WebContents::FromRenderFrameHost(render_frame_host)
76 ->GetLastCommittedURL().GetOrigin())); 76 ->GetLastCommittedURL().GetOrigin()));
77 } 77 }
78 78
79 void LayoutTestPermissionManager::RequestPermission(
80 const std::vector<PermissionType>& permissions,
81 content::RenderFrameHost* render_frame_host,
82 int request_id,
83 const GURL& requesting_origin,
84 bool user_gesture,
85 const BatchRequestCallback& callback) {
86 DCHECK_CURRENTLY_ON(BrowserThread::UI);
87
88 std::vector<PermissionStatus> statuses(
mlamouri (slow - plz ping) 2015/09/02 11:36:42 nit: if you want, you can rename statuses to resul
Lalit Maganti 2015/09/02 14:24:51 Done.
89 permissions.size(), PERMISSION_STATUS_DENIED);
90 for (size_t i = 0; i < permissions.size(); i++) {
mlamouri (slow - plz ping) 2015/09/02 11:36:42 nit: you can probably do something among those lin
91 statuses[i] = GetPermissionStatus(
92 permissions[i], requesting_origin,
93 WebContents::FromRenderFrameHost(render_frame_host)
94 ->GetLastCommittedURL().GetOrigin());
95 }
96 callback.Run(statuses);
97 }
98
79 void LayoutTestPermissionManager::CancelPermissionRequest( 99 void LayoutTestPermissionManager::CancelPermissionRequest(
80 PermissionType permission,
81 RenderFrameHost* render_frame_host, 100 RenderFrameHost* render_frame_host,
82 int request_id, 101 int request_id) {
83 const GURL& requesting_origin) {
84 DCHECK_CURRENTLY_ON(BrowserThread::UI); 102 DCHECK_CURRENTLY_ON(BrowserThread::UI);
85 } 103 }
86 104
87 void LayoutTestPermissionManager::ResetPermission( 105 void LayoutTestPermissionManager::ResetPermission(
88 PermissionType permission, 106 PermissionType permission,
89 const GURL& requesting_origin, 107 const GURL& requesting_origin,
90 const GURL& embedding_origin) { 108 const GURL& embedding_origin) {
91 DCHECK_CURRENTLY_ON(BrowserThread::UI); 109 DCHECK_CURRENTLY_ON(BrowserThread::UI);
92 110
93 base::AutoLock lock(permissions_lock_); 111 base::AutoLock lock(permissions_lock_);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // 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
197 // prevent re-entrance issues. 215 // prevent re-entrance issues.
198 callbacks.push_back(base::Bind(subscription->callback, status)); 216 callbacks.push_back(base::Bind(subscription->callback, status));
199 } 217 }
200 218
201 for (const auto& callback : callbacks) 219 for (const auto& callback : callbacks)
202 callback.Run(); 220 callback.Run();
203 } 221 }
204 222
205 } // namespace content 223 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698