Skip to content

Commit 23dd201

Browse files
authored
Update CustomStoragePartition.md
1 parent f66ec4c commit 23dd201

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

specs/CustomStoragePartition.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ is set in [CoreWebView2EnvironmentOptions.AdditionalBrowserArguments](https://le
3030
used to create CoreWebView2Environment. If not set, no custom storage partition will be
3131
created and all data will be treated as unpartitioned and stored in the global default
3232
location for the profile.
33+
The custom storage partition APIs will remain experiemental when related browser features
34+
are still experimental.
3335

3436
# Examples
3537

@@ -38,11 +40,19 @@ data stored in the custom storage partition.
3840

3941
## Win32 C++
4042
```cpp
41-
// Sets custom storage partition identified by the partitionId, which uniquely
42-
// identifies an application context.
43-
void SetPartitionId(PCWSTR partitionId)
43+
44+
void OnWebViewCreated()
4445
{
46+
// ...
47+
// other WebView setup like add event handlers, update settings.
48+
49+
// Sets custom storage partition identified by the partitionId, which uniquely
50+
// identifies an application context.
51+
PCWSTR partitionId = L"Partition 1";
4552
CHECK_FAILURE(m_webview->put_CustomStoragePartitionId(partitionId));
53+
54+
// Navigate to start page
55+
m_webview->Navigation(startPage);
4656
}
4757

4858
// Clears all data in custom storage partition identified by the partitionId.
@@ -80,9 +90,18 @@ data stored in the custom storage partition.
8090
```c#
8191
// Sets custom storage partition identified by the partitionId, which uniquely
8292
// identifies an application context.
83-
void SetPartitionId(string partitionId)
93+
void CoreWebView_Created()
8494
{
95+
// ...
96+
// other WebView setup like add event handlers, update settings.
97+
98+
// Sets custom storage partition identified by the partitionId, which uniquely
99+
// identifies an application context.
100+
string partitionId = "Partition 1";
85101
m_webview.CustomStoragePartitionId = partitionId;
102+
103+
// Navigate to start page
104+
m_webview.Navigation(startPage);
86105
}
87106
88107
// Clears all data in custom storage partition identified by the partitionId.
@@ -119,14 +138,14 @@ interface ICoreWebView2_18 : IUnknown {
119138
/// `CustomStoragePartitionId` will be reset and the page inside the WebView
120139
/// will work normally with data treated as unpartitioned.
121140
/// The `customStoragePartitionId` parameter is case sensitive. The default is
122-
/// an empty string.
141+
/// an empty string. There is no restriction on the lenght or what characters
142+
/// can be used in partition id.
123143
/// The change of the custom storage partition id will be applied to new
124144
/// page or iframe navigations and not impact existing pages and iframes.
125145
/// To avoid accidentally use new partition id for pending navigations of old page
126146
/// or iframe, it is recommended to create a new WebView for new partition instead
127147
/// of changing partition. If you really have to change partition, it is
128-
/// recommended to navigate to a blank page or call `Stop()` API to stop all
129-
/// navigations and pending resource fetches before setting the new partition
148+
/// recommended to navigate to a blank page before setting the new partition
130149
/// id and navigate to a page for the new partition.
131150
///
132151
/// As setting custom storage partition id does not change DOM security

0 commit comments

Comments
 (0)