7#define CORE_WEBVIEW_TARGET_PRODUCT_VERSION L"118.0.2088.41" 
    9#define COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(p) \ 
   12    HRESULT STDMETHODCALLTYPE get_##p(LPWSTR* value) override \ 
   16        *value = m_##p.Copy(); \ 
   17        if ((*value == nullptr) && (m_##p.Get() != nullptr)) \ 
   18            return HRESULT_FROM_WIN32(GetLastError()); \ 
   21    HRESULT STDMETHODCALLTYPE put_##p(LPCWSTR value) override \ 
   23        LPCWSTR result = m_##p.Set(value); \ 
   24        if ((result == nullptr) && (value != nullptr)) \ 
   25            return HRESULT_FROM_WIN32(GetLastError()); \ 
   30    AutoCoMemString m_##p; 
 
   32#define COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(p, defPVal) \ 
   35    HRESULT STDMETHODCALLTYPE get_##p(BOOL* value) override \ 
   42    HRESULT STDMETHODCALLTYPE put_##p(BOOL value) override \ 
   49    BOOL m_##p = defPVal ? TRUE : FALSE; 
 
   51#define DEFINE_AUTO_COMEM_STRING() \ 
   54    class AutoCoMemString \ 
   67                deallocate_fn(m_string); \ 
   72        LPCWSTR Set(LPCWSTR str) \ 
   77                m_string = MakeCoMemString(str); \ 
   88                return MakeCoMemString(m_string); \ 
   93        LPWSTR MakeCoMemString(LPCWSTR source) \ 
   95            const size_t length = wcslen(source); \ 
   96            const size_t bytes = (length + 1) * sizeof(*source); \ 
   98            if (bytes <= length) \ 
  103            wchar_t* result = reinterpret_cast<wchar_t*>(allocate_fn(bytes)); \ 
  106                memcpy(result, source, bytes); \ 
  109        LPWSTR m_string = nullptr; \ 
 
  112template <
typename allocate_fn_t, allocate_fn_t allocate_fn, 
typename deallocate_fn_t, deallocate_fn_t deallocate_fn>
 
  115          Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
 
  116          ICoreWebView2CustomSchemeRegistration>
 
  135        if ((*schemeName == 
nullptr) && (
m_schemeName.Get() != 
nullptr))
 
  136            return HRESULT_FROM_WIN32(GetLastError());
 
 
  140    HRESULT STDMETHODCALLTYPE 
GetAllowedOrigins(UINT32* allowedOriginsCount, LPWSTR** allowedOrigins)
 override 
  142        if (!allowedOrigins || !allowedOriginsCount)
 
  146        *allowedOriginsCount = 0;
 
  149            *allowedOrigins = 
nullptr;
 
  155            if (!(*allowedOrigins))
 
  157                return HRESULT_FROM_WIN32(GetLastError());
 
  163                if (!(*allowedOrigins)[i])
 
  165                    HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
 
  166                    for (UINT32 j = 0; j < i; j++)
 
  168                        deallocate_fn((*allowedOrigins)[j]);
 
  170                    deallocate_fn(*allowedOrigins);
 
 
  179    HRESULT STDMETHODCALLTYPE 
SetAllowedOrigins(UINT32 allowedOriginsCount, LPCWSTR* allowedOrigins)
 override 
  182        if (allowedOriginsCount == 0)
 
  191                return HRESULT_FROM_WIN32(GetLastError());
 
  193            for (UINT32 i = 0; i < allowedOriginsCount; i++)
 
  198                    HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
 
  199                    for (UINT32 j = 0; j < i; j++)
 
 
 
  233template <typename allocate_fn_t, allocate_fn_t allocate_fn, typename deallocate_fn_t, deallocate_fn_t deallocate_fn>
 
  237          ICoreWebView2EnvironmentOptions,
 
  238          ICoreWebView2EnvironmentOptions2,
 
  239          ICoreWebView2EnvironmentOptions3,
 
  240          ICoreWebView2EnvironmentOptions4,
 
  241          ICoreWebView2EnvironmentOptions5>
 
  254        ReleaseCustomSchemeRegistrations();
 
 
  259        if (m_customSchemeRegistrations)
 
  261            for (UINT32 i = 0; i < m_customSchemeRegistrationsCount; i++)
 
  263                m_customSchemeRegistrations[i]->Release();
 
  265            deallocate_fn(m_customSchemeRegistrations);
 
  266            m_customSchemeRegistrations = 
nullptr;
 
  267            m_customSchemeRegistrationsCount = 0;
 
 
  272    ICoreWebView2CustomSchemeRegistration** m_customSchemeRegistrations = 
nullptr;
 
  273    unsigned int m_customSchemeRegistrationsCount = 0;
 
  293    HRESULT STDMETHODCALLTYPE
 
  294    GetCustomSchemeRegistrations(UINT32* count, ICoreWebView2CustomSchemeRegistration*** schemeRegistrations)
 override 
  296        if (!count || !schemeRegistrations)
 
  301        if (m_customSchemeRegistrationsCount == 0)
 
  303            *schemeRegistrations = 
nullptr;
 
  308            *schemeRegistrations = 
reinterpret_cast<ICoreWebView2CustomSchemeRegistration**
>(
 
  309                allocate_fn(
sizeof(ICoreWebView2CustomSchemeRegistration*) * m_customSchemeRegistrationsCount));
 
  310            if (!*schemeRegistrations)
 
  312                return HRESULT_FROM_WIN32(GetLastError());
 
  314            for (UINT32 i = 0; i < m_customSchemeRegistrationsCount; i++)
 
  316                (*schemeRegistrations)[i] = m_customSchemeRegistrations[i];
 
  317                (*schemeRegistrations)[i]->AddRef();
 
  319            *count = m_customSchemeRegistrationsCount;
 
 
  324    HRESULT STDMETHODCALLTYPE
 
  327        ReleaseCustomSchemeRegistrations();
 
  328        m_customSchemeRegistrations = 
reinterpret_cast<ICoreWebView2CustomSchemeRegistration**
>(
 
  329            allocate_fn(
sizeof(ICoreWebView2CustomSchemeRegistration*) * count));
 
  330        if (!m_customSchemeRegistrations)
 
  332            return static_cast<HRESULT
>(GetLastError());
 
  334        for (UINT32 i = 0; i < count; i++)
 
  336            m_customSchemeRegistrations[i] = schemeRegistrations[i];
 
  337            m_customSchemeRegistrations[i]->AddRef();
 
  339        m_customSchemeRegistrationsCount = count;
 
 
 
  347template <
typename allocate_fn_t, allocate_fn_t allocate_fn, 
typename deallocate_fn_t, deallocate_fn_t deallocate_fn>
 
  350          Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
 
  351          CoreWebView2EnvironmentOptionsBase<allocate_fn_t, allocate_fn, deallocate_fn_t, deallocate_fn>>
 
 
  363    decltype(&::CoTaskMemAlloc),
 
  365    decltype(&::CoTaskMemFree),
 
  370    decltype(&::CoTaskMemAlloc),
 
  372    decltype(&::CoTaskMemFree),
 
Definition webview2_environment_options.hpp:117
HRESULT STDMETHODCALLTYPE SetAllowedOrigins(UINT32 allowedOriginsCount, LPCWSTR *allowedOrigins) override
Definition webview2_environment_options.hpp:179
AutoCoMemString * m_allowedOrigins
Definition webview2_environment_options.hpp:228
HRESULT STDMETHODCALLTYPE GetAllowedOrigins(UINT32 *allowedOriginsCount, LPWSTR **allowedOrigins) override
Definition webview2_environment_options.hpp:140
AutoCoMemString m_schemeName
Definition webview2_environment_options.hpp:225
~CoreWebView2CustomSchemeRegistrationBase()
Definition webview2_environment_options.hpp:125
CoreWebView2CustomSchemeRegistrationBase(LPCWSTR schemeName)
Definition webview2_environment_options.hpp:119
void ReleaseAllowedOrigins()
Definition webview2_environment_options.hpp:216
CoreWebView2CustomSchemeRegistrationBase(CoreWebView2CustomSchemeRegistrationBase &&)=default
HRESULT STDMETHODCALLTYPE get_SchemeName(LPWSTR *schemeName) override
Definition webview2_environment_options.hpp:130
unsigned int m_allowedOriginsCount
Definition webview2_environment_options.hpp:229
Definition webview2_environment_options.hpp:352
~CoreWebView2EnvironmentOptionsBaseClass() override
Definition webview2_environment_options.hpp:358
CoreWebView2EnvironmentOptionsBaseClass()
Definition webview2_environment_options.hpp:354
Definition webview2_environment_options.hpp:242
void ReleaseCustomSchemeRegistrations()
Definition webview2_environment_options.hpp:257
~CoreWebView2EnvironmentOptionsBase()
Definition webview2_environment_options.hpp:252
CoreWebView2EnvironmentOptionsBase()
Definition webview2_environment_options.hpp:244
HRESULT STDMETHODCALLTYPE SetCustomSchemeRegistrations(UINT32 count, ICoreWebView2CustomSchemeRegistration **schemeRegistrations) override
Definition webview2_environment_options.hpp:325
Definition implements.h:2422
This file has no copyright assigned and is placed in the Public Domain.
Definition client.h:26
#define COREWEBVIEW2ENVIRONMENTOPTIONS_BOOL_PROPERTY(p, defPVal)
Definition webview2_environment_options.hpp:32
CoreWebView2CustomSchemeRegistrationBase< decltype(&::CoTaskMemAlloc), ::CoTaskMemAlloc, decltype(&::CoTaskMemFree), ::CoTaskMemFree > CoreWebView2CustomSchemeRegistration
Definition webview2_environment_options.hpp:367
CoreWebView2EnvironmentOptionsBaseClass< decltype(&::CoTaskMemAlloc), ::CoTaskMemAlloc, decltype(&::CoTaskMemFree), ::CoTaskMemFree > CoreWebView2EnvironmentOptions
Definition webview2_environment_options.hpp:374
#define CORE_WEBVIEW_TARGET_PRODUCT_VERSION
Definition webview2_environment_options.hpp:7
#define DEFINE_AUTO_COMEM_STRING()
Definition webview2_environment_options.hpp:51
#define COREWEBVIEW2ENVIRONMENTOPTIONS_STRING_PROPERTY(p)
Definition webview2_environment_options.hpp:9