Add recents, offlinepage and send to home screen for always incognito#1427
Conversation
Will not this breach the principle of not storing outside of RAM incognito navigation details?
Does it mean that the recent tabs feature requires the history in incognito to be enabled? Or, put the other way round: if history in incognito is disabled, will the recent tabs show in the history once someone enables that history in incognito setting? |
we already do, but only in always incognito with history enabled
tecnically yes, recents tabs needs some internal history services, in incognito are not enabled, even with history flag enabled.
no, recents tabs do not read the history, they only record the closing of the tab, if nothing is active, nothing is recorded. my patch activates that only with always incognito + history flag, I have not touched the code related to normal incognito mode, so even with history enabled recents tabs are not shown or recorded |
rereading it, I was not precise (I will not answer again in the evening! :) the reason why I did not activate it is for what I wrote, the opening is always in the primary mode, ie the normal one if without always incognito. basically the recents tabs work with the primary profile because they create an sqllite db in the primary partition (read, directory). |
|
Ok, so if I understand correctly once this patch is merged if the user has always-incognito AND always-incognito history, then they get the recent tabs feature working? |
yes, that's right, with offline pages |
|
Ok, I see; can you expand the patch description to mention more of this information (also from PR description)? So that it is not lost. |
Add a preference that causes all new tabs and all clicked links to launch in incognito. Make sure initial incognito status is correctly recognized. Enable incognito custom tabs and fix crashes for incognito/custom tab intents Use a native flag to correctly start new tabs on app startup Add history, recents, offlinepages and send to home screen support for always incognito. History, recent tabs and offline pages require the INCOGNITO_TAB_HISTORY_ENABLED flag turned on. IncognitoPlaceholder is also deactivated, both in the phone and tablet version. The relative tests are also present. based on the original work by Ryan Archer <ryan.bradley.archer@gmail.com> Major contributions by uazo. See also: bromite/bromite#1427 License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
here is the patch, unfortunately a bit big. what's up:
Add to homescreen in always incognito
it was enough to act in
AppMenuPropertiesDelegateImpl.javato show the button and enableisAddToHomeIntentSupported.Note that I only enabled it for always incognito because the open from the homescreen icon is always in primary mode (in normal navigation, so the homepage sites saved incognito are reopened not in incognito, and that's not good).
Enable recent tabs menu in always incognito
it was sufficient to act in
AppMenuPropertiesDelegateImpl.javato show the button and enable the registration of the tab inTabPersistentStore.javaat the moment of closing. inRecentTabsManagerI simply force the use of the primary profile, simply because otherwise the list of closed tabs would not be persisted. The modification inHistoricalTabSaveris simply to bring me the information of the incognito mode between java and native (the always incognito flag is only on the java side).Note that this feature is also active only for always incognito because reopening from the page is always in primary mode.
Save page in (always) incognito
A little more complex, first some technical notes (I hope not to write nonsense and not to offend anyone): first, it is not a simple creation of an mhtml file as I thought.
the offline mode is managed by
OfflinePageModelFactorywhich derives fromSimpleKeyedServiceFactory, which is chromium's way of managing dependency on services. The services are connected toBrowserContext, in our case by its derivation based on the profiles (ProfileKey) from which the current profile (normal or offtherecord, i.e. incognito) and where the preferences service can be retrieved. Side note: the profiles themselves are an extension of the BrowserContext and that from the incognito profiles you can retrieve the normal profile viaGetOriginalProfile(), useful for having the real persisted preferences.So, the work was to re-enable OfflinePageModelFactory and everything needed for his management, and I found
RequestCoordinatorFactorywhich I re-enabled for incognito management.The final step is to find where the saved pages are reopened, that is in the bridge between java and native (
OfflinePageBridge): here I forced the page to open as if it were a normal mhtml file opened by the user. I preferred this way because alternatively I would have had to rehabilitate other services and the relationship between them, which do not seem to be necessary.As I said here, too, I preferred activation only with always incognito: I do not have the ability to predict whether now or future functionalities can allow the passage of information between normal navigation and incognito (without always incognito active).
so for this I do not link any issues, where the request were different
The changes instead you see in
HistoryPageandHistoryManagerare for v94 where the new IncognitoPlaceholder does not allow viewing the history in incognito. In v94 it is active by default, in v93 seem to be under a flagTests
a note on tests: I'm starting to insert the tests in the patches that I do and that you find in this one too, but the question is a bit complex and must be explained separately.