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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_
8 #include "base/callback_forward.h"
9 #include "base/id_map.h"
10 #include "base/macros.h"
11 #include "components/content_settings/core/browser/content_settings_observer.h"
12 #include "components/keyed_service/core/keyed_service.h"
13 #include "content/public/browser/permission_manager.h"
19 enum class PermissionType
;
20 }; // namespace content
22 class PermissionManager
: public KeyedService
,
23 public content::PermissionManager
,
24 public content_settings::Observer
{
26 explicit PermissionManager(Profile
* profile
);
27 ~PermissionManager() override
;
29 // content::PermissionManager implementation.
30 void RequestPermission(
31 content::PermissionType permission
,
32 content::RenderFrameHost
* render_frame_host
,
34 const GURL
& requesting_origin
,
36 const base::Callback
<void(content::PermissionStatus
)>& callback
) override
;
37 void CancelPermissionRequest(content::PermissionType permission
,
38 content::RenderFrameHost
* render_frame_host
,
40 const GURL
& requesting_origin
) override
;
41 void ResetPermission(content::PermissionType permission
,
42 const GURL
& requesting_origin
,
43 const GURL
& embedding_origin
) override
;
44 content::PermissionStatus
GetPermissionStatus(
45 content::PermissionType permission
,
46 const GURL
& requesting_origin
,
47 const GURL
& embedding_origin
) override
;
48 void RegisterPermissionUsage(content::PermissionType permission
,
49 const GURL
& requesting_origin
,
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
;
60 using SubscriptionsMap
= IDMap
<Subscription
, IDMapOwnPointer
>;
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
;
69 SubscriptionsMap subscriptions_
;
71 DISALLOW_COPY_AND_ASSIGN(PermissionManager
);
74 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_