Skip to content

Commit

Permalink
Revert "Merge pull request #3303 from brave/cosmetic-filtering-frontend"
Browse files Browse the repository at this point in the history
This reverts commit fe9f891, reversing
changes made to 4e6ba95.
  • Loading branch information
bridiver committed Dec 18, 2019
1 parent ac27d50 commit 6d59ebf
Show file tree
Hide file tree
Showing 36 changed files with 13 additions and 807 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use_relative_paths = True

deps = {
"vendor/adblock_rust_ffi": "https://github.com/brave/adblock-rust-ffi.git@d757c647699ff7e6dacc5d7bbd51649b509609a5",
"vendor/adblock_rust_ffi": "https://github.com/brave/adblock-rust-ffi.git@89127a30655eaf54cf73794309846084ea8b91b9",
"vendor/autoplay-whitelist": "https://github.com/brave/autoplay-whitelist.git@ea527a4d36051daedb34421e129c98eda06cb5d3",
"vendor/extension-whitelist": "https://github.com/brave/extension-whitelist.git@7843f62e26a23c51336330e220e9d7992680aae9",
"vendor/hashset-cpp": "https://github.com/brave/hashset-cpp.git@6eab0271d014ff09bd9f38abe1e0c117e13e9aa9",
Expand Down
2 changes: 0 additions & 2 deletions browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ source_set("extensions") {
"//brave/components/brave_component_updater/browser",
"//brave/components/brave_extension:generated_resources",
"//brave/components/brave_extension:static_resources",
"//brave/components/brave_shields/browser",
"//chrome/browser/extensions",
"//chrome/common",
"//components/gcm_driver:gcm_driver",
"//components/gcm_driver:gcm_buildflags",
"//components/prefs",
Expand Down
45 changes: 0 additions & 45 deletions browser/extensions/api/brave_shields_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
#include <utility>

#include "base/strings/string_number_conversions.h"
#include "brave/browser/brave_browser_process_impl.h"
#include "brave/browser/extensions/api/brave_action_api.h"
#include "brave/browser/webcompat_reporter/webcompat_reporter_dialog.h"
#include "brave/common/extensions/api/brave_shields.h"
#include "brave/common/extensions/extension_constants.h"
#include "brave/components/brave_shields/browser/ad_block_service.h"
#include "brave/components/brave_shields/browser/brave_shields_p3a.h"
#include "brave/components/brave_shields/browser/brave_shields_util.h"
#include "brave/components/brave_shields/browser/brave_shields_web_contents_observer.h"
Expand All @@ -25,7 +23,6 @@
#include "chrome/browser/extensions/chrome_extension_function_details.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_util.h"

Expand All @@ -44,40 +41,6 @@ const char kInvalidControlTypeError[] = "Invalid ControlType.";

} // namespace


ExtensionFunction::ResponseAction
BraveShieldsHostnameCosmeticResourcesFunction::Run() {
std::unique_ptr<brave_shields::HostnameCosmeticResources::Params> params(
brave_shields::HostnameCosmeticResources::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());

base::Optional<base::Value> resources = g_brave_browser_process->
ad_block_service()->HostnameCosmeticResources(params->hostname);

if (!resources || !resources->is_dict()) {
return RespondNow(Error(
"Hostname-specific cosmetic resources could not be returned"));
}
auto result_list = std::make_unique<base::ListValue>();

result_list->GetList().push_back(std::move(*resources));

return RespondNow(ArgumentList(std::move(result_list)));
}

ExtensionFunction::ResponseAction BraveShieldsClassIdStylesheetFunction::Run() {
std::unique_ptr<brave_shields::ClassIdStylesheet::Params> params(
brave_shields::ClassIdStylesheet::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());

std::string stylesheet = g_brave_browser_process->
ad_block_service()->ClassIdStylesheet(params->classes,
params->ids,
params->exceptions);
return RespondNow(OneArgument(std::make_unique<base::Value>(stylesheet)));
}


ExtensionFunction::ResponseAction BraveShieldsAllowScriptsOnceFunction::Run() {
std::unique_ptr<brave_shields::AllowScriptsOnce::Params> params(
brave_shields::AllowScriptsOnce::Params::Create(*args_));
Expand Down Expand Up @@ -154,14 +117,6 @@ BraveShieldsGetBraveShieldsEnabledFunction::Run() {
return RespondNow(OneArgument(std::move(result)));
}

ExtensionFunction::ResponseAction
BraveShieldsGetCosmeticFilteringEnabledFunction::Run() {
auto result = std::make_unique<base::Value>(
base::FeatureList::IsEnabled(features::kBraveAdblockCosmeticFiltering));

return RespondNow(OneArgument(std::move(result)));
}

ExtensionFunction::ResponseAction BraveShieldsSetAdControlTypeFunction::Run() {
std::unique_ptr<brave_shields::SetAdControlType::Params> params(
brave_shields::SetAdControlType::Params::Create(*args_));
Expand Down
32 changes: 0 additions & 32 deletions browser/extensions/api/brave_shields_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@
namespace extensions {
namespace api {

class BraveShieldsHostnameCosmeticResourcesFunction : public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveShields.hostnameCosmeticResources", UNKNOWN)

protected:
~BraveShieldsHostnameCosmeticResourcesFunction() override {}

ResponseAction Run() override;
};

class BraveShieldsClassIdStylesheetFunction : public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveShields.classIdStylesheet", UNKNOWN)

protected:
~BraveShieldsClassIdStylesheetFunction() override {}

ResponseAction Run() override;
};

class BraveShieldsAllowScriptsOnceFunction : public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveShields.allowScriptsOnce", UNKNOWN)
Expand Down Expand Up @@ -72,18 +52,6 @@ class BraveShieldsGetBraveShieldsEnabledFunction : public ExtensionFunction {
ResponseAction Run() override;
};

class BraveShieldsGetCosmeticFilteringEnabledFunction
: public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveShields.getCosmeticFilteringEnabled",
UNKNOWN)

protected:
~BraveShieldsGetCosmeticFilteringEnabledFunction() override {}

ResponseAction Run() override;
};

class BraveShieldsSetAdControlTypeFunction : public ExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("braveShields.setAdControlType", UNKNOWN)
Expand Down
6 changes: 0 additions & 6 deletions chromium_src/chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
* 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/. */

#define BRAVE_FEATURE_ENTRIES \
{"brave-adblock-cosmetic-filtering", \
flag_descriptions::kBraveAdblockCosmeticFilteringName, \
flag_descriptions::kBraveAdblockCosmeticFilteringDescription, kOsAll, \
FEATURE_VALUE_TYPE(features::kBraveAdblockCosmeticFiltering)},

#define SetFeatureEntryEnabled SetFeatureEntryEnabled_ChromiumImpl
#include "../../../../chrome/browser/about_flags.cc" // NOLINT
#include "../../../../components/flags_ui/flags_state.cc" // NOLINT
Expand Down
12 changes: 0 additions & 12 deletions chromium_src/chrome/browser/flag_descriptions.cc

This file was deleted.

16 changes: 0 additions & 16 deletions chromium_src/chrome/browser/flag_descriptions.h

This file was deleted.

12 changes: 0 additions & 12 deletions chromium_src/chrome/common/chrome_features.cc

This file was deleted.

16 changes: 0 additions & 16 deletions chromium_src/chrome/common/chrome_features.h

This file was deleted.

76 changes: 0 additions & 76 deletions common/extensions/api/brave_shields.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,65 +73,6 @@
"description": "Notifies the browser about the fact of showing the panel",
"parameters": []
},
{
"name": "hostnameCosmeticResources",
"type": "function",
"description": "Get a cosmetic adblocking stylesheet, generic style exceptions, and script injections specific for the given hostname and domain",
"parameters": [
{
"name": "hostname",
"type": "string"
},
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "hostnameSpecificResources",
"type": "object",
"properties": {
"hide_selectors": {"type": "array", "items": {"type": "string"}, "description": "Hostname-specific CSS selectors that should be hidden from the page"},
"style_selectors": {"type": "object", "additionalProperties": {"type": "array", "items": {"type": "string"}}, "description": "Hostname-specific CSS selectors that should be restyled, with their associated CSS style rules"},
"exceptions": {"type": "array", "items": {"type": "string"}, "description": "Hostname-specific overrides for generic cosmetic blocking selectors"},
"injected_script": {"type": "string", "description": "A script to inject as the page is loading"}
}
}
]
}
]
},
{
"name": "classIdStylesheet",
"type": "function",
"description": "Get a stylesheet of generic rules that may apply to the given set of classes and ids without any of the given excepted selectors",
"parameters": [
{
"name": "classes",
"type": "array",
"items": {"type": "string"}
},
{
"name": "ids",
"type": "array",
"items": {"type": "string"}
},
{
"name": "exceptions",
"type": "array",
"items": {"type": "string"}
},
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "stylesheet",
"type": "string"
}
]
}
]
},
{
"name": "getBraveShieldsEnabled",
"type": "function",
Expand All @@ -153,23 +94,6 @@
}
]
},
{
"name": "getCosmeticFilteringEnabled",
"type": "function",
"description": "Get whether or not the cosmetic filtering feature flag is enabled",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "enabled",
"type": "boolean"
}
]
}
]
},
{
"name": "setAdControlType",
"type": "function",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ transpile_web_ui("brave_extension") {
["brave_extension_background", rebase_path("background.ts")],
["content", rebase_path("content.ts")],
["content_dapps", rebase_path("content_dapps.ts")],
["content_cosmetic", rebase_path("content_cosmetic.ts")],
["webstore", rebase_path("webstore.ts")],
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,28 +137,3 @@ export const shieldsReady: actions.ShieldsReady = () => {
type: types.SHIELDS_READY
}
}

export const generateClassIdStylesheet = (tabId: number, classes: string[], ids: string[]) => {
return {
type: types.GENERATE_CLASS_ID_STYLESHEET,
tabId,
classes,
ids
}
}

export const cosmeticFilterRuleExceptions = (tabId: number, exceptions: string[]) => {
return {
type: types.COSMETIC_FILTER_RULE_EXCEPTIONS,
tabId,
exceptions
}
}

export const contentScriptsLoaded: actions.ContentScriptsLoaded = (tabId: number, url: string) => {
return {
type: types.CONTENT_SCRIPTS_LOADED,
tabId,
url
}
}
Loading

0 comments on commit 6d59ebf

Please sign in to comment.