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

Add social blocking options #1818

Merged
merged 13 commits into from Mar 15, 2019
Merged

Add social blocking options #1818

merged 13 commits into from Mar 15, 2019

Conversation

@bbondy
Copy link
Member

bbondy commented Mar 1, 2019

Fix brave/brave-browser#3489
Fix brave/brave-browser#3534

Related PRs:
brave/adblock-lists#54
brave/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:
Screen Shot 2019-03-10 at 11 11 09 PM

Test plan is in the issue.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Verified that these changes build without errors on
    • Windows
    • macOS
    • Linux
  • Verified that these changes pass automated tests (npm test brave_unit_tests && npm test brave_browser_tests) on
    • Windows
    • macOS
    • Linux
  • Verified that all lint errors/warnings are resolved (npm run lint)
  • Ran git rebase master (if needed).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed.
  • Add appropriate QA labels (QA/Yes or QA/No) to include the closed issue in milestone

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source
@bbondy bbondy self-assigned this Mar 1, 2019
@bbondy bbondy force-pushed the social-blocking-options branch 10 times, most recently from 3c25dd3 to e4bc0dc Mar 4, 2019
@bbondy bbondy force-pushed the social-blocking-options branch 5 times, most recently from aa7de48 to b175246 Mar 11, 2019
@@ -163,7 +183,6 @@ void AdBlockBaseService::OnDATFileDataReady() {
LOG(ERROR) << "Could not obtain ad block data";
return;
}
ad_block_client_.reset(new AdBlockClient());

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 11, 2019

Author Member

This would remove the already added tags on the instance. Deserialize should already be resetting all members to a valid state.

@bbondy bbondy force-pushed the social-blocking-options branch from b175246 to 1906125 Mar 11, 2019
@bbondy bbondy changed the title WIP: Add social blocking options Add social blocking options Mar 11, 2019
@bbondy bbondy force-pushed the social-blocking-options branch 2 times, most recently from c5a9534 to e6a4f5c Mar 12, 2019
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",

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

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();
}

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

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()) &&

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

ShouldBlockCookie will need a refactor but not in the scope of this issue.

This comment has been minimized.

Copy link
@pilgrim-brave

pilgrim-brave Mar 12, 2019

Contributor

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);

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

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(

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

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"

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

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)]]"

This comment has been minimized.

Copy link
@bbondy

bbondy Mar 12, 2019

Author Member

Screenshot available in the issue and PR.

@bbondy bbondy force-pushed the social-blocking-options branch from 54e3222 to 853394b Mar 15, 2019
@bbondy bbondy merged commit 5938e5a into master Mar 15, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/jenkins/pr-head This commit cannot be built
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
bbondy added a commit that referenced this pull request Mar 15, 2019
Add social blocking options
@bbondy bbondy added this to the 0.64.x - Nightly milestone Mar 15, 2019
bbondy added a commit that referenced this pull request Mar 15, 2019
Add social blocking options
/**
* @implements {settings.SocialBlockingBrowserProxy}
*/
class DefaultBraveShieldsBrowserProxyImpl {

This comment has been minimized.

Copy link
@simonhong

simonhong Mar 18, 2019

Collaborator

This should be SocialBlockingBrowserProxyImpl?

class DefaultBraveShieldsBrowserProxyImpl {
}

cr.addSingletonGetter(DefaultBraveShieldsBrowserProxyImpl);

This comment has been minimized.

Copy link
@simonhong

simonhong Mar 18, 2019

Collaborator

ditto

@NejcZdovc NejcZdovc deleted the social-blocking-options branch Mar 18, 2019
@petemill petemill mentioned this pull request Mar 18, 2019
9 of 19 tasks complete
const std::string& pref_name) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
PrefService* user_prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
allow_google_auth_ = user_prefs->GetBoolean(kGoogleLoginControlType);

This comment has been minimized.

Copy link
@iefremov

iefremov Jul 21, 2019

Contributor

it is not thread-safe to write allow_google_auth_ on UI and later read on IO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.