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

Commit 11a6fd9

Browse files
authored
Exclude FxA login urls from history (#3612)
1 parent 57b6b79 commit 11a6fd9

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

app/src/common/shared/org/mozilla/vrbrowser/browser/HistoryStore.kt

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import mozilla.components.support.base.log.logger.Logger
1717
import org.mozilla.vrbrowser.VRBrowserApplication
1818
import org.mozilla.vrbrowser.utils.SystemUtils
1919
import java.util.concurrent.CompletableFuture
20+
import java.util.stream.Collectors
21+
import java.util.stream.Stream
2022

2123
class HistoryStore constructor(val context: Context) {
2224

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

30+
companion object {
31+
@JvmStatic
32+
val BLOCK_LIST: MutableList<String> = Stream.of(
33+
"https://accounts.firefox.com/authorization",
34+
"https://accounts.firefox.com/oauth"
35+
).collect(Collectors.toList())
36+
}
37+
2838
// Bookmarks might have changed during sync, so notify our listeners.
2939
private val syncStatusObserver = object : SyncStatusObserver {
3040
override fun onStarted() {}
@@ -93,13 +103,21 @@ class HistoryStore constructor(val context: Context) {
93103
}
94104

95105
fun recordVisit(aURL: String, pageVisit: PageVisit) = GlobalScope.future {
96-
storage.recordVisit(aURL, pageVisit)
97-
notifyListeners()
106+
if(BLOCK_LIST.stream().noneMatch {
107+
aURL.startsWith(it)
108+
}) {
109+
storage.recordVisit(aURL, pageVisit)
110+
notifyListeners()
111+
}
98112
}
99113

100114
fun recordObservation(aURL: String, observation: PageObservation) = GlobalScope.future {
101-
storage.recordObservation(aURL, observation)
102-
notifyListeners()
115+
if(BLOCK_LIST.stream().noneMatch {
116+
aURL.startsWith(it)
117+
}) {
118+
storage.recordObservation(aURL, observation)
119+
notifyListeners()
120+
}
103121
}
104122

105123
fun deleteHistory(aUrl: String, timestamp: Long) = GlobalScope.future {

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/Windows.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.mozilla.vrbrowser.R;
1616
import org.mozilla.vrbrowser.VRBrowserApplication;
1717
import org.mozilla.vrbrowser.browser.Accounts;
18+
import org.mozilla.vrbrowser.browser.HistoryStore;
1819
import org.mozilla.vrbrowser.browser.Media;
1920
import org.mozilla.vrbrowser.browser.Services;
2021
import org.mozilla.vrbrowser.browser.SettingsStore;
@@ -41,7 +42,6 @@
4142
import java.util.Collections;
4243
import java.util.List;
4344
import java.util.stream.Collectors;
44-
import java.util.stream.Stream;
4545

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

75-
// Restore URLs blocklist
76-
private static final List<String> SAVE_BLOCKLIST = Stream.of(
77-
"https://accounts.firefox.com/oauth/"
78-
).collect(Collectors.toList());
79-
8075
class WindowState {
8176
WindowPlacement placement;
8277
int textureWidth;
@@ -211,7 +206,7 @@ public void saveState() {
211206
ArrayList<Session> sessions = SessionStore.get().getSortedSessions(false);
212207
state.tabs = sessions.stream()
213208
.map(Session::getSessionState)
214-
.filter(sessionState -> SAVE_BLOCKLIST.stream().noneMatch(uri ->
209+
.filter(sessionState -> HistoryStore.getBLOCK_LIST().stream().noneMatch(uri ->
215210
sessionState.mUri != null && sessionState.mUri.startsWith(uri)
216211
))
217212
.collect(Collectors.toCollection(ArrayList::new));

0 commit comments

Comments
 (0)