mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
[CRX] Restore migration logic for managed enableHandToolOnLoad pref
This partially reverts df0836b9b8
.
The entry in preferences_schema.json is restored because that is
required to make managed preferences visible to the extension code.
The default key is still removed from default_preferences.json,
because this change only concerns the Chrome extension, not the
other parts of PDF.js. To account for the missing key, the
deprecated key was added back in chromecom.js
The key needs to be restored in preferences_schema.json too,
because that's the only way to make managed preferences visible.
I'm using `Object.assign`, which was introduced in Chrome 45,
so the preference module will break in Chrome 45 and earlier.
This is fine, because we do not support Chrome before 49.
This commit is contained in:
parent
a89071bdef
commit
fc83ce1aae
2 changed files with 17 additions and 3 deletions
|
@ -308,16 +308,25 @@ 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, function(items) {
|
||||
|
||||
// Deprecated preferences are removed from web/default_preferences.json,
|
||||
// but kept in extensions/chromium/preferences_schema.json for backwards
|
||||
// compatibility with managed preferences.
|
||||
let defaultManagedPrefs = Object.assign({
|
||||
enableHandToolOnLoad: false,
|
||||
}, this.defaults);
|
||||
|
||||
chrome.storage.managed.get(defaultManagedPrefs, function(items) {
|
||||
items = items || defaultManagedPrefs;
|
||||
// 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 (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;
|
||||
}
|
||||
delete items.enableHandToolOnLoad;
|
||||
getPreferences(items);
|
||||
});
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue