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 <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 callback.Run(std::vector<PermissionStatus>()); | 295 callback.Run(std::vector<PermissionStatus>()); |
296 return kNoPendingOperation; | 296 return kNoPendingOperation; |
297 } | 297 } |
298 | 298 |
299 content::WebContents* web_contents = | 299 content::WebContents* web_contents = |
300 content::WebContents::FromRenderFrameHost(render_frame_host); | 300 content::WebContents::FromRenderFrameHost(render_frame_host); |
301 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); | 301 GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); |
302 | 302 |
303 PendingRequest* pending_request = new PendingRequest( | 303 PendingRequest* pending_request = new PendingRequest( |
304 render_frame_host, permissions, callback); | 304 render_frame_host, permissions, callback); |
305 int request_id = pending_requests_.Add(pending_request); | 305 int request_id = pending_requests_.Add( |
| 306 std::unique_ptr<PendingRequest>(pending_request)); |
306 | 307 |
307 const PermissionRequestID request(render_frame_host, request_id); | 308 const PermissionRequestID request(render_frame_host, request_id); |
308 | 309 |
309 for (size_t i = 0; i < permissions.size(); ++i) { | 310 for (size_t i = 0; i < permissions.size(); ++i) { |
310 const PermissionType permission = permissions[i]; | 311 const PermissionType permission = permissions[i]; |
311 | 312 |
312 if (IsConstantPermission(permission) || | 313 if (IsConstantPermission(permission) || |
313 !GetPermissionContext(permission)) { | 314 !GetPermissionContext(permission)) { |
314 // Track permission request usages even for constant permissions. | 315 // Track permission request usages even for constant permissions. |
315 PermissionUmaUtil::PermissionRequested(permission, requesting_origin, | 316 PermissionUmaUtil::PermissionRequested(permission, requesting_origin, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 if (IsConstantPermission(permission)) { | 438 if (IsConstantPermission(permission)) { |
438 subscription->current_value = GetContentSettingForConstantPermission( | 439 subscription->current_value = GetContentSettingForConstantPermission( |
439 permission); | 440 permission); |
440 } else { | 441 } else { |
441 subscription->current_value = | 442 subscription->current_value = |
442 GetPermissionContext(permission) | 443 GetPermissionContext(permission) |
443 ->GetPermissionStatus(subscription->requesting_origin, | 444 ->GetPermissionStatus(subscription->requesting_origin, |
444 subscription->embedding_origin); | 445 subscription->embedding_origin); |
445 } | 446 } |
446 | 447 |
447 return subscriptions_.Add(subscription); | 448 return subscriptions_.Add(std::unique_ptr<Subscription>(subscription)); |
448 } | 449 } |
449 | 450 |
450 void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) { | 451 void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) { |
451 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 452 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
452 // Whether |subscription_id| is known will be checked by the Remove() call. | 453 // Whether |subscription_id| is known will be checked by the Remove() call. |
453 subscriptions_.Remove(subscription_id); | 454 subscriptions_.Remove(subscription_id); |
454 | 455 |
455 if (subscriptions_.IsEmpty()) | 456 if (subscriptions_.IsEmpty()) |
456 HostContentSettingsMapFactory::GetForProfile(profile_) | 457 HostContentSettingsMapFactory::GetForProfile(profile_) |
457 ->RemoveObserver(this); | 458 ->RemoveObserver(this); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // Add the callback to |callbacks| which will be run after the loop to | 495 // Add the callback to |callbacks| which will be run after the loop to |
495 // prevent re-entrance issues. | 496 // prevent re-entrance issues. |
496 callbacks.push_back( | 497 callbacks.push_back( |
497 base::Bind(subscription->callback, | 498 base::Bind(subscription->callback, |
498 ContentSettingToPermissionStatus(new_value))); | 499 ContentSettingToPermissionStatus(new_value))); |
499 } | 500 } |
500 | 501 |
501 for (const auto& callback : callbacks) | 502 for (const auto& callback : callbacks) |
502 callback.Run(); | 503 callback.Run(); |
503 } | 504 } |
OLD | NEW |