620 lines
28 KiB
Diff
620 lines
28 KiB
Diff
From: csagan5 <32685696+csagan5@users.noreply.github.com>
|
|
Date: Sat, 14 Sep 2019 10:20:08 +0200
|
|
Subject: Bromite AdBlockUpdaterService
|
|
|
|
Disable look-alike, metrics, ablation and navigation throttles
|
|
Do not use experiments to enable/disable presets
|
|
Always enable ad filtering
|
|
Download filters by checking Last-Modified header first
|
|
Fix RestoreForeignSessionTab by recreating the tab (issue #681)
|
|
---
|
|
chrome/browser/after_startup_task_utils.cc | 5 +
|
|
chrome/browser/browser_process.h | 7 ++
|
|
chrome/browser/browser_process_impl.cc | 28 +++++
|
|
chrome/browser/browser_process_impl.h | 3 +
|
|
chrome/browser/chrome_browser_main.cc | 2 +
|
|
.../browser/chrome_content_browser_client.cc | 16 ---
|
|
.../sessions/session_restore_android.cc | 4 +-
|
|
components/component_updater/BUILD.gn | 6 +
|
|
...ent_subresource_filter_throttle_manager.cc | 11 ++
|
|
.../content/browser/ruleset_service.cc | 33 ++++-
|
|
.../content/browser/ruleset_service.h | 7 +-
|
|
.../content/browser/ruleset_version.cc | 1 +
|
|
.../content/browser/ruleset_version.h | 5 +
|
|
.../browser/verified_ruleset_dealer.cc | 3 +
|
|
.../browser/subresource_filter_features.cc | 113 +-----------------
|
|
.../core/common/common_features.cc | 2 +-
|
|
.../navigation_throttle_runner.cc | 5 -
|
|
17 files changed, 112 insertions(+), 139 deletions(-)
|
|
|
|
diff --git a/chrome/browser/after_startup_task_utils.cc b/chrome/browser/after_startup_task_utils.cc
|
|
--- a/chrome/browser/after_startup_task_utils.cc
|
|
+++ b/chrome/browser/after_startup_task_utils.cc
|
|
@@ -36,6 +36,8 @@
|
|
#include "ui/views/linux_ui/linux_ui.h"
|
|
#endif
|
|
|
|
+#include "chrome/browser/browser_process.h"
|
|
+
|
|
using content::BrowserThread;
|
|
using content::WebContents;
|
|
using content::WebContentsObserver;
|
|
@@ -138,6 +140,9 @@ void SetBrowserStartupIsComplete() {
|
|
g_after_startup_tasks.Get().clear();
|
|
g_after_startup_tasks.Get().shrink_to_fit();
|
|
|
|
+ // initialize scheduled updates for the AdBlock updater
|
|
+ g_browser_process->adblock_updater()->Start();
|
|
+
|
|
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
|
|
// Make sure we complete the startup notification sequence, or launchers will
|
|
// get confused by not receiving the expected message from the main process.
|
|
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
|
|
--- a/chrome/browser/browser_process.h
|
|
+++ b/chrome/browser/browser_process.h
|
|
@@ -21,6 +21,7 @@
|
|
#include "build/build_config.h"
|
|
#include "chrome/common/buildflags.h"
|
|
#include "media/media_buildflags.h"
|
|
+#include "components/component_updater/adblock_updater_service.h"
|
|
|
|
class BackgroundModeManager;
|
|
class BrowserProcessPlatformPart;
|
|
@@ -67,6 +68,10 @@ class ComponentUpdateService;
|
|
class SupervisedUserWhitelistInstaller;
|
|
}
|
|
|
|
+namespace adblock_updater {
|
|
+class AdBlockUpdaterService;
|
|
+}
|
|
+
|
|
namespace extensions {
|
|
class EventRouterForwarder;
|
|
}
|
|
@@ -249,6 +254,8 @@ class BrowserProcess {
|
|
|
|
virtual component_updater::ComponentUpdateService* component_updater() = 0;
|
|
|
|
+ virtual adblock_updater::AdBlockUpdaterService* adblock_updater() = 0;
|
|
+
|
|
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
|
virtual component_updater::SupervisedUserWhitelistInstaller*
|
|
supervised_user_whitelist_installer() = 0;
|
|
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
|
|
--- a/chrome/browser/browser_process_impl.cc
|
|
+++ b/chrome/browser/browser_process_impl.cc
|
|
@@ -1050,6 +1050,34 @@ BrowserProcessImpl::component_updater() {
|
|
return component_updater_.get();
|
|
}
|
|
|
|
+adblock_updater::AdBlockUpdaterService*
|
|
+BrowserProcessImpl::adblock_updater() {
|
|
+ if (adblock_updater_)
|
|
+ return adblock_updater_.get();
|
|
+
|
|
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI))
|
|
+ return nullptr;
|
|
+
|
|
+ std::unique_ptr<component_updater::UpdateScheduler> scheduler;
|
|
+#if defined(OS_ANDROID)
|
|
+ if (base::FeatureList::IsEnabled(
|
|
+ chrome::android::kBackgroundTaskComponentUpdate) &&
|
|
+ component_updater::BackgroundTaskUpdateScheduler::IsAvailable()) {
|
|
+ scheduler =
|
|
+ std::make_unique<component_updater::BackgroundTaskUpdateScheduler>();
|
|
+ }
|
|
+#endif
|
|
+ if (!scheduler)
|
|
+ scheduler = std::make_unique<component_updater::TimerUpdateScheduler>();
|
|
+
|
|
+ adblock_updater_ = std::make_unique<adblock_updater::AdBlockUpdaterService>(
|
|
+ g_browser_process->system_network_context_manager()->GetSharedURLLoaderFactory(),
|
|
+ std::move(scheduler),
|
|
+ g_browser_process->subresource_filter_ruleset_service());
|
|
+
|
|
+ return adblock_updater_.get();
|
|
+}
|
|
+
|
|
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
|
component_updater::SupervisedUserWhitelistInstaller*
|
|
BrowserProcessImpl::supervised_user_whitelist_installer() {
|
|
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
|
|
--- a/chrome/browser/browser_process_impl.h
|
|
+++ b/chrome/browser/browser_process_impl.h
|
|
@@ -184,6 +184,7 @@ class BrowserProcessImpl : public BrowserProcess,
|
|
#endif
|
|
|
|
component_updater::ComponentUpdateService* component_updater() override;
|
|
+ adblock_updater::AdBlockUpdaterService* adblock_updater() override;
|
|
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
|
component_updater::SupervisedUserWhitelistInstaller*
|
|
supervised_user_whitelist_installer() override;
|
|
@@ -371,6 +372,8 @@ class BrowserProcessImpl : public BrowserProcess,
|
|
// but some users of component updater only install per-user.
|
|
std::unique_ptr<component_updater::ComponentUpdateService> component_updater_;
|
|
|
|
+ std::unique_ptr<adblock_updater::AdBlockUpdaterService> adblock_updater_;
|
|
+
|
|
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
|
std::unique_ptr<component_updater::SupervisedUserWhitelistInstaller>
|
|
supervised_user_whitelist_installer_;
|
|
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
|
|
--- a/chrome/browser/chrome_browser_main.cc
|
|
+++ b/chrome/browser/chrome_browser_main.cc
|
|
@@ -1588,6 +1588,8 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
|
if (!parsed_command_line().HasSwitch(switches::kDisableComponentUpdate)) {
|
|
component_updater::RegisterComponentsForUpdate(profile_->IsOffTheRecord(),
|
|
profile_->GetPrefs());
|
|
+ // force initialisation
|
|
+ g_browser_process->adblock_updater();
|
|
}
|
|
|
|
variations::VariationsService* variations_service =
|
|
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
|
|
--- a/chrome/browser/chrome_content_browser_client.cc
|
|
+++ b/chrome/browser/chrome_content_browser_client.cc
|
|
@@ -67,7 +67,6 @@
|
|
#include "chrome/browser/hid/chrome_hid_delegate.h"
|
|
#include "chrome/browser/interstitials/enterprise_util.h"
|
|
#include "chrome/browser/lifetime/browser_shutdown.h"
|
|
-#include "chrome/browser/lookalikes/lookalike_url_navigation_throttle.h"
|
|
#include "chrome/browser/media/audio_service_util.h"
|
|
#include "chrome/browser/media/router/media_router_feature.h"
|
|
#include "chrome/browser/media/webrtc/audio_debug_recordings_handler.h"
|
|
@@ -219,7 +218,6 @@
|
|
#include "components/metrics/client_info.h"
|
|
#include "components/metrics_services_manager/metrics_services_manager.h"
|
|
#include "components/net_log/chrome_net_log.h"
|
|
-#include "components/page_load_metrics/browser/metrics_navigation_throttle.h"
|
|
#include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
|
|
#include "components/payments/content/payment_request_display_manager.h"
|
|
#include "components/performance_manager/embedder/performance_manager_registry.h"
|
|
@@ -3925,16 +3923,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
|
content::NavigationHandle* handle) {
|
|
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
|
|
|
- // MetricsNavigationThrottle requires that it runs before NavigationThrottles
|
|
- // that may delay or cancel navigations, so only NavigationThrottles that
|
|
- // don't delay or cancel navigations (e.g. throttles that are only observing
|
|
- // callbacks without affecting navigation behavior) should be added before
|
|
- // MetricsNavigationThrottle.
|
|
- if (handle->IsInMainFrame()) {
|
|
- throttles.push_back(
|
|
- page_load_metrics::MetricsNavigationThrottle::Create(handle));
|
|
- }
|
|
-
|
|
#if BUILDFLAG(ENABLE_PLUGINS)
|
|
MaybeAddThrottle(FlashDownloadInterception::MaybeCreateThrottleFor(handle),
|
|
&throttles);
|
|
@@ -4048,10 +4036,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
|
&throttles);
|
|
#endif
|
|
|
|
- MaybeAddThrottle(
|
|
- LookalikeUrlNavigationThrottle::MaybeCreateNavigationThrottle(handle),
|
|
- &throttles);
|
|
-
|
|
MaybeAddThrottle(PDFIFrameNavigationThrottle::MaybeCreateThrottleFor(handle),
|
|
&throttles);
|
|
|
|
diff --git a/chrome/browser/sessions/session_restore_android.cc b/chrome/browser/sessions/session_restore_android.cc
|
|
--- a/chrome/browser/sessions/session_restore_android.cc
|
|
+++ b/chrome/browser/sessions/session_restore_android.cc
|
|
@@ -43,7 +43,9 @@ content::WebContents* SessionRestore::RestoreForeignSessionTab(
|
|
TabAndroid* current_tab = TabAndroid::FromWebContents(web_contents);
|
|
DCHECK(current_tab);
|
|
if (disposition == WindowOpenDisposition::CURRENT_TAB) {
|
|
- current_tab->SwapWebContents(std::move(new_web_contents), false, false);
|
|
+ int active_tab_index = tab_model->GetActiveIndex();
|
|
+ tab_model->CreateTab(current_tab, new_web_contents.release());
|
|
+ tab_model->CloseTabAt(active_tab_index);
|
|
} else {
|
|
DCHECK(disposition == WindowOpenDisposition::NEW_FOREGROUND_TAB ||
|
|
disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB);
|
|
diff --git a/components/component_updater/BUILD.gn b/components/component_updater/BUILD.gn
|
|
--- a/components/component_updater/BUILD.gn
|
|
+++ b/components/component_updater/BUILD.gn
|
|
@@ -10,6 +10,12 @@ static_library("component_updater") {
|
|
"component_updater_command_line_config_policy.h",
|
|
"component_updater_paths.cc",
|
|
"component_updater_paths.h",
|
|
+
|
|
+ "adblock_updater_service.cc",
|
|
+ "adblock_updater_service.h",
|
|
+ "download_filters_task.cc",
|
|
+ "download_filters_task.h",
|
|
+
|
|
"component_updater_service.cc",
|
|
"component_updater_service.h",
|
|
"component_updater_service_internal.h",
|
|
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc b/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc
|
|
--- a/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc
|
|
+++ b/components/subresource_filter/content/browser/content_subresource_filter_throttle_manager.cc
|
|
@@ -391,6 +391,17 @@ ContentSubresourceFilterThrottleManager::
|
|
throttle->NotifyPageActivationWithRuleset(EnsureRulesetHandle(),
|
|
ad_tagging_state);
|
|
}
|
|
+
|
|
+ //TODO: could use same logic as in SubresourceFilterSafeBrowsingActivationThrottle::NotifyResult()
|
|
+ {
|
|
+ subresource_filter::ActivationDecision ignored_decision;
|
|
+ mojom::ActivationState ad_filtering_state;
|
|
+ ad_filtering_state.activation_level = client_->OnPageActivationComputed(
|
|
+ navigation_handle, mojom::ActivationLevel::kEnabled, &ignored_decision);
|
|
+ throttle->NotifyPageActivationWithRuleset(EnsureRulesetHandle(),
|
|
+ ad_filtering_state);
|
|
+ }
|
|
+
|
|
return throttle;
|
|
}
|
|
|
|
diff --git a/components/subresource_filter/content/browser/ruleset_service.cc b/components/subresource_filter/content/browser/ruleset_service.cc
|
|
--- a/components/subresource_filter/content/browser/ruleset_service.cc
|
|
+++ b/components/subresource_filter/content/browser/ruleset_service.cc
|
|
@@ -46,9 +46,7 @@ namespace {
|
|
|
|
void RecordIndexAndWriteRulesetResult(
|
|
RulesetService::IndexAndWriteRulesetResult result) {
|
|
- UMA_HISTOGRAM_ENUMERATION(
|
|
- "SubresourceFilter.WriteRuleset.Result", static_cast<int>(result),
|
|
- static_cast<int>(RulesetService::IndexAndWriteRulesetResult::MAX));
|
|
+ VLOG(1) << "SubresourceFilter.WriteRuleset.Result: " << static_cast<int>(result);
|
|
}
|
|
|
|
// Implements operations on a `sentinel file`, which is used as a safeguard to
|
|
@@ -227,10 +225,13 @@ RulesetService::RulesetService(
|
|
RulesetService::~RulesetService() {}
|
|
|
|
void RulesetService::IndexAndStoreAndPublishRulesetIfNeeded(
|
|
- const UnindexedRulesetInfo& unindexed_ruleset_info) {
|
|
- if (unindexed_ruleset_info.content_version.empty())
|
|
+ const UnindexedRulesetInfo& unindexed_ruleset_info, bool ignore_recent_version) {
|
|
+ if (unindexed_ruleset_info.content_version.empty()) {
|
|
+ LOG(INFO) << "RulesetService: ignoring update with empty version.";
|
|
return;
|
|
+ }
|
|
|
|
+ if (!ignore_recent_version) {
|
|
// Trying to store a ruleset with the same version for a second time would
|
|
// not only be futile, but would fail on Windows due to "File System
|
|
// Tunneling" as long as the previously stored copy of the rules is still
|
|
@@ -240,13 +241,16 @@ void RulesetService::IndexAndStoreAndPublishRulesetIfNeeded(
|
|
if (most_recently_indexed_version.IsCurrentFormatVersion() &&
|
|
most_recently_indexed_version.content_version ==
|
|
unindexed_ruleset_info.content_version) {
|
|
+ LOG(INFO) << "RulesetService: ignoring update with equal or older version.";
|
|
return;
|
|
}
|
|
+ }
|
|
|
|
// Before initialization, retain information about the most recently supplied
|
|
// unindexed ruleset, to be processed during initialization.
|
|
if (!is_initialized_) {
|
|
queued_unindexed_ruleset_info_ = unindexed_ruleset_info;
|
|
+ LOG(INFO) << "RulesetService: ignoring update while not initialized.";
|
|
return;
|
|
}
|
|
|
|
@@ -265,6 +269,18 @@ IndexedRulesetVersion RulesetService::GetMostRecentlyIndexedVersion() const {
|
|
IndexedRulesetVersion RulesetService::IndexAndWriteRuleset(
|
|
const base::FilePath& indexed_ruleset_base_dir,
|
|
const UnindexedRulesetInfo& unindexed_ruleset_info) {
|
|
+ IndexedRulesetVersion version = IndexAndWriteRulesetInternal(indexed_ruleset_base_dir, unindexed_ruleset_info);
|
|
+ // cleanup temporary file when done
|
|
+ if (unindexed_ruleset_info.delete_ruleset_path) {
|
|
+ base::DeleteFile(unindexed_ruleset_info.ruleset_path);
|
|
+ }
|
|
+ return version;
|
|
+}
|
|
+
|
|
+// static
|
|
+IndexedRulesetVersion RulesetService::IndexAndWriteRulesetInternal(
|
|
+ const base::FilePath& indexed_ruleset_base_dir,
|
|
+ const UnindexedRulesetInfo& unindexed_ruleset_info) {
|
|
base::ScopedBlockingCall scoped_blocking_call(FROM_HERE,
|
|
base::BlockingType::MAY_BLOCK);
|
|
|
|
@@ -272,6 +288,7 @@ IndexedRulesetVersion RulesetService::IndexAndWriteRuleset(
|
|
unindexed_ruleset_info.ruleset_path,
|
|
base::File::FLAG_OPEN | base::File::FLAG_READ);
|
|
if (!unindexed_ruleset_file.IsValid()) {
|
|
+ LOG(WARNING) << "RulesetService: failed to open: " << unindexed_ruleset_info.ruleset_path;
|
|
RecordIndexAndWriteRulesetResult(
|
|
IndexAndWriteRulesetResult::FAILED_OPENING_UNINDEXED_RULESET);
|
|
return IndexedRulesetVersion();
|
|
@@ -285,6 +302,7 @@ IndexedRulesetVersion RulesetService::IndexAndWriteRuleset(
|
|
indexed_ruleset_base_dir, indexed_version);
|
|
|
|
if (!base::CreateDirectory(indexed_ruleset_version_dir)) {
|
|
+ LOG(WARNING) << "RulesetService: failed to create version dir: " << indexed_ruleset_version_dir;
|
|
RecordIndexAndWriteRulesetResult(
|
|
IndexAndWriteRulesetResult::FAILED_CREATING_VERSION_DIR);
|
|
return IndexedRulesetVersion();
|
|
@@ -310,6 +328,7 @@ IndexedRulesetVersion RulesetService::IndexAndWriteRuleset(
|
|
|
|
RulesetIndexer indexer;
|
|
if (!(*g_index_ruleset_func)(std::move(unindexed_ruleset_file), &indexer)) {
|
|
+ LOG(WARNING) << "RulesetService: failed parsing.";
|
|
RecordIndexAndWriteRulesetResult(
|
|
IndexAndWriteRulesetResult::FAILED_PARSING_UNINDEXED_RULESET);
|
|
return IndexedRulesetVersion();
|
|
@@ -330,6 +349,8 @@ IndexedRulesetVersion RulesetService::IndexAndWriteRuleset(
|
|
if (result != IndexAndWriteRulesetResult::SUCCESS)
|
|
return IndexedRulesetVersion();
|
|
|
|
+ LOG(INFO) << "RulesetService: successful parsing.";
|
|
+
|
|
DCHECK(indexed_version.IsValid());
|
|
return indexed_version;
|
|
}
|
|
@@ -454,6 +475,7 @@ void RulesetService::IndexAndStoreRuleset(
|
|
void RulesetService::OnWrittenRuleset(WriteRulesetCallback result_callback,
|
|
const IndexedRulesetVersion& version) {
|
|
DCHECK(!result_callback.is_null());
|
|
+ LOG(INFO) << "RulesetService: valid version: " << version.IsValid();
|
|
if (!version.IsValid())
|
|
return;
|
|
version.SaveToPrefs(local_state_);
|
|
@@ -466,7 +488,6 @@ void RulesetService::OpenAndPublishRuleset(
|
|
IndexedRulesetLocator::GetRulesetDataFilePath(
|
|
IndexedRulesetLocator::GetSubdirectoryPathForVersion(
|
|
indexed_ruleset_base_dir_, version));
|
|
-
|
|
publisher_->TryOpenAndSetRulesetFile(
|
|
file_path, version.checksum,
|
|
base::BindOnce(&RulesetService::OnRulesetSet, AsWeakPtr()));
|
|
diff --git a/components/subresource_filter/content/browser/ruleset_service.h b/components/subresource_filter/content/browser/ruleset_service.h
|
|
--- a/components/subresource_filter/content/browser/ruleset_service.h
|
|
+++ b/components/subresource_filter/content/browser/ruleset_service.h
|
|
@@ -181,7 +181,7 @@ class RulesetService : public base::SupportsWeakPtr<RulesetService> {
|
|
//
|
|
// Virtual so that it can be mocked out in tests.
|
|
virtual void IndexAndStoreAndPublishRulesetIfNeeded(
|
|
- const UnindexedRulesetInfo& unindexed_ruleset_info);
|
|
+ const UnindexedRulesetInfo& unindexed_ruleset_info, bool ignore_recent_version = false);
|
|
|
|
// Get the ruleset version associated with the current local_state_.
|
|
IndexedRulesetVersion GetMostRecentlyIndexedVersion() const;
|
|
@@ -214,6 +214,11 @@ class RulesetService : public base::SupportsWeakPtr<RulesetService> {
|
|
const base::FilePath& indexed_ruleset_base_dir,
|
|
const UnindexedRulesetInfo& unindexed_ruleset_info);
|
|
|
|
+ // internal function used to wrap the temporary file deletion for unindexed rulesets
|
|
+ static IndexedRulesetVersion IndexAndWriteRulesetInternal(
|
|
+ const base::FilePath& indexed_ruleset_base_dir,
|
|
+ const UnindexedRulesetInfo& unindexed_ruleset_info);
|
|
+
|
|
// Reads the rules from the |unindexed_ruleset_file|, and indexes them using
|
|
// |indexer|. Returns whether the entire ruleset could be parsed.
|
|
static bool IndexRuleset(base::File unindexed_ruleset_file,
|
|
diff --git a/components/subresource_filter/content/browser/ruleset_version.cc b/components/subresource_filter/content/browser/ruleset_version.cc
|
|
--- a/components/subresource_filter/content/browser/ruleset_version.cc
|
|
+++ b/components/subresource_filter/content/browser/ruleset_version.cc
|
|
@@ -25,6 +25,7 @@ const char kSubresourceFilterRulesetChecksum[] =
|
|
} // namespace
|
|
|
|
UnindexedRulesetInfo::UnindexedRulesetInfo() = default;
|
|
+UnindexedRulesetInfo::UnindexedRulesetInfo(const UnindexedRulesetInfo& other) = default;
|
|
UnindexedRulesetInfo::~UnindexedRulesetInfo() = default;
|
|
|
|
IndexedRulesetVersion::IndexedRulesetVersion() = default;
|
|
diff --git a/components/subresource_filter/content/browser/ruleset_version.h b/components/subresource_filter/content/browser/ruleset_version.h
|
|
--- a/components/subresource_filter/content/browser/ruleset_version.h
|
|
+++ b/components/subresource_filter/content/browser/ruleset_version.h
|
|
@@ -25,6 +25,7 @@ namespace subresource_filter {
|
|
// filtering rules on disk.
|
|
struct UnindexedRulesetInfo {
|
|
UnindexedRulesetInfo();
|
|
+ UnindexedRulesetInfo(const UnindexedRulesetInfo& other);
|
|
~UnindexedRulesetInfo();
|
|
|
|
// The version of the ruleset contents. Because the wire format of unindexed
|
|
@@ -43,6 +44,10 @@ struct UnindexedRulesetInfo {
|
|
// can be indicated not only by setting |license_path| to empty, but also by
|
|
// setting it to any non existent path.
|
|
base::FilePath license_path;
|
|
+
|
|
+ // Whether to delete or not the ruleset path once done indexing; useful for disposal
|
|
+ // of temporary files.
|
|
+ bool delete_ruleset_path;
|
|
};
|
|
|
|
// Encapsulates the combination of the binary format version of the indexed
|
|
diff --git a/components/subresource_filter/content/browser/verified_ruleset_dealer.cc b/components/subresource_filter/content/browser/verified_ruleset_dealer.cc
|
|
--- a/components/subresource_filter/content/browser/verified_ruleset_dealer.cc
|
|
+++ b/components/subresource_filter/content/browser/verified_ruleset_dealer.cc
|
|
@@ -11,6 +11,7 @@
|
|
#include "base/check.h"
|
|
#include "base/files/file.h"
|
|
#include "base/location.h"
|
|
+#include "base/logging.h"
|
|
#include "base/metrics/histogram_macros.h"
|
|
#include "base/notreached.h"
|
|
#include "base/task_runner_util.h"
|
|
@@ -36,6 +37,8 @@ base::File VerifiedRulesetDealer::OpenAndSetRulesetFile(
|
|
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("loading"),
|
|
"VerifiedRulesetDealer::OpenAndSetRulesetFile", "file_valid",
|
|
file.IsValid());
|
|
+
|
|
+ LOG(INFO) << "OpenAndSetRulesetFile: " << file_path << " is valid: " << file.IsValid();
|
|
if (file.IsValid()) {
|
|
SetRulesetFile(file.Duplicate());
|
|
expected_checksum_ = expected_checksum;
|
|
diff --git a/components/subresource_filter/core/browser/subresource_filter_features.cc b/components/subresource_filter/core/browser/subresource_filter_features.cc
|
|
--- a/components/subresource_filter/core/browser/subresource_filter_features.cc
|
|
+++ b/components/subresource_filter/core/browser/subresource_filter_features.cc
|
|
@@ -53,69 +53,7 @@ class CommaSeparatedStrings {
|
|
DISALLOW_COPY_AND_ASSIGN(CommaSeparatedStrings);
|
|
};
|
|
|
|
-std::string TakeVariationParamOrReturnEmpty(
|
|
- std::map<std::string, std::string>* params,
|
|
- const std::string& key) {
|
|
- auto it = params->find(key);
|
|
- if (it == params->end())
|
|
- return std::string();
|
|
- std::string value = std::move(it->second);
|
|
- params->erase(it);
|
|
- return value;
|
|
-}
|
|
-
|
|
-mojom::ActivationLevel ParseActivationLevel(
|
|
- const base::StringPiece activation_level) {
|
|
- if (base::LowerCaseEqualsASCII(activation_level, kActivationLevelEnabled))
|
|
- return mojom::ActivationLevel::kEnabled;
|
|
- else if (base::LowerCaseEqualsASCII(activation_level, kActivationLevelDryRun))
|
|
- return mojom::ActivationLevel::kDryRun;
|
|
- return mojom::ActivationLevel::kDisabled;
|
|
-}
|
|
-
|
|
-ActivationScope ParseActivationScope(const base::StringPiece activation_scope) {
|
|
- if (base::LowerCaseEqualsASCII(activation_scope, kActivationScopeAllSites))
|
|
- return ActivationScope::ALL_SITES;
|
|
- else if (base::LowerCaseEqualsASCII(activation_scope,
|
|
- kActivationScopeActivationList))
|
|
- return ActivationScope::ACTIVATION_LIST;
|
|
- return ActivationScope::NO_SITES;
|
|
-}
|
|
-
|
|
-ActivationList ParseActivationList(std::string activation_lists_string) {
|
|
- CommaSeparatedStrings activation_lists(std::move(activation_lists_string));
|
|
- if (activation_lists.CaseInsensitiveContains(
|
|
- kActivationListPhishingInterstitial)) {
|
|
- return ActivationList::PHISHING_INTERSTITIAL;
|
|
- } else if (activation_lists.CaseInsensitiveContains(
|
|
- kActivationListSocialEngineeringAdsInterstitial)) {
|
|
- return ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL;
|
|
- } else if (activation_lists.CaseInsensitiveContains(
|
|
- kActivationListSubresourceFilter)) {
|
|
- return ActivationList::SUBRESOURCE_FILTER;
|
|
- } else if (activation_lists.CaseInsensitiveContains(
|
|
- kActivationListBetterAds)) {
|
|
- return ActivationList::BETTER_ADS;
|
|
- }
|
|
- return ActivationList::NONE;
|
|
-}
|
|
-
|
|
-// Will return a value between 0 and 1 inclusive.
|
|
-double ParsePerformanceMeasurementRate(const std::string& rate) {
|
|
- double value = 0.0;
|
|
- if (!base::StringToDouble(rate, &value) || value < 0)
|
|
- return 0.0;
|
|
- return value < 1 ? value : 1;
|
|
-}
|
|
-
|
|
-int ParseInt(const base::StringPiece value) {
|
|
- int result = 0;
|
|
- base::StringToInt(value, &result);
|
|
- return result;
|
|
-}
|
|
-
|
|
-std::vector<Configuration> FillEnabledPresetConfigurations(
|
|
- std::map<std::string, std::string>* params) {
|
|
+std::vector<Configuration> FillEnabledPresetConfigurations() {
|
|
// If ad tagging is enabled, turn on the dryrun automatically.
|
|
bool ad_tagging_enabled = base::FeatureList::IsEnabled(kAdTagging);
|
|
const struct {
|
|
@@ -123,23 +61,16 @@ std::vector<Configuration> FillEnabledPresetConfigurations(
|
|
bool enabled_by_default;
|
|
Configuration (*factory_method)();
|
|
} kAvailablePresetConfigurations[] = {
|
|
- {kPresetLiveRunOnPhishingSites, true,
|
|
+ {kPresetLiveRunOnPhishingSites, false,
|
|
&Configuration::MakePresetForLiveRunOnPhishingSites},
|
|
{kPresetPerformanceTestingDryRunOnAllSites, ad_tagging_enabled,
|
|
&Configuration::MakePresetForPerformanceTestingDryRunOnAllSites},
|
|
{kPresetLiveRunForBetterAds, true,
|
|
&Configuration::MakePresetForLiveRunForBetterAds}};
|
|
|
|
- CommaSeparatedStrings enabled_presets(
|
|
- TakeVariationParamOrReturnEmpty(params, kEnablePresetsParameterName));
|
|
- CommaSeparatedStrings disabled_presets(
|
|
- TakeVariationParamOrReturnEmpty(params, kDisablePresetsParameterName));
|
|
-
|
|
std::vector<Configuration> enabled_configurations;
|
|
for (const auto& available_preset : kAvailablePresetConfigurations) {
|
|
- if ((enabled_presets.CaseInsensitiveContains(available_preset.name) ||
|
|
- available_preset.enabled_by_default) &&
|
|
- !disabled_presets.CaseInsensitiveContains(available_preset.name)) {
|
|
+ if (available_preset.enabled_by_default) {
|
|
enabled_configurations.push_back(available_preset.factory_method());
|
|
}
|
|
}
|
|
@@ -147,46 +78,10 @@ std::vector<Configuration> FillEnabledPresetConfigurations(
|
|
return enabled_configurations;
|
|
}
|
|
|
|
-Configuration ParseExperimentalConfiguration(
|
|
- std::map<std::string, std::string>* params) {
|
|
- Configuration configuration;
|
|
-
|
|
- // ActivationConditions:
|
|
- configuration.activation_conditions.activation_scope = ParseActivationScope(
|
|
- TakeVariationParamOrReturnEmpty(params, kActivationScopeParameterName));
|
|
-
|
|
- configuration.activation_conditions.activation_list = ParseActivationList(
|
|
- TakeVariationParamOrReturnEmpty(params, kActivationListsParameterName));
|
|
-
|
|
- configuration.activation_conditions.priority =
|
|
- ParseInt(TakeVariationParamOrReturnEmpty(
|
|
- params, kActivationPriorityParameterName));
|
|
-
|
|
- // ActivationOptions:
|
|
- configuration.activation_options.activation_level = ParseActivationLevel(
|
|
- TakeVariationParamOrReturnEmpty(params, kActivationLevelParameterName));
|
|
-
|
|
- configuration.activation_options.performance_measurement_rate =
|
|
- ParsePerformanceMeasurementRate(TakeVariationParamOrReturnEmpty(
|
|
- params, kPerformanceMeasurementRateParameterName));
|
|
-
|
|
- // GeneralSettings:
|
|
- configuration.general_settings.ruleset_flavor =
|
|
- TakeVariationParamOrReturnEmpty(params, kRulesetFlavorParameterName);
|
|
-
|
|
- return configuration;
|
|
-}
|
|
-
|
|
std::vector<Configuration> ParseEnabledConfigurations() {
|
|
- std::map<std::string, std::string> params;
|
|
- base::GetFieldTrialParamsByFeature(kSafeBrowsingSubresourceFilter, ¶ms);
|
|
-
|
|
std::vector<Configuration> configs;
|
|
if (base::FeatureList::IsEnabled(kSafeBrowsingSubresourceFilter))
|
|
- configs = FillEnabledPresetConfigurations(¶ms);
|
|
-
|
|
- Configuration experimental_config = ParseExperimentalConfiguration(¶ms);
|
|
- configs.push_back(std::move(experimental_config));
|
|
+ configs = FillEnabledPresetConfigurations();
|
|
|
|
return configs;
|
|
}
|
|
diff --git a/components/subresource_filter/core/common/common_features.cc b/components/subresource_filter/core/common/common_features.cc
|
|
--- a/components/subresource_filter/core/common/common_features.cc
|
|
+++ b/components/subresource_filter/core/common/common_features.cc
|
|
@@ -6,6 +6,6 @@
|
|
|
|
namespace subresource_filter {
|
|
|
|
-const base::Feature kAdTagging{"AdTagging", base::FEATURE_ENABLED_BY_DEFAULT};
|
|
+const base::Feature kAdTagging{"AdTagging", base::FEATURE_DISABLED_BY_DEFAULT};
|
|
|
|
} // namespace subresource_filter
|
|
diff --git a/content/browser/renderer_host/navigation_throttle_runner.cc b/content/browser/renderer_host/navigation_throttle_runner.cc
|
|
--- a/content/browser/renderer_host/navigation_throttle_runner.cc
|
|
+++ b/content/browser/renderer_host/navigation_throttle_runner.cc
|
|
@@ -124,11 +124,6 @@ void NavigationThrottleRunner::RegisterNavigationThrottles() {
|
|
devtools_instrumentation::CreateNavigationThrottles(request)) {
|
|
AddThrottle(std::move(throttle));
|
|
}
|
|
-
|
|
- // Insert all testing NavigationThrottles last.
|
|
- throttles_.insert(throttles_.end(),
|
|
- std::make_move_iterator(testing_throttles.begin()),
|
|
- std::make_move_iterator(testing_throttles.end()));
|
|
}
|
|
|
|
NavigationThrottle* NavigationThrottleRunner::GetDeferringThrottle() const {
|
|
--
|
|
2.17.1
|
|
|