What is partition attribute for webview tag in Chrome App API?

穿精又带淫゛_ 提交于 2019-12-12 04:43:20

问题


I'm developing a Google Chrome packaged app right now.

I'm going to use webview tag to embed webpages for this app that I'm working on.

And I was reading this document below that describe webview tag.

https://developer.chrome.com/apps/tags/webview

But, I didn't quite understand what this is for.

Could anyone please explain what partition attribute is for?

Thanks!

<webview id="foo" src="http://www.google.com/" style="width:640px; height:480px" partition="persist:googlepluswidgets"></webview>

Storage partition ID used by the webview tag. If the storage partition ID starts with persist: (partition="persist:googlepluswidgets"), the webview will use a persistent storage partition available to all guests in the app with the same storage partition ID. If the ID is unset or if there is no 'persist': prefix, the webview will use an in-memory storage partition. This value can only be modified before the first navigation, since the storage partition of an active renderer process cannot change. Subsequent attempts to modify the value will fail with a DOM exception. By assigning the same partition ID, multiple webviews can share the same storage partition.


回答1:


A browser has a certain local state; localStorage, sessionStorage, cookies, etc.

A webview is a "mini browser". You can have multiple webviews, and you need to indicate the same partition so that they share this state (be multiple "tabs" of the same browser). Note that they will not share their state with the main Chrome instance.

And if you want this state to persist through closing your window, you need to add persistent to the ID. Useful if you're working with something that needs cookies.

The ID itself doesn't mean anything, it's just an identifier.



来源:https://stackoverflow.com/questions/25697697/what-is-partition-attribute-for-webview-tag-in-chrome-app-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!