-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20d1d66
commit 3e66324
Showing
18 changed files
with
192 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 18 additions & 13 deletions
31
src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#include "pch.h" | ||
#include "winget/Experiment.h" | ||
#include "winget/UserSettings.h" | ||
#include "Experiment/Experiment.h" | ||
|
||
namespace AppInstaller::Settings | ||
{ | ||
namespace | ||
{ | ||
bool IsEnabledInternal(Experiment::Key key, const UserSettings& userSettings) | ||
{ | ||
if (key == Experiment::Key::None) | ||
{ | ||
return true; | ||
} | ||
|
||
if (!GroupPolicies().IsEnabled(TogglePolicy::Policy::Experiments)) | ||
{ | ||
AICLI_LOG(Core, Info, << | ||
"Experiments '" << Experiment::GetExperiment(key).Name() << | ||
"' is disabled due to group policy: " << TogglePolicy::GetPolicy(TogglePolicy::Policy::Experiments).RegValueName()); | ||
return false; | ||
} | ||
|
||
auto experiments = userSettings.Get<Setting::Experiments>(); | ||
auto experiment = Experiment::GetExperiment(key); | ||
auto jsonName = std::string(experiment.JsonName()); | ||
if (experiments.find(jsonName) != experiments.end()) | ||
{ | ||
return experiments[jsonName]; | ||
} | ||
|
||
return AppInstaller::Experiment::IsEnabled(experiment.GetKey()); | ||
} | ||
} | ||
|
||
bool Experiment::IsEnabled(Key key) | ||
{ | ||
return IsEnabledInternal(key, User()); | ||
} | ||
|
||
Experiment Experiment::GetExperiment(Key key) | ||
{ | ||
switch (key) | ||
{ | ||
case Key::CDN: | ||
return Experiment{ "CDN experiment", "CDN", "https://aka.ms/winget-settings", "CDN"}; | ||
|
||
default: | ||
THROW_HR(E_UNEXPECTED); | ||
} | ||
} | ||
|
||
std::vector<Experiment> Experiment::GetAllExperiments() | ||
{ | ||
std::vector<Experiment> result; | ||
|
||
for (Key_t i = 0x1; i < static_cast<Key_t>(Key::Max); i = i << 1) | ||
{ | ||
result.emplace_back(GetExperiment(static_cast<Key>(i))); | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
#pragma once | ||
#include <string> | ||
#include <type_traits> | ||
#include "AppInstallerStrings.h" | ||
|
||
namespace AppInstaller::Settings | ||
{ | ||
struct Experiment | ||
{ | ||
enum class Key : unsigned | ||
{ | ||
None = 0x0, | ||
CDN = 0x1, | ||
Max, | ||
}; | ||
|
||
using Key_t = std::underlying_type_t<Key>; | ||
|
||
Experiment(std::string_view name, std::string_view jsonName, std::string_view link, std::string key) : | ||
m_name(name), m_jsonName(jsonName), m_link(link), m_key(key) {} | ||
|
||
static bool IsEnabled(Key feature); | ||
|
||
static Experiment GetExperiment(Experiment::Key key); | ||
static std::vector<Experiment> GetAllExperiments(); | ||
|
||
std::string_view Name() const { return m_name; } | ||
Utility::LocIndView JsonName() const { return m_jsonName; } | ||
std::string_view Link() const { return m_link; } | ||
std::string GetKey() const { return m_key; } | ||
|
||
private: | ||
std::string_view m_name; | ||
Utility::LocIndView m_jsonName; | ||
std::string_view m_link; | ||
std::string m_key; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
src/PowerShell/Microsoft.WinGet.SharedLib/Resources/GroupPolicyResource.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters