理解Chrome .storage.sync's在未登录Chrome浏览器时的行为

Understanding chrome.storage.sync's behaviour when not signed in to the Chrome browser

本文关键字:Chrome 浏览器 登录 sync storage 理解      更新时间:2023-09-26

我一直在玩chrome.storage.sync API作为我正在构建的谷歌Chrome扩展的一部分。

API清楚地表明,如果您登录到Chrome浏览器与您的谷歌帐户和使用chrome.storage.sync.set然后所有的数据设置将是可访问的下一次您登录到Chrome浏览器与相同的谷歌帐户和使用chrome.storage.sync.get

API没有特别明确的是chrome.storage.sync在未登录到Chrome浏览器时的行为

从我的实验看来,当不是登录到Chrome浏览器,chrome.storage.sync.setchrome.storage.local.set保存到不同的地方。

它在API中说:

当Chrome离线时,Chrome将数据保存在本地。下次浏览器在线时,Chrome会同步数据。即使用户禁用同步、存储。同步仍然可以工作。在这种情况下,它会表现得很好与storage.local.

相同

看来

的位置

Chrome本地存储[同步]数据

chrome.storage.local.set存储它的位置不同。有人能证实这是真的吗?

当Chrome.storage.sync无法连接到互联网时,它会将数据存储在本地一个新的临时位置。它不会将其存储在Chrome.storage.local中,而是通过Chrome.storage.sync.

混乱似乎是在语言上。Chrome.storage.local是一个单独的位置,而Chrome.storage.sync的行为将像Chrome.storage.local一样。它不使用相同的存储位置

实际上chrome的描述已经清楚地说明了https://developer.chrome.com/extensions/storage

当Chrome离线时,Chrome将数据保存在本地。下次浏览器在线时,Chrome会同步数据。即使用户禁用同步、存储。同步仍然可以工作。在这种情况下,它会表现得很好与storage.local.

相同