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 bbondy commented Mar 1, 2019

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:
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 Compare March 8, 2019 15:43
@bbondy bbondy force-pushed the social-blocking-options branch 5 times, most recently from aa7de48 to b175246 Compare March 11, 2019 03:01
@@ -163,7 +183,6 @@ void AdBlockBaseService::OnDATFileDataReady() {
LOG(ERROR) << "Could not obtain ad block data";
return;
}
ad_block_client_.reset(new AdBlockClient());
Copy link
Member Author

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.

@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 Compare March 12, 2019 03:41
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",
Copy link
Member Author

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();
}
Copy link
Member Author

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()) &&
Copy link
Member Author

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.

Copy link
Contributor

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);
Copy link
Member Author

@bbondy bbondy Mar 12, 2019

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(
Copy link
Member Author

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"
Copy link
Member Author

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)]]"
Copy link
Member Author

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.

@bbondy bbondy merged commit 5938e5a into master Mar 15, 2019
bbondy added a commit that referenced this pull request Mar 15, 2019
@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
/**
* @implements {settings.SocialBlockingBrowserProxy}
*/
class DefaultBraveShieldsBrowserProxyImpl {
Copy link
Member

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);
Copy link
Member

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);
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some Google login integrations do not work Add options for controlling how blocking is done at a high level
6 participants