Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support syncing of settings in Chrome extension #7346

Merged
merged 1 commit into from
May 24, 2016

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented May 23, 2016

Use chrome.storage.sync to store preferences instead of chrome.storage.local, to allow settings to be synchronized if the user chooses to sign in in Chrome and enables synchronization of extension preferences.

Tested with Chrome 50 as follows:

  1. Build the Chrome extension (node make chromium).
  2. Load the extension at chrome://extensions.
  3. Open the options page, right-click and choose Inspect element to open Chrome's devtools and run the following snippet in the console (to simulate the behavior before this PR):
    storageAreaName = 'local'; storageArea = chrome.storage.local;
  4. Change some preferences in the options page.
  5. Close the options page and re-open it. You will observe that the settings are back to their defaults (because the settings at step 3 and 4 are saved to storage.local).
  6. Inspect the background page and reload it (e.g. by running location.reload() from the console).
  7. Confirm that the background page shows "Successfully migrated preferences from local to sync storage."
  8. Repeat step 6 (i.e. reload the background page).
  9. Confirm that no extra messages are printed (i.e. there is nothing to migrate since the last migration succeeded).

With the above steps, you can verify that the migration logic works as intended. Now, also test whether the preferences are actually applied:

  1. Visit the options page of the extension at chrome://extensions
  2. Untick the "Activate Hand tool by default" checkbox.
  3. Open any PDF file, e.g. http://www.orimi.com/pdf-test.pdf
  4. Press the mouse and move it around.
  5. Confirm that text is being selected (=handtool is disabled).
  6. Go back to the options page, and check the "Activate Hand tool by default" checkbox.
  7. Repeat step 3 and 4.
  8. Confirm that the page is moved up and down (=handtool is enabled). (If your screen is big then the page fits on one page, in that case just zoom in or resize the window so that the page doesn't fit in the viewport).

Fixes #7325.

/cc @timvandermeij Please review this PR.

Use chrome.storage.sync to store preferences instead of
chrome.storage.local, to allow settings to be synchronized if the user
chooses to sign in in Chrome and enables synchronization of extension
preferences.
@Rob--W Rob--W force-pushed the crx-sync-storage branch from 1cd549c to 0be8e72 Compare May 24, 2016 22:52
@Rob--W
Copy link
Member Author

Rob--W commented May 24, 2016

@timvandermeij I rebased and amended the commit so that the pref from #7353 is also migrated when needed.

@timvandermeij
Copy link
Contributor

timvandermeij commented May 24, 2016

I'm stuck at step 7 of the migration logic testing steps. When I reload the background page, the console does not show the intended message. Instead I get:

undefined
Navigated to chrome-extension://liebonjgmjnebbagcedpdnmffffkjpmd/options/options.html

It's not clear to me where the undefined comes from. I'm using Chromium 50 on Arch Linux. Do you also see this with the most recent commit? Do you have to be signed in to Chrome for this to work (currently I'm not)?

@Rob--W
Copy link
Member Author

Rob--W commented May 24, 2016 via email

@timvandermeij
Copy link
Contributor

I see now. I was reloading the options page, not the background page (pdfHandler.html). Now I do see the message in the console.

@timvandermeij timvandermeij merged commit 47b929b into mozilla:master May 24, 2016
@timvandermeij
Copy link
Contributor

Thank you for the patch!

@KevsBitcoin
Copy link

Looking to sync data from one extension that i need to set up add rules will this be able to sync the data from folder location \Chrome\User Data\Profile\databases\chrome-extension_ this is where that data is stored after i add and save info i applied to a chrome extension?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants