| ... |
... |
@@ -39,24 +39,23 @@ class TorConnectionAssistViewModel( |
|
39
|
39
|
|
|
40
|
40
|
private fun loadAndUnloadDummyPage() {
|
|
41
|
41
|
viewModelScope.launch(Dispatchers.IO) {
|
|
42
|
|
- // Load local url (it just needs to begin with "about:" to get past filter) to initialize the browser,
|
|
43
|
|
- // Domain fronting needs Services.io.getProtocolHandler("http")... to actually work, and it
|
|
44
|
|
- // does not till the browser/engine is initialized, and this is so far the easiest way to do that.
|
|
45
|
|
- // Load early here so that it is ready when needed if we get to the step where DF is invoked
|
|
46
|
|
- // Then later remove it so it doesn't show for the user
|
|
47
|
|
- components.useCases.tabsUseCases.addTab.invoke("about:")
|
|
|
42
|
+ // Load made up local url to initialize the browser.
|
|
|
43
|
+ // Domain fronting needs Services.io.getProtocolHandler("http")... to actually work
|
|
|
44
|
+ // It does not work until the browser/engine is initialized and we found this is so far
|
|
|
45
|
+ // the easiest way to do that.
|
|
|
46
|
+ // Load early here so that it is ready when needed if we get to the step where domain
|
|
|
47
|
+ // fronting is invoked. Remove after it so it doesn't show for the user
|
|
|
48
|
+ components.useCases.tabsUseCases.addTab.invoke("about:dummyPage")
|
|
48
|
49
|
// removeTabs doesn't work without a delay.
|
|
49
|
50
|
Thread.sleep(500)
|
|
50
|
51
|
// Remove loaded URL so it is never visible to the user
|
|
51
|
52
|
components.useCases.tabsUseCases.removeTabs.invoke(
|
|
52
|
53
|
components.core.store.state.tabs.filter {
|
|
53
|
|
- it.getUrl() == "about:" || it.getUrl() == "about:blank"
|
|
|
54
|
+ it.getUrl() == "about:dummyPage"
|
|
54
|
55
|
}.map { it.id },
|
|
55
|
56
|
)
|
|
56
|
|
- // recentlyClosedTabsStorage.value.removeAllTabs() doesn't seem to work,
|
|
57
|
|
- // so instead we collect and iteratively remove all tabs from recent history.
|
|
58
|
|
- // Nothing should ever show up in history so we remove everything,
|
|
59
|
|
- // including old "about:" tabs that may have stacked up.
|
|
|
57
|
+ // Collect and iteratively remove all tabs from recent history.
|
|
|
58
|
+ // Nothing should ever show up in history so it is safe to just remove everything,
|
|
60
|
59
|
components.core.recentlyClosedTabsStorage.value.getTabs()
|
|
61
|
60
|
.collect { tabs: List<TabState> ->
|
|
62
|
61
|
for (tab in tabs) {
|