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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 if (!context_->render_frame_host() || | 127 if (!context_->render_frame_host() || |
128 !browser_context->GetPermissionManager()) { | 128 !browser_context->GetPermissionManager()) { |
129 callback.Run(GetPermissionStatus(permission, origin)); | 129 callback.Run(GetPermissionStatus(permission, origin)); |
130 return; | 130 return; |
131 } | 131 } |
132 | 132 |
133 int pending_request_id = pending_requests_.Add(new PendingRequest( | 133 int pending_request_id = pending_requests_.Add(new PendingRequest( |
134 base::Bind(&PermissionRequestResponseCallbackWrapper, callback), 1)); | 134 base::Bind(&PermissionRequestResponseCallbackWrapper, callback), 1)); |
135 int id = browser_context->GetPermissionManager()->RequestPermission( | 135 int id = browser_context->GetPermissionManager()->RequestPermission( |
136 PermissionDescriptorToPermissionType(permission), | 136 PermissionDescriptorToPermissionType(permission), |
137 context_->render_frame_host(), GURL(origin.Serialize()), user_gesture, | 137 context_->render_frame_host(), origin.GetURL(), user_gesture, |
138 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, | 138 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, |
139 weak_factory_.GetWeakPtr(), pending_request_id)); | 139 weak_factory_.GetWeakPtr(), pending_request_id)); |
140 | 140 |
141 // Check if the request still exists. It might have been removed by the | 141 // Check if the request still exists. It might have been removed by the |
142 // callback if it was run synchronously. | 142 // callback if it was run synchronously. |
143 PendingRequest* pending_request = pending_requests_.Lookup( | 143 PendingRequest* pending_request = pending_requests_.Lookup( |
144 pending_request_id); | 144 pending_request_id); |
145 if (!pending_request) | 145 if (!pending_request) |
146 return; | 146 return; |
147 pending_request->id = id; | 147 pending_request->id = id; |
(...skipping 29 matching lines...) Expand all Loading... |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 std::vector<PermissionType> types(permissions.size()); | 180 std::vector<PermissionType> types(permissions.size()); |
181 for (size_t i = 0; i < types.size(); ++i) | 181 for (size_t i = 0; i < types.size(); ++i) |
182 types[i] = PermissionDescriptorToPermissionType(permissions[i]); | 182 types[i] = PermissionDescriptorToPermissionType(permissions[i]); |
183 | 183 |
184 int pending_request_id = pending_requests_.Add( | 184 int pending_request_id = pending_requests_.Add( |
185 new PendingRequest(callback, permissions.size())); | 185 new PendingRequest(callback, permissions.size())); |
186 int id = browser_context->GetPermissionManager()->RequestPermissions( | 186 int id = browser_context->GetPermissionManager()->RequestPermissions( |
187 types, context_->render_frame_host(), GURL(origin.Serialize()), | 187 types, context_->render_frame_host(), origin.GetURL(), user_gesture, |
188 user_gesture, | |
189 base::Bind(&PermissionServiceImpl::OnRequestPermissionsResponse, | 188 base::Bind(&PermissionServiceImpl::OnRequestPermissionsResponse, |
190 weak_factory_.GetWeakPtr(), pending_request_id)); | 189 weak_factory_.GetWeakPtr(), pending_request_id)); |
191 | 190 |
192 // Check if the request still exists. It may have been removed by the | 191 // Check if the request still exists. It may have been removed by the |
193 // the response callback. | 192 // the response callback. |
194 PendingRequest* pending_request = pending_requests_.Lookup( | 193 PendingRequest* pending_request = pending_requests_.Lookup( |
195 pending_request_id); | 194 pending_request_id); |
196 if (!pending_request) | 195 if (!pending_request) |
197 return; | 196 return; |
198 pending_request->id = id; | 197 pending_request->id = id; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 355 |
357 PermissionStatusCallback callback = subscription->callback; | 356 PermissionStatusCallback callback = subscription->callback; |
358 | 357 |
359 subscription->callback.Reset(); | 358 subscription->callback.Reset(); |
360 pending_subscriptions_.Remove(pending_subscription_id); | 359 pending_subscriptions_.Remove(pending_subscription_id); |
361 | 360 |
362 callback.Run(status); | 361 callback.Run(status); |
363 } | 362 } |
364 | 363 |
365 } // namespace content | 364 } // namespace content |
OLD | NEW |