Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft API Review] Origin Settings #4771

Open
wants to merge 1 commit into
base: dianaqu/origin-setting-api
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions specs/OriginSettings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
Origin Settings
===

# Background
Purpose of this API is to provide devloper the ability to control different security related
features by origins. Developer can chose to trust a origin, for example 'microsoft.com' and
toggle differnt security features for this origin. If user navigate to such origin, settings
like auto audio play can be applied.

# Examples
## WinRT and .NET
```c#

```

## Win32 C++
```cpp

```

# API Notes

See [API Details](#api-details) section below for API reference.

# API Details
## Win32 C++

```c++
interface ICoreWebView2OriginSetting;
interface ICoreWebView2Profile21;

[v1_enum]
typedef enum COREWEBVIEW2_ORIGIN_SETTING_STATE {
COREWEBVIEW2_ORIGIN_SETTING_STATE_DEFAULT,
COREWEBVIEW2_ORIGIN_SETTING_STATE_ON,
COREWEBVIEW2_ORIGIN_SETTING_STATE_OFF,
} COREWEBVIEW2_ORIGIN_SETTING_STATE;


[uuid(e8240179-1b27-5ce2-84b2-ea187e3e91ec), object, pointer_default(unique)]
interface ICoreWebView2OriginSetting : IUnknown {
// Origins that match a certain pattern
[propget] HRESULT OriginMatch([out, retval] LPWSTR* value);
[propput] HRESULT OriginMatch([in] LPCWSTR value);

// Growing list of features that developer can decide to toggle the state.
// Once enable, uri matching the above origin will grant developer the ability to accessing these features.
// All feature default to be disabled by default.
[propget] HRESULT EnhancedSecurityMode([out, retval] COREWEBVIEW2_ORIGIN_SETTING_STATE* value);
[propput] HRESULT EnhancedSecurityMode([in] COREWEBVIEW2_ORIGIN_SETTING_STATE value);
[propget] HRESULT SmartScreen([out, retval] COREWEBVIEW2_ORIGIN_SETTING_STATE* value);
[propput] HRESULT SmartScreen([in] COREWEBVIEW2_ORIGIN_SETTING_STATE value);
[propget] HRESULT SystemAccentColor([out, retval] COREWEBVIEW2_ORIGIN_SETTING_STATE* value);
[propput] HRESULT SystemAccentColor([in] COREWEBVIEW2_ORIGIN_SETTING_STATE value);
[propget] HRESULT MediaAutoPlay([out, retval] COREWEBVIEW2_ORIGIN_SETTING_STATE* value);
[propput] HRESULT MediaAutoPlay([in] COREWEBVIEW2_ORIGIN_SETTING_STATE value);
}

[uuid(558ba548-eb04-4d92-9207-3b1c838878bd), object, pointer_default(unique)]
interface ICoreWebView2Profile21 : IUnknown {
// Array of origin settings.
HRESULT GetOriginSettings(
[out] UINT32* count,
[out] ICoreWebView2OriginSetting*** originSettings);
// Set the array of origin settings to use.
HRESULT SetOriginSettings(
[in] UINT32 count,
[in] const ICoreWebView2OriginSetting** originSettings);
}
```

## .NET and WinRT

```c#
namespace Microsoft.Web.WebView2.Core
{
// ...

enum CoreWebView2OriginSettingState
{
Default = 0,
On = 1,
Off = 2,
};

runtimeclass CoreWebView2Profile
{
IVector<CoreWebView2OriginSetting> OriginSettings { get; set; };

// ...
}

runtimeclass CoreWebView2OriginSetting
{
String OriginMatch { get; };
CoreWebView2OriginSettingState EnhancedSecurityMode { get; set; };
CoreWebView2OriginSettingState SmartScreen { get; set; };
CoreWebView2OriginSettingState SystemAccentColor { get; set; };
CoreWebView2OriginSettingState MediaAutoPlay { get; set; };
}

// ...
}
```