1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

[CRX] Integrate cursorToolOnLoad pref + migration logic

Add UI for the cursorToolOnLoad pref in the UI of the Chrome extension.

Add logic to migrate the enableHandToolOnLoad pref to cursorToolOnLoad.
For past values in the mutable extension storage area:
1. If enableHandToolOnLoad=true, save cursorToolOnLoad=1.
2. Remove enableHandToolOnLoad.

For the managed extension storage, which is immutable since it is based
on administrative policies, use the following logic:
1. If enableHandToolOnLoad=true and cursorToolOnLoad=0 (default).
   set cursorToolOnLoad=0 and assume enableHandToolOnLoad=false.
2. As usual, managed preferences can (and will) be overridden by the user.

The first migration logic is in extensions/chromium/options/migration.js
and can be removed after a few months / less than many years.

The second migration logic is in web/chromecom.js, and should be kept
around for a long while (many years).

The need for this migration logic arises from the change by:
https://github.com/mozilla/pdf.js/pull/7635
This commit is contained in:
Rob Wu 2017-07-15 01:50:15 +02:00
parent ca3c08f12b
commit 19549bb7d6
5 changed files with 73 additions and 1 deletions

View file

@ -328,7 +328,18 @@ class ChromePreferences extends BasePreferences {
// Get preferences as set by the system administrator.
// See extensions/chromium/preferences_schema.json for more information.
// These preferences can be overridden by the user.
chrome.storage.managed.get(this.defaults, getPreferences);
chrome.storage.managed.get(this.defaults, function(items) {
// Migration code for https://github.com/mozilla/pdf.js/pull/7635.
// Never remove this, because we have no means of modifying managed
// preferences.
if (items && items.enableHandToolOnLoad && !items.cursorToolOnLoad) {
// if the old enableHandToolOnLoad has a non-default value,
// and cursorToolOnLoad has a default value, migrate.
items.enableHandToolOnLoad = false;
items.cursorToolOnLoad = 1;
}
getPreferences(items);
});
} else {
// Managed storage not supported, e.g. in old Chromium versions.
getPreferences(this.defaults);