MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Browser / CreateBrowserControlsWebView

Method CreateBrowserControlsWebView

BrowserWindow.cpp:237–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237HRESULT BrowserWindow::CreateBrowserControlsWebView()
238{
239 return m_uiEnv->CreateCoreWebView2Controller(m_hWnd, Callback<ICoreWebView2CreateCoreWebView2ControllerCompletedHandler>(
240 [this](HRESULT result, ICoreWebView2Controller* host) -> HRESULT
241 {
242 if (!SUCCEEDED(result))
243 {
244 OutputDebugString(L"Controls WebView creation failed\n");
245 return result;
246 }
247 // WebView created
248 m_controlsController = host;
249 CheckFailure(m_controlsController->get_CoreWebView2(&m_controlsWebView), L"");
250
251 wil::com_ptr<ICoreWebView2Settings> settings;
252 RETURN_IF_FAILED(m_controlsWebView->get_Settings(&settings));
253 RETURN_IF_FAILED(settings->put_AreDevToolsEnabled(FALSE));
254
255 RETURN_IF_FAILED(m_controlsController->add_ZoomFactorChanged(Callback<ICoreWebView2ZoomFactorChangedEventHandler>(
256 [](ICoreWebView2Controller* host, IUnknown* args) -> HRESULT
257 {
258 host->put_ZoomFactor(1.0);
259 return S_OK;
260 }
261 ).Get(), &m_controlsZoomToken));
262
263 RETURN_IF_FAILED(m_controlsWebView->add_WebMessageReceived(m_uiMessageBroker.Get(), &m_controlsUIMessageBrokerToken));
264 RETURN_IF_FAILED(ResizeUIWebViews());
265
266 std::wstring controlsPath = GetFullPathFor(L"wvbrowser_ui\\controls_ui\\default.html");
267 RETURN_IF_FAILED(m_controlsWebView->Navigate(controlsPath.c_str()));
268
269 return S_OK;
270 }).Get());
271}
272
273HRESULT BrowserWindow::CreateBrowserOptionsWebView()
274{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected