Skip to content

Commit b4842cc

Browse files
committed
Subclass PermissionManager
1 parent 07678b6 commit b4842cc

7 files changed

+59
-10
lines changed

browser/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ source_set("browser") {
104104
"//brave/components/brave_shields/browser:brave_shields",
105105
"extensions",
106106
"net",
107+
"permissions",
107108
]
108109

109110
if (is_mac) {

browser/permissions/BUILD.gn

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import("//build/config/features.gni")
2+
3+
source_set("permissions") {
4+
sources = [
5+
"brave_permission_manager.cc",
6+
"brave_permission_manager.h",
7+
]
8+
9+
deps = [
10+
"//chrome/browser",
11+
]
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
#include "brave/browser/permissions/brave_permission_manager.h"
6+
7+
#include "brave/browser/autoplay/autoplay_permission_context.h"
8+
9+
BravePermissionManager::BravePermissionManager(Profile* profile)
10+
: PermissionManager(profile) {
11+
permission_contexts_[CONTENT_SETTINGS_TYPE_AUTOPLAY] =
12+
std::make_unique<AutoplayPermissionContext>(profile);
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
* You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
#ifndef BRAVE_BROWSER_PERMISSION_BRAVE_PERMISSION_MANAGER_H_
6+
#define BRAVE_BROWSER_PERMISSION_BRAVE_PERMISSION_MANAGER_H_
7+
8+
#include "chrome/browser/permissions/permission_manager.h"
9+
10+
class BravePermissionManager : public PermissionManager {
11+
public:
12+
explicit BravePermissionManager(Profile* profile);
13+
14+
private:
15+
DISALLOW_COPY_AND_ASSIGN(BravePermissionManager);
16+
};
17+
18+
#endif // BRAVE_BROWSER_PERMISSION_BRAVE_PERMISSION_MANAGER_H_
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define PermissionManager BravePermissionManager
2+
#include "../../../../../../chrome/browser/permissions/permission_manager_factory.cc"
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/chrome/browser/permissions/permission_manager.cc b/chrome/browser/permissions/permission_manager.cc
2-
index af0c4c0e74fbcf78f02fe112f19724260dda456a..dc1dea1a9ec64c9d7b6344ee26be2e888f217076 100644
2+
index af0c4c0e74fbcf78f02fe112f19724260dda456a..045a82e8484d845cd6ee7871a39b8093ffb048ae 100644
33
--- a/chrome/browser/permissions/permission_manager.cc
44
+++ b/chrome/browser/permissions/permission_manager.cc
55
@@ -121,6 +121,8 @@ ContentSettingsType PermissionTypeToContentSetting(PermissionType permission) {
@@ -11,12 +11,3 @@ index af0c4c0e74fbcf78f02fe112f19724260dda456a..dc1dea1a9ec64c9d7b6344ee26be2e88
1111
case PermissionType::NUM:
1212
// This will hit the NOTREACHED below.
1313
break;
14-
@@ -304,6 +306,8 @@ PermissionManager::PermissionManager(Profile* profile) : profile_(profile) {
15-
std::make_unique<ClipboardWritePermissionContext>(profile);
16-
permission_contexts_[CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER] =
17-
std::make_unique<payments::PaymentHandlerPermissionContext>(profile);
18-
+ permission_contexts_[CONTENT_SETTINGS_TYPE_AUTOPLAY] =
19-
+ std::make_unique<AutoplayPermissionContext>(profile);
20-
}
21-
22-
PermissionManager::~PermissionManager() {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/chrome/browser/permissions/permission_manager.h b/chrome/browser/permissions/permission_manager.h
2+
index 1a8b5734e028db6b0c063b6927a032b02d852503..a6fbebbbeb6de88c277c13570a2208c4f5b22491 100644
3+
--- a/chrome/browser/permissions/permission_manager.h
4+
+++ b/chrome/browser/permissions/permission_manager.h
5+
@@ -120,6 +120,7 @@ class PermissionManager : public KeyedService,
6+
bool IsPermissionKillSwitchOn(ContentSettingsType);
7+
8+
private:
9+
+ friend class BravePermissionManager;
10+
friend class PermissionManagerTest;
11+
friend class GeolocationPermissionContextTests;
12+

0 commit comments

Comments
 (0)