diff --git a/extensions/chromium/options/migration.js b/extensions/chromium/options/migration.js index 7073fc5bc7e80..0ecaf2d96e4e4 100644 --- a/extensions/chromium/options/migration.js +++ b/extensions/chromium/options/migration.js @@ -29,6 +29,8 @@ limitations under the License. storageLocal.get(storageKeys, function(values) { if (!values || !Object.keys(values).length) { // No local storage - nothing to migrate. + // ... except possibly for a renamed preference name. + migrateRenamedStorage(); return; } migrateToSyncStorage(values); @@ -63,7 +65,34 @@ limitations under the License. // the migration successful. console.log( 'Successfully migrated preferences from local to sync storage.'); + migrateRenamedStorage(); }); }); } + + // TODO: Remove this migration code somewhere in the future, when most users + // have had their chance of migrating to the new preference format. + // Note: We cannot modify managed preferences, so the migration logic is + // duplicated in web/chromecom.js too. + function migrateRenamedStorage() { + storageSync.get([ + 'enableHandToolOnLoad', + 'cursorToolOnLoad', + ], function(items) { + // Migration code for https://github.com/mozilla/pdf.js/pull/7635. + if (typeof items.enableHandToolOnLoad === 'boolean') { + if (items.enableHandToolOnLoad) { + storageSync.set({ + cursorToolOnLoad: 1, + }, function() { + if (!chrome.runtime.lastError) { + storageSync.remove('enableHandToolOnLoad'); + } + }); + } else { + storageSync.remove('enableHandToolOnLoad'); + } + } + }); + } })(); diff --git a/extensions/chromium/options/options.html b/extensions/chromium/options/options.html index 901cd95e2cf42..6a00062e123cb 100644 --- a/extensions/chromium/options/options.html +++ b/extensions/chromium/options/options.html @@ -80,6 +80,18 @@ + +