Skip to content

Commit

Permalink
[Chrome extension] Attempt to migrate the old `showPreviousViewOnLoad…
Browse files Browse the repository at this point in the history
…`/`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.
  • Loading branch information
Snuffleupagus committed Jan 28, 2019
1 parent 66deea1 commit fbfb4da
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions extensions/chromium/options/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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']);
}
}
});
}
})();
9 changes: 9 additions & 0 deletions web/chromecom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit fbfb4da

Please sign in to comment.