Skip to content

Commit

Permalink
Subclass PermissionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdh committed Jul 17, 2018
1 parent b4ae901 commit ea9e693
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 10 deletions.
1 change: 1 addition & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ source_set("browser") {
"//brave/components/omnibox/browser:brave_autocomplete",
"extensions",
"net",
"permissions",
]

if (is_mac) {
Expand Down
12 changes: 12 additions & 0 deletions browser/permissions/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import("//build/config/features.gni")

source_set("permissions") {
sources = [
"brave_permission_manager.cc",
"brave_permission_manager.h",
]

deps = [
"//chrome/browser",
]
}
13 changes: 13 additions & 0 deletions browser/permissions/brave_permission_manager.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/permissions/brave_permission_manager.h"

#include "brave/browser/autoplay/autoplay_permission_context.h"

BravePermissionManager::BravePermissionManager(Profile* profile)
: PermissionManager(profile) {
permission_contexts_[CONTENT_SETTINGS_TYPE_AUTOPLAY] =
std::make_unique<AutoplayPermissionContext>(profile);
}
18 changes: 18 additions & 0 deletions browser/permissions/brave_permission_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_PERMISSION_BRAVE_PERMISSION_MANAGER_H_
#define BRAVE_BROWSER_PERMISSION_BRAVE_PERMISSION_MANAGER_H_

#include "chrome/browser/permissions/permission_manager.h"

class BravePermissionManager : public PermissionManager {
public:
explicit BravePermissionManager(Profile* profile);

private:
DISALLOW_COPY_AND_ASSIGN(BravePermissionManager);
};

#endif // BRAVE_BROWSER_PERMISSION_BRAVE_PERMISSION_MANAGER_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define PermissionManager BravePermissionManager
#include "../../../../../../chrome/browser/permissions/permission_manager_factory.cc"
11 changes: 1 addition & 10 deletions patches/chrome-browser-permissions-permission_manager.cc.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/chrome/browser/permissions/permission_manager.cc b/chrome/browser/permissions/permission_manager.cc
index af0c4c0e74fbcf78f02fe112f19724260dda456a..dc1dea1a9ec64c9d7b6344ee26be2e888f217076 100644
index af0c4c0e74fbcf78f02fe112f19724260dda456a..045a82e8484d845cd6ee7871a39b8093ffb048ae 100644
--- a/chrome/browser/permissions/permission_manager.cc
+++ b/chrome/browser/permissions/permission_manager.cc
@@ -121,6 +121,8 @@ ContentSettingsType PermissionTypeToContentSetting(PermissionType permission) {
Expand All @@ -11,12 +11,3 @@ index af0c4c0e74fbcf78f02fe112f19724260dda456a..dc1dea1a9ec64c9d7b6344ee26be2e88
case PermissionType::NUM:
// This will hit the NOTREACHED below.
break;
@@ -304,6 +306,8 @@ PermissionManager::PermissionManager(Profile* profile) : profile_(profile) {
std::make_unique<ClipboardWritePermissionContext>(profile);
permission_contexts_[CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER] =
std::make_unique<payments::PaymentHandlerPermissionContext>(profile);
+ permission_contexts_[CONTENT_SETTINGS_TYPE_AUTOPLAY] =
+ std::make_unique<AutoplayPermissionContext>(profile);
}

PermissionManager::~PermissionManager() {
12 changes: 12 additions & 0 deletions patches/chrome-browser-permissions-permission_manager.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/chrome/browser/permissions/permission_manager.h b/chrome/browser/permissions/permission_manager.h
index 1a8b5734e028db6b0c063b6927a032b02d852503..a6fbebbbeb6de88c277c13570a2208c4f5b22491 100644
--- a/chrome/browser/permissions/permission_manager.h
+++ b/chrome/browser/permissions/permission_manager.h
@@ -120,6 +120,7 @@ class PermissionManager : public KeyedService,
bool IsPermissionKillSwitchOn(ContentSettingsType);

private:
+ friend class BravePermissionManager;
friend class PermissionManagerTest;
friend class GeolocationPermissionContextTests;

0 comments on commit ea9e693

Please sign in to comment.