| 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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/content_settings/core/browser/content_settings_observer.h" |
| 10 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
| 11 #include "content/public/browser/permission_manager.h" | 13 #include "content/public/browser/permission_manager.h" |
| 12 | 14 |
| 15 |
| 13 class Profile; | 16 class Profile; |
| 14 | 17 |
| 15 namespace content { | 18 namespace content { |
| 16 enum class PermissionType; | 19 enum class PermissionType; |
| 17 }; // namespace content | 20 }; // namespace content |
| 18 | 21 |
| 19 class PermissionManager : public KeyedService, | 22 class PermissionManager : public KeyedService, |
| 20 public content::PermissionManager { | 23 public content::PermissionManager, |
| 24 public content_settings::Observer { |
| 21 public: | 25 public: |
| 22 explicit PermissionManager(Profile* profile); | 26 explicit PermissionManager(Profile* profile); |
| 23 ~PermissionManager() override; | 27 ~PermissionManager() override; |
| 24 | 28 |
| 25 // content::PermissionManager implementation. | 29 // content::PermissionManager implementation. |
| 26 void RequestPermission( | 30 void RequestPermission( |
| 27 content::PermissionType permission, | 31 content::PermissionType permission, |
| 28 content::WebContents* web_contents, | 32 content::WebContents* web_contents, |
| 29 int request_id, | 33 int request_id, |
| 30 const GURL& requesting_origin, | 34 const GURL& requesting_origin, |
| 31 bool user_gesture, | 35 bool user_gesture, |
| 32 const base::Callback<void(content::PermissionStatus)>& callback) override; | 36 const base::Callback<void(content::PermissionStatus)>& callback) override; |
| 33 void CancelPermissionRequest(content::PermissionType permission, | 37 void CancelPermissionRequest(content::PermissionType permission, |
| 34 content::WebContents* web_contents, | 38 content::WebContents* web_contents, |
| 35 int request_id, | 39 int request_id, |
| 36 const GURL& requesting_origin) override; | 40 const GURL& requesting_origin) override; |
| 37 void ResetPermission(content::PermissionType permission, | 41 void ResetPermission(content::PermissionType permission, |
| 38 const GURL& requesting_origin, | 42 const GURL& requesting_origin, |
| 39 const GURL& embedding_origin) override; | 43 const GURL& embedding_origin) override; |
| 40 content::PermissionStatus GetPermissionStatus( | 44 content::PermissionStatus GetPermissionStatus( |
| 41 content::PermissionType permission, | 45 content::PermissionType permission, |
| 42 const GURL& requesting_origin, | 46 const GURL& requesting_origin, |
| 43 const GURL& embedding_origin) override; | 47 const GURL& embedding_origin) override; |
| 44 void RegisterPermissionUsage(content::PermissionType permission, | 48 void RegisterPermissionUsage(content::PermissionType permission, |
| 45 const GURL& requesting_origin, | 49 const GURL& requesting_origin, |
| 46 const GURL& embedding_origin) override; | 50 const GURL& embedding_origin) override; |
| 51 int SubscribePermissionStatusChange( |
| 52 content::PermissionType permission, |
| 53 const GURL& requesting_origin, |
| 54 const GURL& embedding_origin, |
| 55 const base::Callback<void(content::PermissionStatus)>& callback) override; |
| 56 void UnsubscribePermissionStatusChange(int subscription_id) override; |
| 47 | 57 |
| 48 private: | 58 private: |
| 59 struct Subscription; |
| 60 using SubscriptionsMap = IDMap<Subscription, IDMapOwnPointer>; |
| 61 |
| 62 // content_settings::Observer implementation. |
| 63 void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, |
| 64 const ContentSettingsPattern& secondary_pattern, |
| 65 ContentSettingsType content_type, |
| 66 std::string resource_identifier) override; |
| 67 |
| 49 Profile* profile_; | 68 Profile* profile_; |
| 69 SubscriptionsMap subscriptions_; |
| 50 | 70 |
| 51 DISALLOW_COPY_AND_ASSIGN(PermissionManager); | 71 DISALLOW_COPY_AND_ASSIGN(PermissionManager); |
| 52 }; | 72 }; |
| 53 | 73 |
| 54 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | 74 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ |
| OLD | NEW |