Skip to content
This repository has been archived by the owner on Apr 17, 2021. It is now read-only.

Closes #311: enable tracking protection #318

Merged
merged 3 commits into from
Jan 16, 2018

Conversation

mcomella
Copy link
Contributor

The isBlockingEnabled flag should still work when we add the UI.

From my commit summary:

I think request.isForMainFrame() is unnecessary because of this line in
UrlMatcher.matches:

        if (pageHost != null && pageHost.equals(resourceHost)) {
            return false;
        }

Which whitelists first party requests: this is assuming the pageHost, which
comes from TrackingProtectionWebViewClient.currentPageUrl, actually
represents the current page loading (and thus the main frame).

I noted that my Android TV emulator seems to block the same numbers of trackers
as Focus.

I think request.isForMainFrame() is unnecessary because of this line in
UrlMatcher.matches:

        if (pageHost != null && pageHost.equals(resourceHost)) {
            return false;
        }

Which whitelists first party requests: this is assuming the `pageHost`, which
comes from `TrackingProtectionWebViewClient.currentPageUrl`, actually
represents the current page loading (and thus the main frame).

I noted that my Android TV emulator seems to block the same numbers of trackers
as Focus.
@mcomella mcomella requested review from liuche and boek January 12, 2018 23:56
Copy link
Contributor

@liuche liuche left a comment

Choose a reason for hiding this comment

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

One comment about isForMainFrame.


// Don't block the main frame from being loaded. This also protects against cases where we
// open a link that redirects to another app (e.g. to the play store).
final Uri pageUri = Uri.parse(currentPageURL);

// if ((!request.isForMainFrame()) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I dug through some code and it looks like the isForMainFrame was added to prevent non-browser links (like market://) from crashing on this matcher check.

If you verify that it still works, then I'm okay with it, but otherwise I'd leave it in.

mozilla-mobile/focus-android#106 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't use isForMainFrame because with this version of the webView we get a string, rather than the expected type we get in Focus.

That being said, I'll dig in on your research – thanks for doing that (good idea!)!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it looks like the isForMainFrame was added to prevent non-browser links (like market://) from crashing on this matcher check.

Looking at the linked issue, it looks like the http/http(s) checks were added to prevent crashing with malformed URLs like (market:://) but isForMainFrame is unrelated. #38 is open for fixing the http(s) check, which is out of scope of this issue (and we haven't seen any problems for it yet - maybe AmazonWebView is different because we're on a TV).

@mcomella mcomella merged commit 33ee0b1 into mozilla-mobile:master Jan 16, 2018
@mcomella mcomella deleted the i311-tp branch January 16, 2018 23:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants