Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant obsolete brave/tracking-protection #2971

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use_relative_paths = True

deps = {
"vendor/adblock_rust_ffi": "https://github.com/brave/adblock-rust-ffi.git@0e980ee0a63d837f3ecad666fabe1f50311baa81",
"vendor/autoplay-whitelist": "https://github.com/brave/autoplay-whitelist.git@f39d83788cd12b883bfe6561cc7166b176ab9d9d",
"vendor/extension-whitelist": "https://github.com/brave/extension-whitelist.git@aa74a1bc29ced176e50db9f54946f28d82dfc795",
"vendor/tracking-protection": "https://github.com/brave/tracking-protection.git@3de744d4698b2f8fac1f52579d39f9ad154d1ec2",
"vendor/hashset-cpp": "https://github.com/brave/hashset-cpp.git@4b55fe39bb25bb0d8b11a43d547d75f00c6c46fb",
"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",
"vendor/bloom-filter-cpp": "https://github.com/brave/bloom-filter-cpp.git@9be5c63b14e094156e00c8b28f205e7794f0b92c",
"vendor/requests": "https://github.com/kennethreitz/requests@e4d59bedfd3c7f4f254f4f5d036587bcd8152458",
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
Expand Down
11 changes: 0 additions & 11 deletions browser/net/brave_ad_block_tp_network_delegate_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "brave/components/brave_shields/browser/ad_block_service.h"
#include "brave/components/brave_shields/browser/brave_shields_util.h"
#include "brave/components/brave_shields/browser/brave_shields_web_contents_observer.h"
#include "brave/components/brave_shields/browser/tracking_protection_service.h"
#include "brave/components/brave_shields/common/brave_shield_constants.h"
#include "brave/grit/brave_generated_resources.h"
#include "content/public/browser/browser_thread.h"
Expand Down Expand Up @@ -133,22 +132,12 @@ void OnBeforeURLRequestAdBlockTP(
tab_host, &did_match_exception,
&ctx->cancel_request_explicitly)) {
ctx->blocked_by = kAdBlocked;
} else if (!did_match_exception &&
!g_brave_browser_process->tracking_protection_service()
->ShouldStartRequest(ctx->request_url, ctx->resource_type,
tab_host, &did_match_exception,
&ctx->cancel_request_explicitly)) {
ctx->blocked_by = kTrackerBlocked;
}

if (ctx->blocked_by == kAdBlocked) {
brave_shields::DispatchBlockedEventFromIO(ctx->request_url,
ctx->render_frame_id, ctx->render_process_id, ctx->frame_tree_node_id,
brave_shields::kAds);
} else if (ctx->blocked_by == kTrackerBlocked) {
brave_shields::DispatchBlockedEventFromIO(ctx->request_url,
ctx->render_frame_id, ctx->render_process_id, ctx->frame_tree_node_id,
brave_shields::kTrackers);
}
}

Expand Down
3 changes: 1 addition & 2 deletions browser/net/brave_network_delegate_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,7 @@ void BraveNetworkDelegateBase::RunNextCallback(
IsRequestIdentifierValid(ctx->request_identifier)) {
*ctx->new_url = GURL(ctx->new_url_spec);
}
if (ctx->blocked_by == brave::kAdBlocked ||
ctx->blocked_by == brave::kTrackerBlocked) {
if (ctx->blocked_by == brave::kAdBlocked) {
// We are going to intercept this request and block it later in the
// network stack.
if (ctx->cancel_request_explicitly) {
Expand Down
1 change: 0 additions & 1 deletion browser/net/url_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ enum BraveNetworkDelegateEventType {
enum BlockedBy {
kNotBlocked ,
kAdBlocked,
kTrackerBlocked,
kOtherBlocked
};

Expand Down
3 changes: 2 additions & 1 deletion browser/ui/webui/brave_adblock_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ void BraveAdblockUI::CustomizeWebUIProperties(
PrefService* prefs = profile->GetPrefs();
if (render_view_host) {
render_view_host->SetWebUIProperty(
"adsBlockedStat", std::to_string(prefs->GetUint64(kAdsBlocked)));
"adsBlockedStat", std::to_string(prefs->GetUint64(kAdsBlocked) +
prefs->GetUint64(kTrackersBlocked)));
}
}

Expand Down
3 changes: 0 additions & 3 deletions browser/ui/webui/brave_new_tab_message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ void BraveNewTabMessageHandler::OnJavascriptAllowed() {
pref_change_registrar_.Add(kAdsBlocked,
base::Bind(&BraveNewTabMessageHandler::OnStatsChanged,
base::Unretained(this)));
pref_change_registrar_.Add(kTrackersBlocked,
base::Bind(&BraveNewTabMessageHandler::OnStatsChanged,
base::Unretained(this)));
pref_change_registrar_.Add(kHttpsUpgrades,
base::Bind(&BraveNewTabMessageHandler::OnStatsChanged,
base::Unretained(this)));
Expand Down
6 changes: 2 additions & 4 deletions browser/ui/webui/brave_new_tab_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ void BraveNewTabUI::SetStatsWebUIProperties(
if (render_view_host) {
render_view_host->SetWebUIProperty(
"adsBlockedStat",
std::to_string(prefs->GetUint64(kAdsBlocked)));
render_view_host->SetWebUIProperty(
"trackersBlockedStat",
std::to_string(prefs->GetUint64(kTrackersBlocked)));
std::to_string(prefs->GetUint64(kAdsBlocked) +
prefs->GetUint64(kTrackersBlocked)));
render_view_host->SetWebUIProperty(
"javascriptBlockedStat",
std::to_string(prefs->GetUint64(kJavascriptBlocked)));
Expand Down
2 changes: 2 additions & 0 deletions common/pref_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "brave/common/pref_names.h"

const char kAdsBlocked[] = "brave.stats.ads_blocked";
// We no longer update this pref, but we keep it around for now because it's
// added to kAdsBlocked when being displayed.
const char kTrackersBlocked[] = "brave.stats.trackers_blocked";
const char kJavascriptBlocked[] = "brave.stats.javascript_blocked";
const char kHttpsUpgrades[] = "brave.stats.https_upgrades";
Expand Down
8 changes: 2 additions & 6 deletions components/brave_new_tab_ui/containers/newTab/stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class Stats extends React.Component<Props, {}> {
return 50
}

get trackedBlockersCount () {
return this.props.stats.trackersBlockedStat || 0
}

get adblockCount () {
return this.props.stats.adsBlockedStat || 0
}
Expand All @@ -30,7 +26,7 @@ class Stats extends React.Component<Props, {}> {
}

get estimatedTimeSaved () {
const estimatedMillisecondsSaved = (this.adblockCount + this.trackedBlockersCount) * this.millisecondsPerItem || 0
const estimatedMillisecondsSaved = this.adblockCount * this.millisecondsPerItem || 0
const hours = estimatedMillisecondsSaved < 1000 * 60 * 60 * 24
const minutes = estimatedMillisecondsSaved < 1000 * 60 * 60
const seconds = estimatedMillisecondsSaved < 1000 * 60
Expand Down Expand Up @@ -62,7 +58,7 @@ class Stats extends React.Component<Props, {}> {
}

render () {
const trackedBlockersCount = (this.trackedBlockersCount + this.adblockCount).toLocaleString()
const trackedBlockersCount = this.adblockCount.toLocaleString()
const httpsUpgradedCount = this.httpsUpgradedCount.toLocaleString()
const timeSaved = this.estimatedTimeSaved

Expand Down
3 changes: 1 addition & 2 deletions components/brave_new_tab_ui/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const defaultState: NewTab.State = {
bookmarks: {},
stats: {
adsBlockedStat: 0,
trackersBlockedStat: 0,
javascriptBlockedStat: 0,
httpsUpgradesStat: 0,
fingerprintingBlockedStat: 0
Expand All @@ -37,7 +36,7 @@ const defaultState: NewTab.State = {
export const getLoadTimeData = (state: NewTab.State) => {
state = { ...state }
state.stats = defaultState.stats
;['adsBlockedStat', 'trackersBlockedStat', 'javascriptBlockedStat',
;['adsBlockedStat', 'javascriptBlockedStat',
'httpsUpgradesStat', 'fingerprintingBlockedStat'].forEach((stat) => {
state.stats[stat] = parseInt(chrome.getVariableValue(stat), 10) || 0
})
Expand Down
1 change: 0 additions & 1 deletion components/brave_shields/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ source_set("browser") {
"//brave/components/content_settings/core/browser",
"//brave/content:common",
"//brave/vendor/adblock_rust_ffi:adblock_ffi",
"//brave/vendor/tracking-protection/brave:tracking-protection",
"//brave/vendor/autoplay-whitelist/brave:autoplay-whitelist",
"//chrome/common",
"//components/prefs",
Expand Down
54 changes: 0 additions & 54 deletions components/brave_shields/browser/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -547,60 +547,6 @@ IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kAdsBlocked), 0ULL);
}

// Load a page that references a tracker from an untrusted domain, but
// has no specific exception rule in ad-block.
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
TrackerReferencedFromUntrustedDomain) {
SetDefaultComponentIdAndBase64PublicKeyForTest(
kDefaultAdBlockComponentTestId,
kDefaultAdBlockComponentTestBase64PublicKey);
InitTrackingProtectionService();
ASSERT_TRUE(InstallTrackingProtectionExtension());
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kTrackersBlocked),
0ULL);
GURL url = embedded_test_server()->GetURL("google.com", kAdBlockTestPage);
ui_test_utils::NavigateToURL(browser(), url);
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
GURL test_url = embedded_test_server()->GetURL("365dm.com", "/logo.png");
bool as_expected = false;
ASSERT_TRUE(ExecuteScriptAndExtractBool(contents,
base::StringPrintf(
"setExpectations(0, 1, 0, 0, 0, 0);"
"addImage('%s')",
test_url.spec().c_str()),
&as_expected));
EXPECT_TRUE(as_expected);
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kTrackersBlocked),
1ULL);
}

// Load a page that references a tracker from an untrusted domain, but
// has a specific exception rule in ad-block.
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest,
TrackerReferencedFromUntrustedDomainWithException) {
InitTrackingProtectionService();
UpdateAdBlockInstanceWithRules("||365dm.com\n@@logo.png");
ASSERT_TRUE(InstallTrackingProtectionExtension());
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kTrackersBlocked),
0ULL);
GURL url = embedded_test_server()->GetURL("google.com", kAdBlockTestPage);
ui_test_utils::NavigateToURL(browser(), url);
content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents();
GURL test_url = embedded_test_server()->GetURL("365dm.com", "/logo.png");
bool as_expected = false;
ASSERT_TRUE(ExecuteScriptAndExtractBool(contents,
base::StringPrintf(
"setExpectations(1, 0, 0, 0, 0, 0);"
"addImage('%s')",
test_url.spec().c_str()),
&as_expected));
EXPECT_TRUE(as_expected);
EXPECT_EQ(browser()->profile()->GetPrefs()->GetUint64(kTrackersBlocked),
0ULL);
}

// Make sure the third-party flag is passed into the ad-block library properly
IN_PROC_BROWSER_TEST_F(AdBlockServiceTest, AdBlockThirdPartyWorksByETLDP1) {
UpdateAdBlockInstanceWithRules("||a.com$third-party");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ void BraveShieldsWebContentsObserver::DispatchBlockedEvent(

if (block_type == kAds) {
prefs->SetUint64(kAdsBlocked, prefs->GetUint64(kAdsBlocked) + 1);
} else if (block_type == kTrackers) {
prefs->SetUint64(kTrackersBlocked,
prefs->GetUint64(kTrackersBlocked) + 1);
} else if (block_type == kHTTPUpgradableResources) {
prefs->SetUint64(kHttpsUpgrades, prefs->GetUint64(kHttpsUpgrades) + 1);
} else if (block_type == kJavaScript) {
Expand Down
Loading