| 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 20 matching lines...) Expand all Loading... |
| 31 static PermissionManager* Get(Profile* profile); | 31 static PermissionManager* Get(Profile* profile); |
| 32 | 32 |
| 33 explicit PermissionManager(Profile* profile); | 33 explicit PermissionManager(Profile* profile); |
| 34 ~PermissionManager() override; | 34 ~PermissionManager() override; |
| 35 | 35 |
| 36 // content::PermissionManager implementation. | 36 // content::PermissionManager implementation. |
| 37 int RequestPermission( | 37 int RequestPermission( |
| 38 content::PermissionType permission, | 38 content::PermissionType permission, |
| 39 content::RenderFrameHost* render_frame_host, | 39 content::RenderFrameHost* render_frame_host, |
| 40 const GURL& requesting_origin, | 40 const GURL& requesting_origin, |
| 41 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) | 41 const base::Callback<void(permission::mojom::PermissionStatus)>& callback) |
| 42 override; | 42 override; |
| 43 int RequestPermissions( | 43 int RequestPermissions( |
| 44 const std::vector<content::PermissionType>& permissions, | 44 const std::vector<content::PermissionType>& permissions, |
| 45 content::RenderFrameHost* render_frame_host, | 45 content::RenderFrameHost* render_frame_host, |
| 46 const GURL& requesting_origin, | 46 const GURL& requesting_origin, |
| 47 const base::Callback< | 47 const base::Callback<void( |
| 48 void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) | 48 const std::vector<permission::mojom::PermissionStatus>&)>& callback) |
| 49 override; | 49 override; |
| 50 void CancelPermissionRequest(int request_id) override; | 50 void CancelPermissionRequest(int request_id) override; |
| 51 void ResetPermission(content::PermissionType permission, | 51 void ResetPermission(content::PermissionType permission, |
| 52 const GURL& requesting_origin, | 52 const GURL& requesting_origin, |
| 53 const GURL& embedding_origin) override; | 53 const GURL& embedding_origin) override; |
| 54 blink::mojom::PermissionStatus GetPermissionStatus( | 54 permission::mojom::PermissionStatus GetPermissionStatus( |
| 55 content::PermissionType permission, | 55 content::PermissionType permission, |
| 56 const GURL& requesting_origin, | 56 const GURL& requesting_origin, |
| 57 const GURL& embedding_origin) override; | 57 const GURL& embedding_origin) override; |
| 58 void RegisterPermissionUsage(content::PermissionType permission, | 58 void RegisterPermissionUsage(content::PermissionType permission, |
| 59 const GURL& requesting_origin, | 59 const GURL& requesting_origin, |
| 60 const GURL& embedding_origin) override; | 60 const GURL& embedding_origin) override; |
| 61 int SubscribePermissionStatusChange( | 61 int SubscribePermissionStatusChange( |
| 62 content::PermissionType permission, | 62 content::PermissionType permission, |
| 63 const GURL& requesting_origin, | 63 const GURL& requesting_origin, |
| 64 const GURL& embedding_origin, | 64 const GURL& embedding_origin, |
| 65 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) | 65 const base::Callback<void(permission::mojom::PermissionStatus)>& callback) |
| 66 override; | 66 override; |
| 67 void UnsubscribePermissionStatusChange(int subscription_id) override; | 67 void UnsubscribePermissionStatusChange(int subscription_id) override; |
| 68 | 68 |
| 69 private: | 69 private: |
| 70 friend class GeolocationPermissionContextTests; | 70 friend class GeolocationPermissionContextTests; |
| 71 // TODO(raymes): Refactor MediaPermission to not call GetPermissionContext. | 71 // TODO(raymes): Refactor MediaPermission to not call GetPermissionContext. |
| 72 // See crbug.com/596786. | 72 // See crbug.com/596786. |
| 73 friend class MediaPermission; | 73 friend class MediaPermission; |
| 74 | 74 |
| 75 class PendingRequest; | 75 class PendingRequest; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 | 86 |
| 87 // Called when a permission was decided for a given PendingRequest. The | 87 // Called when a permission was decided for a given PendingRequest. The |
| 88 // PendingRequest is identified by its |request_id| and the permission is | 88 // PendingRequest is identified by its |request_id| and the permission is |
| 89 // identified by its |permission_id|. If the PendingRequest contains more than | 89 // identified by its |permission_id|. If the PendingRequest contains more than |
| 90 // 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. |
| 91 // When all the permissions have been resolved, the PendingRequest's callback | 91 // When all the permissions have been resolved, the PendingRequest's callback |
| 92 // is run. | 92 // is run. |
| 93 void OnPermissionsRequestResponseStatus( | 93 void OnPermissionsRequestResponseStatus( |
| 94 int request_id, | 94 int request_id, |
| 95 int permission_id, | 95 int permission_id, |
| 96 blink::mojom::PermissionStatus status); | 96 permission::mojom::PermissionStatus status); |
| 97 | 97 |
| 98 // Not all WebContents are able to display permission requests. If the PBM | 98 // Not all WebContents are able to display permission requests. If the PBM |
| 99 // is required but missing for |web_contents|, don't pass along the request. | 99 // is required but missing for |web_contents|, don't pass along the request. |
| 100 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents); | 100 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents); |
| 101 | 101 |
| 102 // content_settings::Observer implementation. | 102 // content_settings::Observer implementation. |
| 103 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 103 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, |
| 104 const ContentSettingsPattern& secondary_pattern, | 104 const ContentSettingsPattern& secondary_pattern, |
| 105 ContentSettingsType content_type, | 105 ContentSettingsType content_type, |
| 106 std::string resource_identifier) override; | 106 std::string resource_identifier) override; |
| 107 | 107 |
| 108 Profile* profile_; | 108 Profile* profile_; |
| 109 PendingRequestsMap pending_requests_; | 109 PendingRequestsMap pending_requests_; |
| 110 SubscriptionsMap subscriptions_; | 110 SubscriptionsMap subscriptions_; |
| 111 | 111 |
| 112 std::unordered_map<content::PermissionType, | 112 std::unordered_map<content::PermissionType, |
| 113 std::unique_ptr<PermissionContextBase>, | 113 std::unique_ptr<PermissionContextBase>, |
| 114 PermissionTypeHash> | 114 PermissionTypeHash> |
| 115 permission_contexts_; | 115 permission_contexts_; |
| 116 | 116 |
| 117 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; | 117 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; |
| 118 | 118 |
| 119 DISALLOW_COPY_AND_ASSIGN(PermissionManager); | 119 DISALLOW_COPY_AND_ASSIGN(PermissionManager); |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 122 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| OLD | NEW |