| 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 "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/id_map.h" | 9 #include "base/id_map.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 public content_settings::Observer { | 26 public content_settings::Observer { |
| 27 public: | 27 public: |
| 28 explicit PermissionManager(Profile* profile); | 28 explicit PermissionManager(Profile* profile); |
| 29 ~PermissionManager() override; | 29 ~PermissionManager() override; |
| 30 | 30 |
| 31 // content::PermissionManager implementation. | 31 // content::PermissionManager implementation. |
| 32 int RequestPermission( | 32 int RequestPermission( |
| 33 content::PermissionType permission, | 33 content::PermissionType permission, |
| 34 content::RenderFrameHost* render_frame_host, | 34 content::RenderFrameHost* render_frame_host, |
| 35 const GURL& requesting_origin, | 35 const GURL& requesting_origin, |
| 36 const base::Callback<void(content::PermissionStatus)>& callback) override; | 36 const base::Callback<void(content::mojom::PermissionStatus)>& callback) |
| 37 override; |
| 37 int RequestPermissions( | 38 int RequestPermissions( |
| 38 const std::vector<content::PermissionType>& permissions, | 39 const std::vector<content::PermissionType>& permissions, |
| 39 content::RenderFrameHost* render_frame_host, | 40 content::RenderFrameHost* render_frame_host, |
| 40 const GURL& requesting_origin, | 41 const GURL& requesting_origin, |
| 41 const base::Callback<void( | 42 const base::Callback< |
| 42 const std::vector<content::PermissionStatus>&)>& callback) override; | 43 void(const std::vector<content::mojom::PermissionStatus>&)>& callback) |
| 44 override; |
| 43 void CancelPermissionRequest(int request_id) override; | 45 void CancelPermissionRequest(int request_id) override; |
| 44 void ResetPermission(content::PermissionType permission, | 46 void ResetPermission(content::PermissionType permission, |
| 45 const GURL& requesting_origin, | 47 const GURL& requesting_origin, |
| 46 const GURL& embedding_origin) override; | 48 const GURL& embedding_origin) override; |
| 47 content::PermissionStatus GetPermissionStatus( | 49 content::mojom::PermissionStatus GetPermissionStatus( |
| 48 content::PermissionType permission, | 50 content::PermissionType permission, |
| 49 const GURL& requesting_origin, | 51 const GURL& requesting_origin, |
| 50 const GURL& embedding_origin) override; | 52 const GURL& embedding_origin) override; |
| 51 void RegisterPermissionUsage(content::PermissionType permission, | 53 void RegisterPermissionUsage(content::PermissionType permission, |
| 52 const GURL& requesting_origin, | 54 const GURL& requesting_origin, |
| 53 const GURL& embedding_origin) override; | 55 const GURL& embedding_origin) override; |
| 54 int SubscribePermissionStatusChange( | 56 int SubscribePermissionStatusChange( |
| 55 content::PermissionType permission, | 57 content::PermissionType permission, |
| 56 const GURL& requesting_origin, | 58 const GURL& requesting_origin, |
| 57 const GURL& embedding_origin, | 59 const GURL& embedding_origin, |
| 58 const base::Callback<void(content::PermissionStatus)>& callback) override; | 60 const base::Callback<void(content::mojom::PermissionStatus)>& callback) |
| 61 override; |
| 59 void UnsubscribePermissionStatusChange(int subscription_id) override; | 62 void UnsubscribePermissionStatusChange(int subscription_id) override; |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 class PendingRequest; | 65 class PendingRequest; |
| 63 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>; | 66 using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>; |
| 64 | 67 |
| 65 struct Subscription; | 68 struct Subscription; |
| 66 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; | 69 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; |
| 67 | 70 |
| 68 // Called when a permission was decided for a given PendingRequest. The | 71 // Called when a permission was decided for a given PendingRequest. The |
| 69 // PendingRequest is identified by its |request_id| and the permission is | 72 // PendingRequest is identified by its |request_id| and the permission is |
| 70 // identified by its |permission_id|. If the PendingRequest contains more than | 73 // identified by its |permission_id|. If the PendingRequest contains more than |
| 71 // one permission, it will wait for the remaining permissions to be resolved. | 74 // one permission, it will wait for the remaining permissions to be resolved. |
| 72 // When all the permissions have been resolved, the PendingRequest's callback | 75 // When all the permissions have been resolved, the PendingRequest's callback |
| 73 // is run. | 76 // is run. |
| 74 void OnPermissionsRequestResponseStatus( | 77 void OnPermissionsRequestResponseStatus( |
| 75 int request_id, | 78 int request_id, |
| 76 int permission_id, | 79 int permission_id, |
| 77 content::PermissionStatus status); | 80 content::mojom::PermissionStatus status); |
| 78 | 81 |
| 79 // Not all WebContents are able to display permission requests. If the PBM | 82 // Not all WebContents are able to display permission requests. If the PBM |
| 80 // is required but missing for |web_contents|, don't pass along the request. | 83 // is required but missing for |web_contents|, don't pass along the request. |
| 81 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents); | 84 bool IsPermissionBubbleManagerMissing(content::WebContents* web_contents); |
| 82 | 85 |
| 83 // content_settings::Observer implementation. | 86 // content_settings::Observer implementation. |
| 84 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 87 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, |
| 85 const ContentSettingsPattern& secondary_pattern, | 88 const ContentSettingsPattern& secondary_pattern, |
| 86 ContentSettingsType content_type, | 89 ContentSettingsType content_type, |
| 87 std::string resource_identifier) override; | 90 std::string resource_identifier) override; |
| 88 | 91 |
| 89 Profile* profile_; | 92 Profile* profile_; |
| 90 PendingRequestsMap pending_requests_; | 93 PendingRequestsMap pending_requests_; |
| 91 SubscriptionsMap subscriptions_; | 94 SubscriptionsMap subscriptions_; |
| 92 | 95 |
| 93 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; | 96 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; |
| 94 | 97 |
| 95 DISALLOW_COPY_AND_ASSIGN(PermissionManager); | 98 DISALLOW_COPY_AND_ASSIGN(PermissionManager); |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 101 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| OLD | NEW |