 #   changes to localStorage and into vimium's internal state.
 # * Sync.fetchAsync() polls chrome.storage.sync at startup, similarly propagating
 #   changes to localStorage and into vimium's internal state.
-#
-# Changes are propagated into vimium's state using the same mechanism
-# (Settings.performPostUpdateHook) that is used when options are changed on
-# the options page.
 #
 # The effect is best-effort synchronization of vimium options/settings between
 # chrome/vimium instances.

  # postUpdateHooks convenience wrapper
  performPostUpdateHook: (key, value) ->
    @postUpdateHooks[key] value if @postUpdateHooks[key]

  # options.coffee and options.html only handle booleans and strings; therefore all defaults must be booleans
  # or strings

    @storage.get null, (items) =>
      unless chrome.runtime.lastError
        for own key, value of items
          Settings.storeAndPropagate key, value if @shouldSyncKey key

  # Asynchronous message from synced storage.
  handleStorageUpdate: (changes, area) ->
    for own key, change of changes
      Settings.storeAndPropagate key, change?.newValue if @shouldSyncKey key

  # Only called synchronously from within vimium, never on a callback.
  # No need to propagate updates to the rest of vimium, that's already been done.
