| 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 "chrome/browser/permissions/permission_manager.h" | 5 #include "chrome/browser/permissions/permission_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 weak_ptr_factory_.GetWeakPtr(), request_id, i))); | 310 weak_ptr_factory_.GetWeakPtr(), request_id, i))); |
| 311 } | 311 } |
| 312 | 312 |
| 313 // The request might have been resolved already. | 313 // The request might have been resolved already. |
| 314 if (!pending_requests_.Lookup(request_id)) | 314 if (!pending_requests_.Lookup(request_id)) |
| 315 return kNoPendingOperation; | 315 return kNoPendingOperation; |
| 316 | 316 |
| 317 return request_id; | 317 return request_id; |
| 318 } | 318 } |
| 319 | 319 |
| 320 std::size_t PermissionManager::PermissionTypeHash::operator()( | |
| 321 const content::PermissionType& type) const { | |
| 322 return static_cast<size_t>(type); | |
| 323 } | |
| 324 | |
| 325 PermissionContextBase* PermissionManager::GetPermissionContext( | 320 PermissionContextBase* PermissionManager::GetPermissionContext( |
| 326 PermissionType type) { | 321 PermissionType type) { |
| 327 const auto& it = permission_contexts_.find(type); | 322 const auto& it = permission_contexts_.find(type); |
| 328 return it == permission_contexts_.end() ? nullptr : it->second.get(); | 323 return it == permission_contexts_.end() ? nullptr : it->second.get(); |
| 329 } | 324 } |
| 330 | 325 |
| 331 void PermissionManager::OnPermissionsRequestResponseStatus( | 326 void PermissionManager::OnPermissionsRequestResponseStatus( |
| 332 int request_id, | 327 int request_id, |
| 333 int permission_id, | 328 int permission_id, |
| 334 PermissionStatus status) { | 329 PermissionStatus status) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // Add the callback to |callbacks| which will be run after the loop to | 470 // Add the callback to |callbacks| which will be run after the loop to |
| 476 // prevent re-entrance issues. | 471 // prevent re-entrance issues. |
| 477 callbacks.push_back( | 472 callbacks.push_back( |
| 478 base::Bind(subscription->callback, | 473 base::Bind(subscription->callback, |
| 479 ContentSettingToPermissionStatus(new_value))); | 474 ContentSettingToPermissionStatus(new_value))); |
| 480 } | 475 } |
| 481 | 476 |
| 482 for (const auto& callback : callbacks) | 477 for (const auto& callback : callbacks) |
| 483 callback.Run(); | 478 callback.Run(); |
| 484 } | 479 } |
| OLD | NEW |