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
;
21 }; // namespace content
23 class PermissionManager
: public KeyedService
,
24 public content::PermissionManager
,
25 public content_settings::Observer
{
27 explicit PermissionManager(Profile
* profile
);
28 ~PermissionManager() override
;
30 // content::PermissionManager implementation.
31 void RequestPermission(
32 content::PermissionType permission
,
33 content::RenderFrameHost
* render_frame_host
,
35 const GURL
& requesting_origin
,
37 const base::Callback
<void(content::PermissionStatus
)>& callback
) override
;
38 void CancelPermissionRequest(content::PermissionType permission
,
39 content::RenderFrameHost
* render_frame_host
,
41 const GURL
& requesting_origin
) override
;
42 void ResetPermission(content::PermissionType permission
,
43 const GURL
& requesting_origin
,
44 const GURL
& embedding_origin
) override
;
45 content::PermissionStatus
GetPermissionStatus(
46 content::PermissionType permission
,
47 const GURL
& requesting_origin
,
48 const GURL
& embedding_origin
) override
;
49 void RegisterPermissionUsage(content::PermissionType permission
,
50 const GURL
& requesting_origin
,
51 const GURL
& embedding_origin
) override
;
52 int SubscribePermissionStatusChange(
53 content::PermissionType permission
,
54 const GURL
& requesting_origin
,
55 const GURL
& embedding_origin
,
56 const base::Callback
<void(content::PermissionStatus
)>& callback
) override
;
57 void UnsubscribePermissionStatusChange(int subscription_id
) override
;
61 using SubscriptionsMap
= IDMap
<Subscription
, IDMapOwnPointer
>;
63 // Not all WebContents are able to display permission requests. If the PBM
64 // is required but missing for |web_contents|, don't pass along the request.
65 bool IsPermissionBubbleManagerMissing(content::WebContents
* web_contents
);
67 // content_settings::Observer implementation.
68 void OnContentSettingChanged(const ContentSettingsPattern
& primary_pattern
,
69 const ContentSettingsPattern
& secondary_pattern
,
70 ContentSettingsType content_type
,
71 std::string resource_identifier
) override
;
74 SubscriptionsMap subscriptions_
;
76 DISALLOW_COPY_AND_ASSIGN(PermissionManager
);
79 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_