| 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/child/permissions/permission_dispatcher.h" | 5 #include "content/child/permissions/permission_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/callback.h" | 10 #include "base/callback.h" |
| 10 #include "content/public/child/worker_thread.h" | 11 #include "content/public/child/worker_thread.h" |
| 11 #include "content/public/common/service_registry.h" | 12 #include "content/public/common/service_registry.h" |
| 12 #include "third_party/WebKit/public/platform/WebURL.h" | 13 #include "third_party/WebKit/public/platform/WebURL.h" |
| 13 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionOb
server.h" | 14 #include "third_party/WebKit/public/platform/modules/permissions/WebPermissionOb
server.h" |
| 14 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 15 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 15 | 16 |
| 16 using blink::WebPermissionObserver; | 17 using blink::WebPermissionObserver; |
| 17 | 18 |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // will not be called. | 290 // will not be called. |
| 290 uintptr_t callback_key = reinterpret_cast<uintptr_t>(callback); | 291 uintptr_t callback_key = reinterpret_cast<uintptr_t>(callback); |
| 291 permissions_callbacks_.add(callback_key, | 292 permissions_callbacks_.add(callback_key, |
| 292 scoped_ptr<blink::WebPermissionsCallback>(callback)); | 293 scoped_ptr<blink::WebPermissionsCallback>(callback)); |
| 293 | 294 |
| 294 mojo::Array<PermissionName> names(types.size()); | 295 mojo::Array<PermissionName> names(types.size()); |
| 295 for (size_t i = 0; i < types.size(); ++i) | 296 for (size_t i = 0; i < types.size(); ++i) |
| 296 names[i] = GetPermissionName(types[i]); | 297 names[i] = GetPermissionName(types[i]); |
| 297 | 298 |
| 298 GetPermissionServicePtr()->RequestPermissions( | 299 GetPermissionServicePtr()->RequestPermissions( |
| 299 names.Pass(), | 300 std::move(names), origin, |
| 300 origin, | |
| 301 blink::WebUserGestureIndicator::isProcessingUserGesture(), | 301 blink::WebUserGestureIndicator::isProcessingUserGesture(), |
| 302 base::Bind(&PermissionDispatcher::OnRequestPermissionsResponse, | 302 base::Bind(&PermissionDispatcher::OnRequestPermissionsResponse, |
| 303 base::Unretained(this), | 303 base::Unretained(this), worker_thread_id, callback_key)); |
| 304 worker_thread_id, | |
| 305 callback_key)); | |
| 306 } | 304 } |
| 307 | 305 |
| 308 void PermissionDispatcher::RevokePermissionInternal( | 306 void PermissionDispatcher::RevokePermissionInternal( |
| 309 blink::WebPermissionType type, | 307 blink::WebPermissionType type, |
| 310 const std::string& origin, | 308 const std::string& origin, |
| 311 blink::WebPermissionCallback* callback, | 309 blink::WebPermissionCallback* callback, |
| 312 int worker_thread_id) { | 310 int worker_thread_id) { |
| 313 // We need to save the |callback| in an ScopedPtrHashMap so if |this| gets | 311 // We need to save the |callback| in an ScopedPtrHashMap so if |this| gets |
| 314 // deleted, the callback will not leak. In the case of |this| gets deleted, | 312 // deleted, the callback will not leak. In the case of |this| gets deleted, |
| 315 // the |permission_service_| pipe will be destroyed too so OnQueryPermission | 313 // the |permission_service_| pipe will be destroyed too so OnQueryPermission |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 origin, | 404 origin, |
| 407 current_status, | 405 current_status, |
| 408 base::Bind(&PermissionDispatcher::OnPermissionChanged, | 406 base::Bind(&PermissionDispatcher::OnPermissionChanged, |
| 409 base::Unretained(this), | 407 base::Unretained(this), |
| 410 type, | 408 type, |
| 411 origin, | 409 origin, |
| 412 base::Unretained(observer))); | 410 base::Unretained(observer))); |
| 413 } | 411 } |
| 414 | 412 |
| 415 } // namespace content | 413 } // namespace content |
| OLD | NEW |