Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Remove extra tracking exclusion notifications
Browse files Browse the repository at this point in the history
Update tracking protection on location change instead of url change
Rebase fixes
  • Loading branch information
keianhzo committed Apr 22, 2020
1 parent 3e2c565 commit fc50518
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,26 @@ public void fetchAll(Function<List<SitePermission>, Void> onResult) {

public void add(@NonNull Session session) {
mContentBlockingController.addException(session.getGeckoSession());
mListeners.forEach(listener -> listener.onExcludedTrackingProtectionChange(
UrlUtils.getHost(session.getCurrentUri()),
true));
persist();
// Private sessions don't persist to the content blocking controller exceptions list so we just notify
if (session.isPrivateMode()) {
mListeners.forEach(listener -> listener.onExcludedTrackingProtectionChange(
UrlUtils.getHost(session.getCurrentUri()),
true));
} else {
persist();
}
}

public void remove(@NonNull Session session) {
mContentBlockingController.removeException(session.getGeckoSession());
mListeners.forEach(listener -> listener.onExcludedTrackingProtectionChange(
UrlUtils.getHost(session.getCurrentUri()),
false));
persist();
// Private sessions don't persist to the content blocking controller exceptions list so we just notify
if (session.isPrivateMode()) {
mListeners.forEach(listener -> listener.onExcludedTrackingProtectionChange(
UrlUtils.getHost(session.getCurrentUri()),
true));
} else {
persist();
}
}

public void remove(@NonNull SitePermission permission) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ public void onChanged(Spannable aUrl) {
!isLibraryVisible.getValue().get() &&
!UrlUtils.isContentFeed(getApplication(), aUrl.toString()) &&
!UrlUtils.isFileUri(aUrl.toString()) &&
!UrlUtils.isPrivateAboutPage(getApplication(), aUrl.toString()) &&
(
(SettingsStore.getInstance(getApplication()).getTrackingProtectionLevel() != ContentBlocking.EtpLevel.NONE) ||
isPopUpAvailable.getValue().get() ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ public void detachFromWindow() {
mViewModel.getIsFullscreen().removeObserver(mIsFullscreenObserver);
mViewModel.getIsActiveWindow().removeObserver(mIsActiveWindowObserver);
mViewModel.getIsPopUpBlocked().removeObserver(mIsPopUpBlockedListener);
mViewModel.getUrl().removeObserver(mUrlObserver);
mViewModel = null;
}

Expand All @@ -518,7 +517,6 @@ public void attachToWindow(@NonNull WindowWidget aWindow) {
mViewModel.getIsFullscreen().observeForever( mIsFullscreenObserver);
mViewModel.getIsActiveWindow().observeForever(mIsActiveWindowObserver);
mViewModel.getIsPopUpBlocked().observeForever(mIsPopUpBlockedListener);
mViewModel.getUrl().observeForever(mUrlObserver);
mBinding.navigationBarNavigation.urlBar.attachToWindow(mAttachedWindow);

mTrackingDelegate.addListener(mTrackingListener);
Expand Down Expand Up @@ -803,6 +801,15 @@ private void closeFloatingMenus() {
}
}

// NavigationDelegate

@Override
public void onLocationChange(@NonNull GeckoSession geckoSession, @Nullable String s) {
if (getSession() != null && getSession().getGeckoSession() == geckoSession) {
updateTrackingProtection();
}
}

// Content delegate

private Observer<ObservableBoolean> mIsFullscreenObserver = isFullScreen -> {
Expand Down Expand Up @@ -835,8 +842,6 @@ private void closeFloatingMenus() {
}
};

private Observer<Spannable> mUrlObserver = sitePermissions -> updateTrackingProtection();

private Observer<ObservableBoolean> mIsActiveWindowObserver = aIsActiveWindow -> updateTrackingProtection();

private Observer<ObservableBoolean> mIsPopUpBlockedListener = observableBoolean -> {
Expand Down

0 comments on commit fc50518

Please sign in to comment.