| Index: chrome/browser/policy/policy_browsertest.cc
|
| diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
|
| index acdd3199584eb5273ae333acaa7c1539fcaeff4a..73ccbdee42121e0a89980afdd98cdb425c595d98 100644
|
| --- a/chrome/browser/policy/policy_browsertest.cc
|
| +++ b/chrome/browser/policy/policy_browsertest.cc
|
| @@ -881,13 +881,13 @@ class PolicyTest : public InProcessBrowserTest {
|
| void ApplySafeSearchPolicy(
|
| std::unique_ptr<base::FundamentalValue> legacy_safe_search,
|
| std::unique_ptr<base::FundamentalValue> google_safe_search,
|
| - std::unique_ptr<base::FundamentalValue> youtube_safety_mode) {
|
| + std::unique_ptr<base::FundamentalValue> youtube_restrict) {
|
| PolicyMap policies;
|
| SetPolicy(&policies, key::kForceSafeSearch, std::move(legacy_safe_search));
|
| SetPolicy(&policies, key::kForceGoogleSafeSearch,
|
| std::move(google_safe_search));
|
| - SetPolicy(&policies, key::kForceYouTubeSafetyMode,
|
| - std::move(youtube_safety_mode));
|
| + SetPolicy(&policies, key::kForceYouTubeRestrict,
|
| + std::move(youtube_restrict));
|
| UpdateProviderPolicy(policies);
|
| }
|
|
|
| @@ -1172,20 +1172,27 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ForceSafeSearch) {
|
| // First check that nothing happens.
|
| CheckSafeSearch(false);
|
|
|
| - // Go over all combinations of (undefined,true,false) for the three policies.
|
| - for (int i = 0; i < 3 * 3 * 3; i++) {
|
| - int legacy = i % 3;
|
| - int google = (i / 3) % 3;
|
| - int youtube = i / (3 * 3);
|
| + // Go over all combinations of (undefined,true,false) resp.
|
| + // (undefined, off, moderate, strict) for the three policies.
|
| + for (int i = 0; i < 3 * 3 * 4; i++) {
|
| + int val = i;
|
| + int legacy = val % 3; val /= 3;
|
| + int google = val % 3; val /= 3;
|
| + int youtube = val % 4;
|
|
|
| // Override the default SafeSearch setting using policies.
|
| + static_assert(safe_search_util::YTRM_OFF == 0 &&
|
| + safe_search_util::YTRM_MODERATE == 1 &&
|
| + safe_search_util::YTRM_STRICT == 2,
|
| + "Adjust 'youtube' to match YTRM enum");
|
| +
|
| ApplySafeSearchPolicy(
|
| - legacy == 0 ? nullptr
|
| - : base::WrapUnique(new base::FundamentalValue(legacy == 1)),
|
| - google == 0 ? nullptr
|
| - : base::WrapUnique(new base::FundamentalValue(google == 1)),
|
| - youtube == 0 ? nullptr : base::WrapUnique(
|
| - new base::FundamentalValue(youtube == 1)));
|
| + legacy == 0 ? nullptr
|
| + : base::WrapUnique(new base::FundamentalValue(legacy == 1)),
|
| + google == 0 ? nullptr
|
| + : base::WrapUnique(new base::FundamentalValue(google == 1)),
|
| + youtube == 0 ? nullptr // subtracting 1 gives 0,1,2, see above
|
| + : base::WrapUnique(new base::FundamentalValue(youtube - 1)));
|
|
|
| // The legacy policy should only have an effect if both google and youtube
|
| // are undefined.
|
| @@ -1199,9 +1206,14 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, ForceSafeSearch) {
|
| prefs->GetBoolean(prefs::kForceGoogleSafeSearch));
|
|
|
| EXPECT_EQ(youtube != 0 || legacy_in_effect,
|
| - prefs->IsManagedPreference(prefs::kForceYouTubeSafetyMode));
|
| - EXPECT_EQ(youtube == 1 || legacy_enabled,
|
| - prefs->GetBoolean(prefs::kForceYouTubeSafetyMode));
|
| + prefs->IsManagedPreference(prefs::kForceYouTubeRestrict));
|
| + EXPECT_EQ(youtube != 0,
|
| + prefs->GetInteger(prefs::kForceYouTubeRestrict) == youtube - 1);
|
| +
|
| + // The legacy safe search policy should result in Moderate strictness
|
| + if (youtube == 0 && legacy_enabled)
|
| + EXPECT_EQ(prefs->GetInteger(prefs::kForceYouTubeRestrict),
|
| + safe_search_util::YTRM_MODERATE);
|
|
|
| CheckSafeSearch(google == 1 || legacy_enabled);
|
| }
|
|
|