Skip to content

Commit

Permalink
Update background process store extension
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Nov 23, 2017
1 parent 072c5e0 commit 55cd96d
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 47 deletions.
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ group("child_dependencies") {
group("browser_dependencies") {
public_deps = [
"//brave/browser",
"//brave/common/extensions"
]
}

Expand Down
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ deps = {
"vendor/tracking-protection": "https://github.com/brave/tracking-protection.git@0931529eba33109c6b3946a83295577fea540045",
"vendor/hashset-cpp": "https://github.com/bbondy/hashset-cpp.git@f427324d667d7188a9e0975cca7f3a8c06226b4d",
"vendor/bloom-filter-cpp": "https://github.com/bbondy/bloom-filter-cpp.git@6faa14ececa33badad149c40f94ff9867159681c",
"vendor/brave-extension": "https://github.com/brave/brave-extension.git@64aa807bcf16effabc4a37cfed696e077a6c1974",
"vendor/brave-extension": "https://github.com/brave/brave-extension.git@4e7c8782e6d8c0f07b626d8f36c86093bcc7b687",
"vendor/requests": "https://github.com/kennethreitz/requests@e4d59bedfd3c7f4f254f4f5d036587bcd8152458",
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
"vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403",
Expand Down
9 changes: 9 additions & 0 deletions common/extensions/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source_set("extensions") {
sources = [
"brave_extensions_client.cc",
"brave_extensions_client.h",
]
deps = [
"api"
]
}
28 changes: 22 additions & 6 deletions common/extensions/api/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import("//extensions/common/api/schema.gni")
import("//tools/json_schema_compiler/json_features.gni")
import("//tools/json_schema_compiler/json_schema_api.gni")

json_schema_api("api") {
root_namespace = extensions_api_root_namespace
schemas = true
bundle = true
bundle_name = ""
json_features("api_features") {
feature_type = "APIFeature"
provider_class = "BraveAPIFeatureProvider"
sources = [
"_api_features.json",
]
}

json_schema_api("generated_api") {
sources = [
"brave_shields.json"
]
root_namespace = "extensions::api::%(namespace)s"
schemas = true
schema_include_rules = "extensions/common/api:extensions::api::%(namespace)s"
bundle = true
bundle_name = "Brave"
}

group("api") {
deps = [
":generated_api",
":api_features",
]
}
10 changes: 10 additions & 0 deletions common/extensions/api/_api_features.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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/.

{
"braveShields": {
"dependencies": ["permission:contentSettings"],
"contexts": ["blessed_extension"]
}
}
38 changes: 38 additions & 0 deletions common/extensions/brave_extensions_client.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* 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/common/extensions/brave_extensions_client.h"

#include <memory>
#include <set>
#include <string>

#include "brave/common/extensions/api/generated_schemas.h"
#include "base/strings/string_util.h"

namespace extensions {

static base::LazyInstance<BraveExtensionsClient>::Leaky g_client =
LAZY_INSTANCE_INITIALIZER;

bool BraveExtensionsClient::IsAPISchemaGenerated(
const std::string& name) const {
return ChromeExtensionsClient::IsAPISchemaGenerated(name) ||
api::BraveGeneratedSchemas::IsGenerated(name);
}

base::StringPiece BraveExtensionsClient::GetAPISchema(
const std::string& name) const {
if (api::BraveGeneratedSchemas::IsGenerated(name))
return api::BraveGeneratedSchemas::Get(name);

return ChromeExtensionsClient::GetAPISchema(name);
}

// static
ChromeExtensionsClient* BraveExtensionsClient::GetInstance() {
return g_client.Pointer();
}

} // namespace extensions
30 changes: 30 additions & 0 deletions common/extensions/brave_extensions_client.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* 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_COMMON_EXTENSIONS_BRAVE_EXTENSIONS_CLIENT_H_
#define BRAVE_COMMON_EXTENSIONS_BRAVE_EXTENSIONS_CLIENT_H_

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/common/extensions/chrome_extensions_client.h"

namespace extensions {

// The implementation of ExtensionsClient for Brave, which encapsulates the
// global knowledge of features, permissions, and manifest fields.
class BraveExtensionsClient : public ChromeExtensionsClient {
public:
bool IsAPISchemaGenerated(const std::string& name) const override;
base::StringPiece GetAPISchema(const std::string& name) const override;

// Get the LazyInstance for ChromeExtensionsClient.
static ChromeExtensionsClient* GetInstance();

private:
DISALLOW_COPY_AND_ASSIGN(BraveExtensionsClient);
};

} // namespace extensions

#endif // BRAVE_COMMON_EXTENSIONS_BRAVE_EXTENSIONS_CLIENT_H_
54 changes: 14 additions & 40 deletions patches/master_patch.patch
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,31 @@ index 77cd9e948514e875e636da465f60136ebd510491..fd587778baca0a6885dd143f6ad390d2

virtual CRLSetFetcher* crl_set_fetcher() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 675e9220b5fe7b71240ac28ab4e4fb97fae6fd96..070d45b3ac393d1b6f3f1f6dfd02d0712dfa1bab 100644
index 675e9220b5fe7b71240ac28ab4e4fb97fae6fd96..cb961a10f3bfa61bfc15344e3c635a835b16f121 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -34,7 +34,10 @@
@@ -34,7 +34,11 @@
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
+#include "brave/components/brave_shields/browser/brave_resource_dispatcher_host_delegate.h"
+#include "brave/common/extensions/brave_extensions_client.h"
#include "build/build_config.h"
+#include "brave/components/brave_shields/browser/ad_block_service.h"
+#include "brave/components/brave_shields/browser/tracking_protection_service.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/browser/chrome_child_process_watcher.h"
#include "chrome/browser/chrome_content_browser_client.h"
@@ -954,6 +957,25 @@ net_log::ChromeNetLog* BrowserProcessImpl::net_log() {
@@ -264,7 +268,7 @@ BrowserProcessImpl::BrowserProcessImpl(
base::MakeRefCounted<extensions::EventRouterForwarder>();

extensions::ExtensionsClient::Set(
- extensions::ChromeExtensionsClient::GetInstance());
+ extensions::BraveExtensionsClient::GetInstance());

extensions_browser_client_ =
base::MakeUnique<extensions::ChromeExtensionsBrowserClient>();
@@ -954,6 +958,25 @@ net_log::ChromeNetLog* BrowserProcessImpl::net_log() {
return net_log_.get();
}

Expand All @@ -219,7 +229,7 @@ index 675e9220b5fe7b71240ac28ab4e4fb97fae6fd96..070d45b3ac393d1b6f3f1f6dfd02d071
component_updater::ComponentUpdateService*
BrowserProcessImpl::component_updater() {
if (component_updater_)
@@ -1004,7 +1026,7 @@ BrowserProcessImpl::supervised_user_whitelist_installer() {
@@ -1004,7 +1027,7 @@ BrowserProcessImpl::supervised_user_whitelist_installer() {

void BrowserProcessImpl::ResourceDispatcherHostCreated() {
resource_dispatcher_host_delegate_ =
Expand Down Expand Up @@ -349,42 +359,6 @@ index 99a3f816756039a628dc3032cbda3971dd415138..2cf32156411bd3a28e8c8096e25dcee5
#else
#error Unknown branding
#endif
diff --git a/chrome/common/extensions/api/BUILD.gn b/chrome/common/extensions/api/BUILD.gn
index ad3703177d68941b91d570bcfa001848ffa179a9..a6eb9e854322f84a0d37c91218fd3bd93b412573 100644
--- a/chrome/common/extensions/api/BUILD.gn
+++ b/chrome/common/extensions/api/BUILD.gn
@@ -83,6 +83,8 @@ schema_sources = [
"webstore_private.json",
"webstore_widget_private.idl",
"windows.json",
+
+ "//brave/common/extensions/api/brave_shields.json",
]
if (!is_android) {
schema_sources += [ "processes.idl" ]
@@ -194,6 +196,7 @@ json_schema_api("api") {
root_namespace = extensions_api_root_namespace
deps = [
"//extensions/common/api",
+ "//brave/common/extensions/api",
]
}

diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 8ec1de091af1a17127e66bc67c6ee7cb8b5c2be3..0686739f34df6198129d2a9a363fba00da4a537e 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -826,5 +826,9 @@
"matches": [
"chrome://bookmarks/*"
]
- }]
+ }],
+ "braveShields": {
+ "dependencies": ["permission:contentSettings"],
+ "contexts": ["blessed_extension"]
+ }
}
diff --git a/chrome/common/extensions/api/content_settings.json b/chrome/common/extensions/api/content_settings.json
index 9c0927abbb6127eae9f4e3143f6d508aa9d81f72..2e1df067e514b2c67c86866ed18a97b9eec02697 100644
--- a/chrome/common/extensions/api/content_settings.json
Expand Down

0 comments on commit 55cd96d

Please sign in to comment.