Skip to content

Commit 6581054

Browse files
janRuckarogerwang
authored andcommitted
chrome.cookies API for webview documentation
1 parent 6388aaa commit 6581054

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

docs/References/Chrome Extension APIs.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ In addition, we supported some chrome.* API in the [extension platform](https://
77

88
* [chrome.contentSettings](https://developer.chrome.com/extensions/contentSettings) : used to control notfication settings.
99
* [chrome.tabs](https://developer.chrome.com/extensions/tabs) : used to support fully DevTools extensions
10-
* [chrome.proxy](https://developer.chrome.com/extensions/proxy) : manage proxy settings
10+
* [chrome.proxy](https://developer.chrome.com/extensions/proxy) : manage proxy settings
11+
* [chrome.cookies](https://developer.chrome.com/extensions/cookies) : functions `get`, `getAll`, `set` and `remove` are supported for webview with webview storeId (`webview.getCookieStoreId()`)

docs/References/webview Tag.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,16 @@ and add 'partition="trusted"' attribute to the webview tag.
4242

4343
### Node.js support in webview
4444

45-
To enable Node.js support in WebView, add the `allownw` attribute to the webview tag. Then Node.js will be turned on, no matter it loads local file or remote site. Use this feature with caution because webview is normally supposed to load untrusted contents.
45+
To enable Node.js support in WebView, add the `allownw` attribute to the webview tag. Then Node.js will be turned on, no matter it loads local file or remote site. Use this feature with caution because webview is normally supposed to load untrusted contents.
46+
47+
### Cookies support in webview
48+
49+
Webview has 'getCookieStoreId()' function which returns storeId which can be used in [chrome.cookies](https://developer.chrome.com/extensions/cookies) API.
50+
51+
##### Example in console:
52+
Lets assume you have simple NW.js app with webview.
53+
54+
Show all cookies for e.g. http://docs.nwjs.io in console (to have some cookies there you need to visit page first):
55+
```html
56+
chrome.cookies.getAll({url:"http://docs.nwjs.io", storeId:webview.getCookieStoreId()}, console.log.bind(console));
57+
```

0 commit comments

Comments
 (0)