Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import mozilla.components.support.base.log.logger.Logger
import org.mozilla.vrbrowser.VRBrowserApplication
import org.mozilla.vrbrowser.utils.SystemUtils
import java.util.concurrent.CompletableFuture
import java.util.stream.Collectors
import java.util.stream.Stream

class HistoryStore constructor(val context: Context) {

Expand All @@ -25,6 +27,14 @@ class HistoryStore constructor(val context: Context) {
private var listeners = ArrayList<HistoryListener>()
private var storage = (context.applicationContext as VRBrowserApplication).places.history

companion object {
@JvmStatic
val BLOCK_LIST: MutableList<String> = Stream.of(
"https://accounts.firefox.com/authorization",
"https://accounts.firefox.com/oauth"
).collect(Collectors.toList())
}

// Bookmarks might have changed during sync, so notify our listeners.
private val syncStatusObserver = object : SyncStatusObserver {
override fun onStarted() {}
Expand Down Expand Up @@ -93,13 +103,21 @@ class HistoryStore constructor(val context: Context) {
}

fun recordVisit(aURL: String, pageVisit: PageVisit) = GlobalScope.future {
storage.recordVisit(aURL, pageVisit)
notifyListeners()
if(BLOCK_LIST.stream().noneMatch {
aURL.startsWith(it)
}) {
storage.recordVisit(aURL, pageVisit)
notifyListeners()
}
}

fun recordObservation(aURL: String, observation: PageObservation) = GlobalScope.future {
storage.recordObservation(aURL, observation)
notifyListeners()
if(BLOCK_LIST.stream().noneMatch {
aURL.startsWith(it)
}) {
storage.recordObservation(aURL, observation)
notifyListeners()
}
}

fun deleteHistory(aUrl: String, timestamp: Long) = GlobalScope.future {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.mozilla.vrbrowser.R;
import org.mozilla.vrbrowser.VRBrowserApplication;
import org.mozilla.vrbrowser.browser.Accounts;
import org.mozilla.vrbrowser.browser.HistoryStore;
import org.mozilla.vrbrowser.browser.Media;
import org.mozilla.vrbrowser.browser.Services;
import org.mozilla.vrbrowser.browser.SettingsStore;
Expand All @@ -41,7 +42,6 @@
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import mozilla.components.concept.sync.AccountObserver;
import mozilla.components.concept.sync.AuthType;
Expand Down Expand Up @@ -72,11 +72,6 @@ public class Windows implements TrayListener, TopBarWidget.Delegate, TitleBarWid
private static final int TAB_SENT_NOTIFICATION_ID = 1;
private static final int BOOKMARK_ADDED_NOTIFICATION_ID = 2;

// Restore URLs blocklist
private static final List<String> SAVE_BLOCKLIST = Stream.of(
"https://accounts.firefox.com/oauth/"
).collect(Collectors.toList());

class WindowState {
WindowPlacement placement;
int textureWidth;
Expand Down Expand Up @@ -211,7 +206,7 @@ public void saveState() {
ArrayList<Session> sessions = SessionStore.get().getSortedSessions(false);
state.tabs = sessions.stream()
.map(Session::getSessionState)
.filter(sessionState -> SAVE_BLOCKLIST.stream().noneMatch(uri ->
.filter(sessionState -> HistoryStore.getBLOCK_LIST().stream().noneMatch(uri ->
sessionState.mUri != null && sessionState.mUri.startsWith(uri)
))
.collect(Collectors.toCollection(ArrayList::new));
Expand Down