Chromium Code Reviews| 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/containers/scoped_ptr_hash_map.h" | |
| 9 #include "base/id_map.h" | 10 #include "base/id_map.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | |
| 11 #include "components/content_settings/core/browser/content_settings_observer.h" | 13 #include "components/content_settings/core/browser/content_settings_observer.h" |
| 14 #include "components/content_settings/core/common/content_settings.h" | |
| 12 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
| 13 #include "content/public/browser/permission_manager.h" | 16 #include "content/public/browser/permission_manager.h" |
| 14 | 17 |
| 15 | 18 |
| 19 class PermissionRequestID; | |
| 16 class Profile; | 20 class Profile; |
| 17 | 21 |
| 18 namespace content { | 22 namespace content { |
| 19 enum class PermissionType; | 23 enum class PermissionType; |
| 20 }; // namespace content | 24 }; // namespace content |
| 21 | 25 |
| 22 class PermissionManager : public KeyedService, | 26 class PermissionManager : public KeyedService, |
| 23 public content::PermissionManager, | 27 public content::PermissionManager, |
| 24 public content_settings::Observer { | 28 public content_settings::Observer { |
| 25 public: | 29 public: |
| 26 explicit PermissionManager(Profile* profile); | 30 explicit PermissionManager(Profile* profile); |
| 27 ~PermissionManager() override; | 31 ~PermissionManager() override; |
| 28 | 32 |
| 29 // content::PermissionManager implementation. | 33 // content::PermissionManager implementation. |
| 30 void RequestPermission( | 34 void RequestPermission( |
| 31 content::PermissionType permission, | 35 content::PermissionType permission, |
| 32 content::RenderFrameHost* render_frame_host, | 36 content::RenderFrameHost* render_frame_host, |
| 33 int request_id, | 37 int request_id, |
| 34 const GURL& requesting_origin, | 38 const GURL& requesting_origin, |
| 35 bool user_gesture, | 39 bool user_gesture, |
| 36 const base::Callback<void(content::PermissionStatus)>& callback) override; | 40 const base::Callback<void(content::PermissionStatus)>& callback) override; |
| 41 void RequestPermissions( | |
| 42 const std::vector<content::PermissionType>& permissions, | |
| 43 content::RenderFrameHost* render_frame_host, | |
| 44 int request_id, | |
| 45 const GURL& requesting_origin, | |
| 46 bool user_gesture, | |
| 47 const base::Callback<void(const StatusVector&)>& callback) override; | |
| 37 void CancelPermissionRequest(content::PermissionType permission, | 48 void CancelPermissionRequest(content::PermissionType permission, |
| 38 content::RenderFrameHost* render_frame_host, | 49 content::RenderFrameHost* render_frame_host, |
| 39 int request_id, | 50 int request_id, |
| 40 const GURL& requesting_origin) override; | 51 const GURL& requesting_origin) override; |
| 52 void CancelPermissionsRequest(content::RenderFrameHost* render_frame_host, | |
| 53 int request_id) override; | |
| 41 void ResetPermission(content::PermissionType permission, | 54 void ResetPermission(content::PermissionType permission, |
| 42 const GURL& requesting_origin, | 55 const GURL& requesting_origin, |
| 43 const GURL& embedding_origin) override; | 56 const GURL& embedding_origin) override; |
| 44 content::PermissionStatus GetPermissionStatus( | 57 content::PermissionStatus GetPermissionStatus( |
| 45 content::PermissionType permission, | 58 content::PermissionType permission, |
| 46 const GURL& requesting_origin, | 59 const GURL& requesting_origin, |
| 47 const GURL& embedding_origin) override; | 60 const GURL& embedding_origin) override; |
| 48 void RegisterPermissionUsage(content::PermissionType permission, | 61 void RegisterPermissionUsage(content::PermissionType permission, |
| 49 const GURL& requesting_origin, | 62 const GURL& requesting_origin, |
| 50 const GURL& embedding_origin) override; | 63 const GURL& embedding_origin) override; |
| 51 int SubscribePermissionStatusChange( | 64 int SubscribePermissionStatusChange( |
| 52 content::PermissionType permission, | 65 content::PermissionType permission, |
| 53 const GURL& requesting_origin, | 66 const GURL& requesting_origin, |
| 54 const GURL& embedding_origin, | 67 const GURL& embedding_origin, |
| 55 const base::Callback<void(content::PermissionStatus)>& callback) override; | 68 const base::Callback<void(content::PermissionStatus)>& callback) override; |
| 56 void UnsubscribePermissionStatusChange(int subscription_id) override; | 69 void UnsubscribePermissionStatusChange(int subscription_id) override; |
| 57 | 70 |
| 58 private: | 71 private: |
| 59 struct Subscription; | 72 struct Subscription; |
| 60 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; | 73 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; |
| 61 | 74 |
| 75 struct PendingResponses; | |
| 76 struct PendingResponse; | |
|
Lalit Maganti (personal)
2015/08/03 23:10:26
Should be removed
| |
| 77 using PendingResponseMap | |
| 78 = base::ScopedPtrHashMap<int, scoped_ptr<PendingResponses>>; | |
| 79 | |
| 80 void OnRequestsResponse( | |
| 81 const base::Callback<void(const StatusVector&)>& callback, | |
| 82 const PermissionRequestID request, | |
| 83 PendingResponses* pending_responses, | |
| 84 int index, | |
| 85 ContentSetting content_setting); | |
| 86 | |
| 62 // content_settings::Observer implementation. | 87 // content_settings::Observer implementation. |
| 63 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | 88 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, |
| 64 const ContentSettingsPattern& secondary_pattern, | 89 const ContentSettingsPattern& secondary_pattern, |
| 65 ContentSettingsType content_type, | 90 ContentSettingsType content_type, |
| 66 std::string resource_identifier) override; | 91 std::string resource_identifier) override; |
| 67 | 92 |
| 68 Profile* profile_; | 93 Profile* profile_; |
| 69 SubscriptionsMap subscriptions_; | 94 SubscriptionsMap subscriptions_; |
| 95 PendingResponseMap pending_batch_responses_; | |
| 96 base::WeakPtrFactory<PermissionManager> weak_ptr_factory_; | |
|
Lalit Maganti (personal)
2015/08/03 23:10:26
Comment about this being the last.
| |
| 70 | 97 |
| 71 DISALLOW_COPY_AND_ASSIGN(PermissionManager); | 98 DISALLOW_COPY_AND_ASSIGN(PermissionManager); |
| 72 }; | 99 }; |
| 73 | 100 |
| 74 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 101 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| OLD | NEW |