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

Domain block and 1PES integration #10339

Merged
merged 9 commits into from
Dec 17, 2021
Merged

Domain block and 1PES integration #10339

merged 9 commits into from
Dec 17, 2021

Conversation

goodov
Copy link
Member

@goodov goodov commented Oct 1, 2021

Add first party ephemeral storage auto-enable logic when a First Party Ephemeral Storage feature is enabled and a user proceeds a domain block interstitial.

Resolves brave/brave-browser#19099

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@goodov goodov requested review from a team as code owners October 1, 2021 13:22
@goodov goodov self-assigned this Oct 1, 2021
@iefremov iefremov self-requested a review October 25, 2021 14:16
@goodov goodov force-pushed the debounce+1pes branch 2 times, most recently from d57d075 to f708321 Compare October 28, 2021 15:14
@goodov goodov requested a review from a team as a code owner October 28, 2021 15:14
@goodov goodov force-pushed the debounce+1pes branch 3 times, most recently from eda447d to 2678787 Compare October 29, 2021 11:29
@goodov goodov changed the title WIP Debounce and 1pes integration Debounce and 1pes integration Oct 29, 2021
@goodov goodov changed the title Debounce and 1pes integration Domain block and 1PES integration Oct 29, 2021
FROM_HERE,
base::BindOnce(&UrlStorageChecker::StartCheck,
base::MakeRefCounted<UrlStorageChecker>(
context_->GetStoragePartitionForUrl(url, true), url,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is deprecated


#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_refptr.h"
#include "components/services/storage/public/mojom/local_storage_control.mojom.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be moved to .cc ?

// actors.
class EphemeralStorageService
: public KeyedService,
public base::SupportsWeakPtr<EphemeralStorageService> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it used anywhere?

WebContents* first_party_tab =
LoadURLInNewTab(a_site_ephemeral_storage_url_);
EXPECT_TRUE(IsShowingInterstitial(first_party_tab));
Click(first_party_tab, "dont-warn-again-checkbox");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed?

void NavigateToBlockedDomainAndExpectEphemeralEnabled() {
WebContents* first_party_tab = NavigateToBlockedDomain();

// After keepalive values should be cleared.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also check that they are NOT cleared while we are keepaliving?

@iefremov
Copy link
Contributor

iefremov commented Nov 1, 2021

  1. during manual testing i've noticed that keepalive actually doesn't work with 1PES, mb I'm doing something wrong?

  2. wondering how we should deal with "don't ask again". If the checkbox is not checked, we still will keep the content setting for a host forever. Not a big deal, just want to check whether this is what we want.

@goodov
Copy link
Member Author

goodov commented Nov 2, 2021

  1. during manual testing i've noticed that keepalive actually doesn't work with 1PES, mb I'm doing something wrong?

discussed in Slack. It works, but if a tab is closed (and no other tabs are opened with the same website), the storage is cleaned up immediately. Keep-alive works for in-tab navigations, for ex. when we navigate away and back; a use-case to remember is an SSO-like authorization (going to an auth website and back).

  1. wondering how we should deal with "don't ask again". If the checkbox is not checked, we still will keep the content setting for a host forever. Not a big deal, just want to check whether this is what we want.

I think it doesn't matter if this options is checked or not. When it's not checked, any attempt to visit the website will still show the interstitial, and we will enable 1PES anyways (if for some reason we decide to turn it off after each visit).

base::FEATURE_DISABLED_BY_DEFAULT};
// When enabled, Brave will attempt to enable 1PES mode in a standard blocking
// mode when a user visists a domain that is present in currently active adblock
// filters. 1PES will be enabled only if nor cookies nor localStorage data is
Copy link
Contributor

@iefremov iefremov Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neither cookies nor localStorage are stored

@@ -32,6 +32,12 @@ enum ControlType {
AGGRESSIVE
};

enum class DomainBlockingType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment?

return DomainBlockingType::kAggressive;
}

if (base::FeatureList::IsEnabled(
// Block using 1PES if ad blocking is "standard".
if (cosmetic_control_type == BLOCK_THIRD_PARTY &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand why it is about cosmetic filters, but that's not relevant to the PR...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is definitely a bit confusing and we need to consolidate the logic for adblock with its own control type. RIght now we're duplicating checks in BraveShieldsDataController and presumably in android for the UI setting

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// filters. 1PES will be enabled only if nor cookies nor localStorage data is
// stored for the website.
const base::Feature kBraveDomainBlock1PES{"BraveDomainBlock1PES",
base::FEATURE_DISABLED_BY_DEFAULT};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry on brave://flags?

Copy link
Contributor

@mariospr mariospr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chromium_src LGTM

@goodov goodov merged commit 6d7fb31 into master Dec 17, 2021
@goodov goodov deleted the debounce+1pes branch December 17, 2021 08:11
@goodov goodov added this to the 1.35.x - Nightly milestone Dec 17, 2021
// Don't block if feature is disabled
if (!base::FeatureList::IsEnabled(brave_shields::features::kBraveDomainBlock))
return false;
return DomainBlockingType::kNone;

// Don't block if Brave Shields is down (this also handles cases where
// the URL is not HTTP(S))
if (!brave_shields::GetBraveShieldsEnabled(map, url))
Copy link
Collaborator

@bridiver bridiver Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This goes against the established pattern of using Get for the raw value for display in the UI and I think that's a bit confusing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be clear I'm talking about GetDomainBlockingType, just commenting here because of the shields check

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe absl::optional<DomainBlockingType> ShouldDoDominBlocking(...) and get rid of kNone?

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.

Integrate first party ephemeral storage with domain block functionality
4 participants