MicrosoftEdge / MicrosoftEdge/WebView2Feedback

How can I adapt this code to use put_ChannelSearchKind instead of a folder when initialising with Win32?

Open
#5,055 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

@ajtruckle You might just need to point your app to use the Canary WebView2 by following steps here. Initialize your webview2 with CoreWebView2EnvironmentOptions.ChannelSearchKind

Originally posted by @pushkin- in #1737

I would like to adapt my code to use this concept. At the moment I have:

void CWebBrowser::InitializeWebView()
{
	CloseWebView();

	CString subFolder = GetInstallPath();
	CString appData = GetUserDataFolder();

	auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
	CHECK_FAILURE(options->put_AdditionalBrowserArguments(L"--allow-file-access-from-files"));

	HRESULT hr = CreateCoreWebView2EnvironmentWithOptions(
		subFolder,
		appData,
		options.Get(),
		Callback<ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler>(
			this,
			&CWebBrowser::OnCreateEnvironmentCompleted).Get());

	if (!SUCCEEDED(hr))
	{
		CString text;
		if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
		{
			text = L"Cannot found the WebView2 component.";
		}
		else
		{
			text = L"Cannot create the webview environment.";
		}

		ShowFailure(hr, text);
	}
}

I am not sure how to tweak this to use the put_ChannelSearchKind(COREWEBVIEW2_CHANNEL_SEARCH_KIND value) property instead of the folder.

I want to temporarily set it to COREWEBVIEW2_CHANNEL_SEARCH_KIND_LEAST_STABLE.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the Win32 InitializeWebView function shown in the issue and read the linked ICoreWebView2EnvironmentOptions7 documentation for ChannelSearchKind. Check how the options object is passed to CreateCoreWebView2EnvironmentWithOptions. Done means the initialization uses the requested channel-search setting instead of relying on the folder argument.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.