Skip to content

Commit 6dcb1cb

Browse files
committed
Add preferUnstableChannel config option
When set, this sets the environment variable WEBVIEW2_RELEASE_CHANNEL_PREFERENCE to 1, which reverses the default channel search order (i.e. starting with canary and working backwards to stable).
1 parent a824f01 commit 6dcb1cb

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/Config.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ConfigJson LoadConfigJson(const std::string& path)
1010
// Set defaults
1111
ConfigJson ret;
1212
ret.startUrl = "https://github.com/WebView-CG/CanIWebView2";
13+
ret.preferUnstableChannel = false;
1314

1415
// If file does not exist, just use defaults
1516
if (!FileExists(path))
@@ -31,5 +32,8 @@ ConfigJson LoadConfigJson(const std::string& path)
3132
if (parsedJson.contains("startUrl"))
3233
ret.startUrl = parsedJson["startUrl"].get<std::string>();
3334

35+
if (parsedJson.contains("preferUnstableChannel"))
36+
ret.preferUnstableChannel = parsedJson["preferUnstableChannel"].get<bool>();
37+
3438
return ret;
3539
}

src/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
struct ConfigJson {
66
std::string startUrl;
7+
bool preferUnstableChannel;
78
};
89

910
ConfigJson LoadConfigJson(const std::string& path);

src/WebView.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ int CALLBACK WinMain(
3535
std::string configJsonPath = FolderFromPath(GetModulePath()) + "config.json";
3636
ConfigJson configJson = LoadConfigJson(configJsonPath);
3737

38+
// The default channel search order is the WebView2 Runtime, Beta, Dev, and Canary (i.e. stable to unstable).
39+
// When preferUnstableCannel is true in config.json, set the environment variable WEBVIEW2_RELEASE_CHANNEL_PREFERENCE
40+
// to 1 which reverses the channel search order.
41+
if (configJson.preferUnstableChannel)
42+
{
43+
SetEnvironmentVariable(L"WEBVIEW2_RELEASE_CHANNEL_PREFERENCE", L"1");
44+
}
45+
3846
/////////////////////////////////////////////////////
3947
// Register window class
4048
WNDCLASSEX wcex;

0 commit comments

Comments
 (0)