| 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 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 const GURL& requesting_origin, | 61 const GURL& requesting_origin, |
| 62 const GURL& embedding_origin) override; | 62 const GURL& embedding_origin) override; |
| 63 int SubscribePermissionStatusChange( | 63 int SubscribePermissionStatusChange( |
| 64 content::PermissionType permission, | 64 content::PermissionType permission, |
| 65 const GURL& requesting_origin, | 65 const GURL& requesting_origin, |
| 66 const GURL& embedding_origin, | 66 const GURL& embedding_origin, |
| 67 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) | 67 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) |
| 68 override; | 68 override; |
| 69 void UnsubscribePermissionStatusChange(int subscription_id) override; | 69 void UnsubscribePermissionStatusChange(int subscription_id) override; |
| 70 | 70 |
| 71 // TODO(raymes): Rather than exposing this, expose a denial reason from |
| 72 // GetPermissionStatus so that callers can determine whether a permission is |
| 73 // denied due to the kill switch. |
| 74 bool IsPermissionKillSwitchOn(content::PermissionType permission); |
| 75 |
| 71 private: | 76 private: |
| 72 friend class GeolocationPermissionContextTests; | 77 friend class GeolocationPermissionContextTests; |
| 73 // TODO(raymes): Refactor MediaPermission to not call GetPermissionContext. | |
| 74 // See crbug.com/596786. | |
| 75 friend class MediaPermission; | |
| 76 | 78 |
| 77 class PendingRequest; | 79 class PendingRequest; |
| 78 using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>; | 80 using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>; |
| 79 | 81 |
| 80 struct Subscription; | 82 struct Subscription; |
| 81 using SubscriptionsMap = IDMap<std::unique_ptr<Subscription>>; | 83 using SubscriptionsMap = IDMap<std::unique_ptr<Subscription>>; |
| 82 | 84 |
| 83 PermissionContextBase* GetPermissionContext(content::PermissionType type); | 85 PermissionContextBase* GetPermissionContext(content::PermissionType type); |
| 84 | 86 |
| 85 // Called when a permission was decided for a given PendingRequest. The | 87 // Called when a permission was decided for a given PendingRequest. The |
| 86 // PendingRequest is identified by its |request_id| and the permission is | 88 // PendingRequest is identified by its |request_id| and the permission is |
| 87 // identified by its |permission_id|. If the PendingRequest contains more than | 89 // identified by its |permission_id|. If the PendingRequest contains more than |
| 88 // one permission, it will wait for the remaining permissions to be resolved. | 90 // one permission, it will wait for the remaining permissions to be resolved. |
| 89 // When all the permissions have been resolved, the PendingRequest's callback | 91 // When all the permissions have been resolved, the PendingRequest's callback |
| 90 // is run. | 92 // is run. |
| 91 void OnPermissionsRequestResponseStatus( | 93 void OnPermissionsRequestResponseStatus( |
| 92 int request_id, | 94 int request_id, |
| 93 int permission_id, | 95 int permission_id, |
| 94 blink::mojom::PermissionStatus status); | 96 blink::mojom::PermissionStatus status); |
| 95 | 97 |
| 96 // content_settings::Observer implementation. | 98 // content_settings::Observer implementation. |
| 97 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 99 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, |
| 98 const ContentSettingsPattern& secondary_pattern, | 100 const ContentSettingsPattern& secondary_pattern, |
| 99 ContentSettingsType content_type, | 101 ContentSettingsType content_type, |
| 100 std::string resource_identifier) override; | 102 std::string resource_identifier) override; |
| 101 | 103 |
| 104 ContentSetting GetPermissionStatusInternal(content::PermissionType permission, |
| 105 const GURL& requesting_origin, |
| 106 const GURL& embedding_origin); |
| 107 |
| 102 Profile* profile_; | 108 Profile* profile_; |
| 103 PendingRequestsMap pending_requests_; | 109 PendingRequestsMap pending_requests_; |
| 104 SubscriptionsMap subscriptions_; | 110 SubscriptionsMap subscriptions_; |
| 105 | 111 |
| 106 std::unordered_map<content::PermissionType, | 112 std::unordered_map<content::PermissionType, |
| 107 std::unique_ptr<PermissionContextBase>, | 113 std::unique_ptr<PermissionContextBase>, |
| 108 PermissionTypeHash> | 114 PermissionTypeHash> |
| 109 permission_contexts_; | 115 permission_contexts_; |
| 110 | 116 |
| 111 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; | 117 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; |
| 112 | 118 |
| 113 DISALLOW_COPY_AND_ASSIGN(PermissionManager); | 119 DISALLOW_COPY_AND_ASSIGN(PermissionManager); |
| 114 }; | 120 }; |
| 115 | 121 |
| 116 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 122 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| OLD | NEW |