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_impl.h" | 5 #include "content/browser/permissions/permission_service_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 callback.Run(GetPermissionStatusFromName(permission, GURL(origin.get()))); | 131 callback.Run(GetPermissionStatusFromName(permission, GURL(origin.get()))); |
132 return; | 132 return; |
133 } | 133 } |
134 | 134 |
135 int pending_request_id = pending_requests_.Add(new PendingRequest( | 135 int pending_request_id = pending_requests_.Add(new PendingRequest( |
136 base::Bind(&PermissionRequestResponseCallbackWrapper, callback), 1)); | 136 base::Bind(&PermissionRequestResponseCallbackWrapper, callback), 1)); |
137 int id = browser_context->GetPermissionManager()->RequestPermission( | 137 int id = browser_context->GetPermissionManager()->RequestPermission( |
138 PermissionNameToPermissionType(permission), | 138 PermissionNameToPermissionType(permission), |
139 context_->render_frame_host(), | 139 context_->render_frame_host(), |
140 GURL(origin.get()), | 140 GURL(origin.get()), |
141 user_gesture, // TODO(mlamouri): should be removed (crbug.com/423770) | |
dominickn
2016/07/01 01:28:28
Remove this TODO?
benwells
2016/07/01 01:56:29
Done.
| |
141 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, | 142 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, |
142 weak_factory_.GetWeakPtr(), | 143 weak_factory_.GetWeakPtr(), |
143 pending_request_id)); | 144 pending_request_id)); |
144 | 145 |
145 // Check if the request still exists. It might have been removed by the | 146 // Check if the request still exists. It might have been removed by the |
146 // callback if it was run synchronously. | 147 // callback if it was run synchronously. |
147 PendingRequest* pending_request = pending_requests_.Lookup( | 148 PendingRequest* pending_request = pending_requests_.Lookup( |
148 pending_request_id); | 149 pending_request_id); |
149 if (!pending_request) | 150 if (!pending_request) |
150 return; | 151 return; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 std::vector<PermissionType> types(permissions.size()); | 192 std::vector<PermissionType> types(permissions.size()); |
192 for (size_t i = 0; i < types.size(); ++i) | 193 for (size_t i = 0; i < types.size(); ++i) |
193 types[i] = PermissionNameToPermissionType(permissions[i]); | 194 types[i] = PermissionNameToPermissionType(permissions[i]); |
194 | 195 |
195 int pending_request_id = pending_requests_.Add( | 196 int pending_request_id = pending_requests_.Add( |
196 new PendingRequest(callback, permissions.size())); | 197 new PendingRequest(callback, permissions.size())); |
197 int id = browser_context->GetPermissionManager()->RequestPermissions( | 198 int id = browser_context->GetPermissionManager()->RequestPermissions( |
198 types, | 199 types, |
199 context_->render_frame_host(), | 200 context_->render_frame_host(), |
200 GURL(origin.get()), | 201 GURL(origin.get()), |
202 user_gesture, // TODO(mlamouri): should be removed (crbug.com/423770) | |
dominickn
2016/07/01 01:28:29
Remove TODO
benwells
2016/07/01 01:56:29
Done.
| |
201 base::Bind(&PermissionServiceImpl::OnRequestPermissionsResponse, | 203 base::Bind(&PermissionServiceImpl::OnRequestPermissionsResponse, |
202 weak_factory_.GetWeakPtr(), | 204 weak_factory_.GetWeakPtr(), |
203 pending_request_id)); | 205 pending_request_id)); |
204 | 206 |
205 // Check if the request still exists. It may have been removed by the | 207 // Check if the request still exists. It may have been removed by the |
206 // the response callback. | 208 // the response callback. |
207 PendingRequest* pending_request = pending_requests_.Lookup( | 209 PendingRequest* pending_request = pending_requests_.Lookup( |
208 pending_request_id); | 210 pending_request_id); |
209 if (!pending_request) | 211 if (!pending_request) |
210 return; | 212 return; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 | 369 |
368 PermissionStatusCallback callback = subscription->callback; | 370 PermissionStatusCallback callback = subscription->callback; |
369 | 371 |
370 subscription->callback.Reset(); | 372 subscription->callback.Reset(); |
371 pending_subscriptions_.Remove(pending_subscription_id); | 373 pending_subscriptions_.Remove(pending_subscription_id); |
372 | 374 |
373 callback.Run(status); | 375 callback.Run(status); |
374 } | 376 } |
375 | 377 |
376 } // namespace content | 378 } // namespace content |
OLD | NEW |