-
Notifications
You must be signed in to change notification settings - Fork 918
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
Add social blocking options #1818
Conversation
3c25dd3
to
e4bc0dc
Compare
aa7de48
to
b175246
Compare
@@ -163,7 +183,6 @@ void AdBlockBaseService::OnDATFileDataReady() { | |||
LOG(ERROR) << "Could not obtain ad block data"; | |||
return; | |||
} | |||
ad_block_client_.reset(new AdBlockClient()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would remove the already added tags on the instance. Deserialize should already be resetting all members to a valid state.
b175246
to
1906125
Compare
c5a9534
to
e6a4f5c
Compare
DEPS
Outdated
@@ -1,7 +1,7 @@ | |||
use_relative_paths = True | |||
|
|||
deps = { | |||
"vendor/ad-block": "https://github.com/brave/ad-block.git@534c153a3e8d1c8eda02cc80297b9abf87e9a7da", | |||
"vendor/ad-block": "https://github.com/brave/ad-block.git@8ddfa911aeaf044741a9d5b66ddd84c9a3c352e7", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: This will need to be updated once I merge brave/ad-block
RegisterBooleanPref(kGoogleLoginControlType, true); | ||
builder.SetPrefService(std::move(prefs)); | ||
return builder.Build().release(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed otherwise a new unregistered pref error occurs only for 1 test in this file.
@@ -167,7 +168,8 @@ bool BraveContentBrowserClient::AllowAccessCookie( | |||
content_settings::BraveCookieSettings* cookie_settings = | |||
(content_settings::BraveCookieSettings*)io_data->GetCookieSettings(); | |||
bool allow = !ShouldBlockCookie(allow_brave_shields, allow_1p_cookies, | |||
allow_3p_cookies, first_party, url) && | |||
allow_3p_cookies, first_party, url, | |||
cookie_settings->GetAllowGoogleAuth()) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShouldBlockCookie
will need a refactor but not in the scope of this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on both counts
@@ -47,6 +47,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | |||
// Default Brave shields | |||
registry->RegisterBooleanPref(kHTTPSEVerywhereControlType, true); | |||
registry->RegisterBooleanPref(kNoScriptControlType, false); | |||
registry->RegisterBooleanPref(kGoogleLoginControlType, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only thing that actually changes default behaviour in the context of this ticket.
kTwitterEmbedControlType, | ||
base::Bind(&BraveNetworkDelegateBase::OnPreferenceChanged, | ||
base::Unretained(this), kTwitterEmbedControlType)); | ||
user_pref_change_registrar_->Add( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I first tried adding these observers inside of the ad block base class but it caused problems because of threading, it doesn't work from the main thread which prefs needed to.
#include "brave/components/brave_shields/common/brave_shield_constants.h" | ||
#include "brave/common/brave_cookie_blocking.h" | ||
#include "brave/common/pref_names.h" | ||
#include "components/prefs/pref_service.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components/prefs is already a dep
in this BUILD.gn
@@ -29,6 +30,13 @@ index 65d9633a7c0e4b0b44dd8a0ae2bb7598b3ee1b06..c6a6980abc74d80c8d3b8fa9104c6494 | |||
+ <settings-default-brave-shields-page prefs="{{prefs}}"></settings-default-brave-shields-page> | |||
+ </settings-section> | |||
+ </template> | |||
+ <template is="dom-if" if="[[showPage_(pageVisibility.socialBlocking)]]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screenshot available in the issue and PR.
9c65196
to
f80b28d
Compare
f80b28d
to
a0b44a6
Compare
54e3222
to
853394b
Compare
/** | ||
* @implements {settings.SocialBlockingBrowserProxy} | ||
*/ | ||
class DefaultBraveShieldsBrowserProxyImpl { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be SocialBlockingBrowserProxyImpl
?
class DefaultBraveShieldsBrowserProxyImpl { | ||
} | ||
|
||
cr.addSingletonGetter(DefaultBraveShieldsBrowserProxyImpl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
const std::string& pref_name) { | ||
DCHECK_CURRENTLY_ON(BrowserThread::UI); | ||
PrefService* user_prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); | ||
allow_google_auth_ = user_prefs->GetBoolean(kGoogleLoginControlType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not thread-safe to write allow_google_auth_
on UI and later read on IO
Fix brave/brave-browser#3489
Fix brave/brave-browser#3534
Related PRs:
brave/adblock-lists#54
brave-experiments/ad-block#192
The only default behaviour that this PR changes is that a cookie for Google login buttons is now allowed. It adds an option to be able to disable it though.
It also adds 3 options to be able to disable previously always-allowed things (Facebook, Twitter, LinkedIn embeds and login buttons).
It looks like this:

Test plan is in the issue.
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) onnpm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: