Commit 530bfb5b authored by cfredric's avatar cfredric Committed by Chromium LUCI CQ

Add an InstallerAttribute and FeatureParam for dogfooding

FirstPartySets.

Change-Id: Ic63b56cc0e6c425b950975a65ece8e1085a8447e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627094
Commit-Queue: Chris Fredrickson <cfredric@chromium.org>
Reviewed-by: default avatarEric Orth <ericorth@chromium.org>
Reviewed-by: default avatarLily Chen <chlily@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843667}
parent 4ae86448
...@@ -96,6 +96,10 @@ FirstPartySetsComponentInstallerPolicy::FirstPartySetsComponentInstallerPolicy( ...@@ -96,6 +96,10 @@ FirstPartySetsComponentInstallerPolicy::FirstPartySetsComponentInstallerPolicy(
FirstPartySetsComponentInstallerPolicy:: FirstPartySetsComponentInstallerPolicy::
~FirstPartySetsComponentInstallerPolicy() = default; ~FirstPartySetsComponentInstallerPolicy() = default;
const char
FirstPartySetsComponentInstallerPolicy::kDogfoodInstallerAttributeName[] =
"_internal_experimental_sets";
bool FirstPartySetsComponentInstallerPolicy:: bool FirstPartySetsComponentInstallerPolicy::
SupportsGroupPolicyEnabledComponentUpdates() const { SupportsGroupPolicyEnabledComponentUpdates() const {
// False since this is a data, non-binary component. // False since this is a data, non-binary component.
...@@ -164,7 +168,12 @@ std::string FirstPartySetsComponentInstallerPolicy::GetName() const { ...@@ -164,7 +168,12 @@ std::string FirstPartySetsComponentInstallerPolicy::GetName() const {
update_client::InstallerAttributes update_client::InstallerAttributes
FirstPartySetsComponentInstallerPolicy::GetInstallerAttributes() const { FirstPartySetsComponentInstallerPolicy::GetInstallerAttributes() const {
return update_client::InstallerAttributes(); return {
{
kDogfoodInstallerAttributeName,
net::features::kFirstPartySetsIsDogfooder.Get() ? "true" : "false",
},
};
} }
std::vector<std::string> FirstPartySetsComponentInstallerPolicy::GetMimeTypes() std::vector<std::string> FirstPartySetsComponentInstallerPolicy::GetMimeTypes()
......
...@@ -41,11 +41,19 @@ class FirstPartySetsComponentInstallerPolicy : public ComponentInstallerPolicy { ...@@ -41,11 +41,19 @@ class FirstPartySetsComponentInstallerPolicy : public ComponentInstallerPolicy {
static void ReconfigureAfterNetworkRestart( static void ReconfigureAfterNetworkRestart(
const base::RepeatingCallback<void(const std::string&)>&); const base::RepeatingCallback<void(const std::string&)>&);
static const char kDogfoodInstallerAttributeName[];
private: private:
FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest, FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest,
LoadsSets_OnComponentReady); LoadsSets_OnComponentReady);
FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest, FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest,
LoadsSets_OnNetworkRestart); LoadsSets_OnNetworkRestart);
FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest,
GetInstallerAttributes_Disabled);
FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest,
GetInstallerAttributes_NonDogfooder);
FRIEND_TEST_ALL_PREFIXES(FirstPartySetsComponentInstallerTest,
GetInstallerAttributes_Dogfooder);
// The following methods override ComponentInstallerPolicy. // The following methods override ComponentInstallerPolicy.
bool SupportsGroupPolicyEnabledComponentUpdates() const override; bool SupportsGroupPolicyEnabledComponentUpdates() const override;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "chrome/browser/component_updater/first_party_sets_component_installer.h" #include "chrome/browser/component_updater/first_party_sets_component_installer.h"
#include "base/callback_helpers.h"
#include "base/files/file_util.h" #include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h" #include "base/run_loop.h"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
#include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_browser_process.h"
#include "components/component_updater/mock_component_updater_service.h" #include "components/component_updater/mock_component_updater_service.h"
#include "net/base/features.h" #include "net/base/features.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -24,6 +26,8 @@ namespace component_updater { ...@@ -24,6 +26,8 @@ namespace component_updater {
namespace { namespace {
using ::testing::_; using ::testing::_;
using ::testing::Pair;
using ::testing::UnorderedElementsAre;
} // namespace } // namespace
class FirstPartySetsComponentInstallerTest : public ::testing::Test { class FirstPartySetsComponentInstallerTest : public ::testing::Test {
...@@ -112,4 +116,48 @@ TEST_F(FirstPartySetsComponentInstallerTest, LoadsSets_OnNetworkRestart) { ...@@ -112,4 +116,48 @@ TEST_F(FirstPartySetsComponentInstallerTest, LoadsSets_OnNetworkRestart) {
} }
} }
TEST_F(FirstPartySetsComponentInstallerTest, GetInstallerAttributes_Disabled) {
scoped_feature_list_.Reset();
scoped_feature_list_.InitAndDisableFeature(net::features::kFirstPartySets);
FirstPartySetsComponentInstallerPolicy policy(
base::DoNothing::Repeatedly<const std::string&>());
EXPECT_THAT(policy.GetInstallerAttributes(),
UnorderedElementsAre(Pair(FirstPartySetsComponentInstallerPolicy::
kDogfoodInstallerAttributeName,
"false")));
}
TEST_F(FirstPartySetsComponentInstallerTest,
GetInstallerAttributes_NonDogfooder) {
scoped_feature_list_.Reset();
scoped_feature_list_.InitAndEnableFeatureWithParameters(
net::features::kFirstPartySets,
{{net::features::kFirstPartySetsIsDogfooder.name, "false"}});
FirstPartySetsComponentInstallerPolicy policy(
base::DoNothing::Repeatedly<const std::string&>());
EXPECT_THAT(policy.GetInstallerAttributes(),
UnorderedElementsAre(Pair(FirstPartySetsComponentInstallerPolicy::
kDogfoodInstallerAttributeName,
"false")));
}
TEST_F(FirstPartySetsComponentInstallerTest, GetInstallerAttributes_Dogfooder) {
scoped_feature_list_.Reset();
scoped_feature_list_.InitAndEnableFeatureWithParameters(
net::features::kFirstPartySets,
{{net::features::kFirstPartySetsIsDogfooder.name, "true"}});
FirstPartySetsComponentInstallerPolicy policy(
base::DoNothing::Repeatedly<const std::string&>());
EXPECT_THAT(policy.GetInstallerAttributes(),
UnorderedElementsAre(Pair(FirstPartySetsComponentInstallerPolicy::
kDogfoodInstallerAttributeName,
"true")));
}
} // namespace component_updater } // namespace component_updater
...@@ -195,5 +195,9 @@ extern const base::FeatureParam<base::TimeDelta> kTimeoutTcpConnectAttemptMax( ...@@ -195,5 +195,9 @@ extern const base::FeatureParam<base::TimeDelta> kTimeoutTcpConnectAttemptMax(
constexpr base::Feature kFirstPartySets{"FirstPartySets", constexpr base::Feature kFirstPartySets{"FirstPartySets",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::FeatureParam<bool> kFirstPartySetsIsDogfooder{
&kFirstPartySets, "FirstPartySetsIsDogfooder", false};
} // namespace features } // namespace features
} // namespace net } // namespace net
...@@ -290,6 +290,10 @@ NET_EXPORT extern const base::FeatureParam<base::TimeDelta> ...@@ -290,6 +290,10 @@ NET_EXPORT extern const base::FeatureParam<base::TimeDelta>
// Enables usage of First Party Sets to determine cookie availability. // Enables usage of First Party Sets to determine cookie availability.
NET_EXPORT extern const base::Feature kFirstPartySets; NET_EXPORT extern const base::Feature kFirstPartySets;
// Controls whether the client is considered a dogfooder for the FirstPartySets
// feature.
NET_EXPORT extern const base::FeatureParam<bool> kFirstPartySetsIsDogfooder;
} // namespace features } // namespace features
} // namespace net } // namespace net
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment