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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (!context_->render_frame_host() || | 122 if (!context_->render_frame_host() || |
123 !browser_context->GetPermissionManager()) { | 123 !browser_context->GetPermissionManager()) { |
124 callback.Run(GetPermissionStatusFromName(permission, origin)); | 124 callback.Run(GetPermissionStatusFromName(permission, origin)); |
125 return; | 125 return; |
126 } | 126 } |
127 | 127 |
128 int pending_request_id = pending_requests_.Add(new PendingRequest( | 128 int pending_request_id = pending_requests_.Add(new PendingRequest( |
129 base::Bind(&PermissionRequestResponseCallbackWrapper, callback), 1)); | 129 base::Bind(&PermissionRequestResponseCallbackWrapper, callback), 1)); |
130 int id = browser_context->GetPermissionManager()->RequestPermission( | 130 int id = browser_context->GetPermissionManager()->RequestPermission( |
131 PermissionNameToPermissionType(permission), context_->render_frame_host(), | 131 PermissionNameToPermissionType(permission), context_->render_frame_host(), |
132 GURL(origin.Serialize()), user_gesture, | 132 origin.GetURL(), user_gesture, |
133 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, | 133 base::Bind(&PermissionServiceImpl::OnRequestPermissionResponse, |
134 weak_factory_.GetWeakPtr(), pending_request_id)); | 134 weak_factory_.GetWeakPtr(), pending_request_id)); |
135 | 135 |
136 // Check if the request still exists. It might have been removed by the | 136 // Check if the request still exists. It might have been removed by the |
137 // callback if it was run synchronously. | 137 // callback if it was run synchronously. |
138 PendingRequest* pending_request = pending_requests_.Lookup( | 138 PendingRequest* pending_request = pending_requests_.Lookup( |
139 pending_request_id); | 139 pending_request_id); |
140 if (!pending_request) | 140 if (!pending_request) |
141 return; | 141 return; |
142 pending_request->id = id; | 142 pending_request->id = id; |
(...skipping 30 matching lines...) Expand all Loading... |
173 return; | 173 return; |
174 } | 174 } |
175 | 175 |
176 std::vector<PermissionType> types(permissions.size()); | 176 std::vector<PermissionType> types(permissions.size()); |
177 for (size_t i = 0; i < types.size(); ++i) | 177 for (size_t i = 0; i < types.size(); ++i) |
178 types[i] = PermissionNameToPermissionType(permissions[i]); | 178 types[i] = PermissionNameToPermissionType(permissions[i]); |
179 | 179 |
180 int pending_request_id = pending_requests_.Add( | 180 int pending_request_id = pending_requests_.Add( |
181 new PendingRequest(callback, permissions.size())); | 181 new PendingRequest(callback, permissions.size())); |
182 int id = browser_context->GetPermissionManager()->RequestPermissions( | 182 int id = browser_context->GetPermissionManager()->RequestPermissions( |
183 types, context_->render_frame_host(), GURL(origin.Serialize()), | 183 types, context_->render_frame_host(), origin.GetURL(), user_gesture, |
184 user_gesture, | |
185 base::Bind(&PermissionServiceImpl::OnRequestPermissionsResponse, | 184 base::Bind(&PermissionServiceImpl::OnRequestPermissionsResponse, |
186 weak_factory_.GetWeakPtr(), pending_request_id)); | 185 weak_factory_.GetWeakPtr(), pending_request_id)); |
187 | 186 |
188 // Check if the request still exists. It may have been removed by the | 187 // Check if the request still exists. It may have been removed by the |
189 // the response callback. | 188 // the response callback. |
190 PendingRequest* pending_request = pending_requests_.Lookup( | 189 PendingRequest* pending_request = pending_requests_.Lookup( |
191 pending_request_id); | 190 pending_request_id); |
192 if (!pending_request) | 191 if (!pending_request) |
193 return; | 192 return; |
194 pending_request->id = id; | 193 pending_request->id = id; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 350 |
352 PermissionStatusCallback callback = subscription->callback; | 351 PermissionStatusCallback callback = subscription->callback; |
353 | 352 |
354 subscription->callback.Reset(); | 353 subscription->callback.Reset(); |
355 pending_subscriptions_.Remove(pending_subscription_id); | 354 pending_subscriptions_.Remove(pending_subscription_id); |
356 | 355 |
357 callback.Run(status); | 356 callback.Run(status); |
358 } | 357 } |
359 | 358 |
360 } // namespace content | 359 } // namespace content |
OLD | NEW |