Skip to content

Commit

Permalink
Quota: Add enterprise policy for persistent quota
Browse files Browse the repository at this point in the history
This change adds an enterprise policy to
override persistent quota deprecation.
Available from M106-107.

Bug: 1233525
Change-Id: Ibfc3e18dd30b7fab6d22cada16812982f72c010a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3792355
Reviewed-by: Sergiy Belozorov <sergiyb@chromium.org>
Reviewed-by: Anqing Zhao <anqing@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Commit-Queue: Ayu Ishii <ayui@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1033745}
  • Loading branch information
ayuishii authored and Chromium LUCI CQ committed Aug 10, 2022
1 parent b5e4df6 commit 6401390
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 8 deletions.
5 changes: 5 additions & 0 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,11 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
blink::switches::kWebSQLNonSecureContextEnabled);
}

// Enable persistent quota if enabled by enterprise policy.
if (prefs->GetBoolean(storage::kPersistentQuotaEnabled)) {
command_line->AppendSwitch(blink::switches::kPersistentQuotaEnabled);
}

#if !BUILDFLAG(IS_ANDROID)
InstantService* instant_service =
InstantServiceFactory::GetForProfile(profile);
Expand Down
17 changes: 17 additions & 0 deletions chrome/browser/chrome_content_browser_client_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,23 @@ TEST_F(ChromeContentBrowserClientSwitchTest,
result.HasSwitch(blink::switches::kWebSQLNonSecureContextEnabled));
}

TEST_F(ChromeContentBrowserClientSwitchTest, PersistentQuotaEnabledDefault) {
base::CommandLine result = FetchCommandLineSwitchesForRendererProcess();
EXPECT_FALSE(result.HasSwitch(blink::switches::kPersistentQuotaEnabled));
}

TEST_F(ChromeContentBrowserClientSwitchTest, PersistentQuotaEnabledDisabled) {
profile()->GetPrefs()->SetBoolean(storage::kPersistentQuotaEnabled, false);
base::CommandLine result = FetchCommandLineSwitchesForRendererProcess();
EXPECT_FALSE(result.HasSwitch(blink::switches::kPersistentQuotaEnabled));
}

TEST_F(ChromeContentBrowserClientSwitchTest, PersistentQuotaEnabledEnabled) {
profile()->GetPrefs()->SetBoolean(storage::kPersistentQuotaEnabled, true);
base::CommandLine result = FetchCommandLineSwitchesForRendererProcess();
EXPECT_TRUE(result.HasSwitch(blink::switches::kPersistentQuotaEnabled));
}

#if BUILDFLAG(IS_CHROMEOS)
TEST_F(ChromeContentBrowserClientSwitchTest,
ShouldSetForceAppModeSwitchInRendererProcessIfItIsSetInCurrentProcess) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,9 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
ash::prefs::kUrlParameterToAutofillSAMLUsername,
base::Value::Type::STRING },
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
{ key::kPersistentQuotaEnabled,
storage::kPersistentQuotaEnabled,
base::Value::Type::BOOLEAN },
};
// clang-format on

Expand Down
36 changes: 36 additions & 0 deletions chrome/test/data/policy/policy_test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -19169,5 +19169,41 @@
}
}
]
},
"PersistentQuotaEnabled": {
"os": [
"win",
"linux",
"mac",
"chromeos_ash",
"chromeos_lacros",
"android"
],
"policy_pref_mapping_tests": [
{
"policies": {},
"prefs": {
"policy.persistent_quota_enabled": {
"default_value": false
}
}
},
{
"policies": { "PersistentQuotaEnabled": false },
"prefs": {
"policy.persistent_quota_enabled": {
"value": false
}
}
},
{
"policies": { "PersistentQuotaEnabled": true },
"prefs": {
"policy.persistent_quota_enabled": {
"value": true
}
}
}
]
}
}
35 changes: 33 additions & 2 deletions components/policy/resources/policy_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -32555,7 +32555,38 @@ Regardless of the value, the user will be able to decide whether or not to keep

This policy has no effect if the option to keep existing browsing data is not available; this happens if enterprise profile separation is strictly enforced, or if the data would be from an already managed profile.
''',
}
},
{
'name': 'PersistentQuotaEnabled',
'owners': ['ayui@chromium.org', 'chrome-owp-storage@google.com'],
'type': 'main',
'schema': { 'type': 'boolean' },
'supported_on': ['chrome.*:106-107', 'chrome_os:106-107', 'android:106-107'],
'future_on': ['fuchsia'],
'features': {
'dynamic_refresh' : False,
'per_profile' : True,
},
'items': [
{
'value': True,
'caption': 'Enable persistent quota.',
},
{
'value': False,
'caption': 'Disable persistent quota.',
}
],
'example_value': False,
'default': False,
'id': 1002,
'caption': '''Force persistent quota to be enabled''',
'tags': [],
'desc': '''Starting M106 persistent quota will no longer be supported. This policy will re-enable persistent quota functionality until M107.
If this policy is set to enabled, webkitRequestFileSystem with persistent type will operate with persistent quota.
If this policy is unset or disabled, webkitRequestFileSystem with persistent type will operate with temporary quota.
''',
},
],
'messages': {
# Messages that are not associated to any policies.
Expand Down Expand Up @@ -33561,6 +33592,6 @@ The recommended way to configure policy on Windows is via GPO, although provisio
'placeholders': [],
'deleted_policy_ids': [114, 115, 204, 205, 206, 341, 412, 438, 476, 544, 546, 562, 569, 578, 583, 585, 586, 587, 588, 589, 590, 591, 600, 668, 669, 872],
'deleted_atomic_policy_group_ids': [19],
'highest_id_currently_used': 1001,
'highest_id_currently_used': 1002,
'highest_atomic_group_id_currently_used': 43
}
4 changes: 4 additions & 0 deletions components/services/storage/public/cpp/storage_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ const char kWebSQLAccess[] = "policy.web_sql_access";
const char kWebSQLNonSecureContextEnabled[] =
"policy.web_sql_non_secure_context_enabled";

// Boolean policy to force enable persistent quota.
const char kPersistentQuotaEnabled[] = "policy.persistent_quota_enabled";

void RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(kWebSQLAccess, false);
registry->RegisterBooleanPref(kWebSQLNonSecureContextEnabled, false);
registry->RegisterBooleanPref(kPersistentQuotaEnabled, false);
}

} // namespace storage
2 changes: 2 additions & 0 deletions components/services/storage/public/cpp/storage_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ extern const char kWebSQLAccess[];

extern const char kWebSQLNonSecureContextEnabled[];

extern const char kPersistentQuotaEnabled[];

void RegisterProfilePrefs(PrefRegistrySimple* registry);

} // namespace storage
Expand Down
4 changes: 1 addition & 3 deletions storage/browser/file_system/file_system_quota_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/bind.h"
#include "base/check.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/files/file.h"
#include "base/location.h"
#include "base/sequence_checker.h"
Expand Down Expand Up @@ -64,8 +63,7 @@ base::span<const FileSystemType> QuotaStorageTypeToFileSystemTypes(
blink::mojom::StorageType storage_type) {
using StorageType = blink::mojom::StorageType;

if (base::FeatureList::IsEnabled(
blink::features::kPersistentQuotaIsTemporaryQuota)) {
if (blink::features::IsPersistentQuotaIsTemporaryQuota()) {
DCHECK_NE(storage_type, StorageType::kPersistent);
if (storage_type == StorageType::kTemporary)
return kTemporaryAndPersistent;
Expand Down
4 changes: 1 addition & 3 deletions storage/browser/file_system/file_system_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "storage/browser/file_system/file_system_util.h"

#include "base/feature_list.h"
#include "storage/common/file_system/file_system_types.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/quota/quota_types.mojom.h"
Expand All @@ -13,8 +12,7 @@ namespace storage {

blink::mojom::StorageType FileSystemTypeToQuotaStorageType(
FileSystemType type) {
if (base::FeatureList::IsEnabled(
blink::features::kPersistentQuotaIsTemporaryQuota) &&
if (blink::features::IsPersistentQuotaIsTemporaryQuota() &&
(type == kFileSystemTypeTemporary || type == kFileSystemTypePersistent)) {
return blink::mojom::StorageType::kTemporary;
}
Expand Down
7 changes: 7 additions & 0 deletions third_party/blink/common/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,13 @@ const base::Feature kCORSErrorsIssueOnly{"CORSErrorsIssueOnly",
const base::Feature kPersistentQuotaIsTemporaryQuota{
"PersistentQuotaIsTemporaryQuota", base::FEATURE_DISABLED_BY_DEFAULT};

bool IsPersistentQuotaIsTemporaryQuota() {
return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kPersistentQuotaEnabled) &&
base::FeatureList::IsEnabled(
features::kPersistentQuotaIsTemporaryQuota);
}

const base::Feature kDelayLowPriorityRequestsAccordingToNetworkState{
"DelayLowPriorityRequestsAccordingToNetworkState",
base::FEATURE_DISABLED_BY_DEFAULT};
Expand Down
3 changes: 3 additions & 0 deletions third_party/blink/common/switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,8 @@ extern const char kEventPathPolicy[] = "event-path-policy";
extern const char kEventPathPolicy_ForceDisable[] = "0";
extern const char kEventPathPolicy_ForceEnable[] = "1";

// Controls whether persistent quota is force enabled.
const char kPersistentQuotaEnabled[] = "persistent-quota-enabled";

} // namespace switches
} // namespace blink
1 change: 1 addition & 0 deletions third_party/blink/public/common/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ BLINK_COMMON_EXPORT extern const base::Feature kCORSErrorsIssueOnly;
// Makes Persistent quota the same as Temporary quota.
BLINK_COMMON_EXPORT
extern const base::Feature kPersistentQuotaIsTemporaryQuota;
BLINK_COMMON_EXPORT bool IsPersistentQuotaIsTemporaryQuota();

// If enabled, the ResourceLoadScheculer will take the current network state
// into consideration, when it plans to delay a low-priority throttleable
Expand Down
1 change: 1 addition & 0 deletions third_party/blink/public/common/switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ BLINK_COMMON_EXPORT extern const char kMaxUntiledLayerWidth[];
BLINK_COMMON_EXPORT extern const char kMinHeightForGpuRasterTile[];
BLINK_COMMON_EXPORT extern const char kNetworkQuietTimeout[];
BLINK_COMMON_EXPORT extern const char kNumRasterThreads[];
BLINK_COMMON_EXPORT extern const char kPersistentQuotaEnabled[];
BLINK_COMMON_EXPORT extern const char kSetTimeoutWithout1MsClampPolicy[];
BLINK_COMMON_EXPORT extern const char
kSetTimeoutWithout1MsClampPolicy_ForceDisable[];
Expand Down
1 change: 1 addition & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32147,6 +32147,7 @@ Called by update_document_policy_enum.py.-->
<int value="999" label="KerberosDomainAutocomplete"/>
<int value="1000" label="KerberosDefaultConfiguration"/>
<int value="1001" label="UnmanagedDeviceSignalsConsentFlowEnabled"/>
<int value="1002" label="PersistentQuotaEnabled"/>
</enum>

<enum name="EnterprisePoliciesSources">
Expand Down

0 comments on commit 6401390

Please sign in to comment.