From 0bc495d03266bcca1b8e8a64e2196cb2ed4dbca7 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 27 Jan 2019 17:49:37 +0100 Subject: [PATCH] [Chrome extension] Attempt to migrate the old `showPreviousViewOnLoad`/`disablePageMode` preferences to the new `viewOnLoad` preference This patch ignores the recently added `disableOpenActionDestination` preference, since the latest PDF.js version found on the "Chrome Web Store" doesn't include it. --- extensions/chromium/options/migration.js | 17 +++++++++++++++++ web/chromecom.js | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/extensions/chromium/options/migration.js b/extensions/chromium/options/migration.js index ca547850c42149..d2d8720d4eb9c3 100644 --- a/extensions/chromium/options/migration.js +++ b/extensions/chromium/options/migration.js @@ -81,6 +81,9 @@ limitations under the License. 'disableTextLayer', 'enhanceTextSelection', 'textLayerMode', + 'showPreviousViewOnLoad', + 'disablePageMode', + 'viewOnLoad', ], function(items) { // Migration code for https://github.com/mozilla/pdf.js/pull/7635. if (typeof items.enableHandToolOnLoad === 'boolean') { @@ -113,6 +116,20 @@ limitations under the License. storageSync.remove(['disableTextLayer', 'enhanceTextSelection']); } } + // Migration code for https://github.com/mozilla/pdf.js/pull/10502. + if (typeof items.showPreviousViewOnLoad === 'boolean') { + if (!items.showPreviousViewOnLoad) { + storageSync.set({ + viewOnLoad: 1, + }, function() { + if (!chrome.runtime.lastError) { + storageSync.remove(['showPreviousViewOnLoad', 'disablePageMode']); + } + }); + } else { + storageSync.remove(['showPreviousViewOnLoad', 'disablePageMode']); + } + } }); } })(); diff --git a/web/chromecom.js b/web/chromecom.js index 48eecb6ccc35e2..88c8f525921fe5 100644 --- a/web/chromecom.js +++ b/web/chromecom.js @@ -341,6 +341,8 @@ class ChromePreferences extends BasePreferences { enableHandToolOnLoad: false, disableTextLayer: false, enhanceTextSelection: false, + showPreviousViewOnLoad: true, + disablePageMode: false, }, this.defaults); chrome.storage.managed.get(defaultManagedPrefs, function(items) { @@ -370,6 +372,13 @@ class ChromePreferences extends BasePreferences { delete items.disableTextLayer; delete items.enhanceTextSelection; + // Migration code for https://github.com/mozilla/pdf.js/pull/10502. + if (!items.showPreviousViewOnLoad && !items.viewOnLoad) { + items.viewOnLoad = 1; + } + delete items.showPreviousViewOnLoad; + delete items.disablePageMode; + getPreferences(items); }); } else {