Commit 3808510d authored by Kelvin Jiang's avatar Kelvin Jiang Committed by Commit Bot

[Extensions] Add unpacked location type for extension features

This CL adds a new "unpacked" value which could be specied under the
"location" key for extension features. APIs/events specified as
"unpacked" will only be available for unpacked and command line
extensions.

This change was motivated by the
declarativeNetRequest.OnRuleMatchedDebug event which should only be
available for unpacked extensions.

Bug: 1017934
Change-Id: Iafe0a64160dc4ca083bcf58393aba94a87bfd3a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1892212
Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711807}
parent 58e5ea45
...@@ -253,8 +253,8 @@ Accepted values are lists of strings from `extension`, `hosted_app`, ...@@ -253,8 +253,8 @@ Accepted values are lists of strings from `extension`, `hosted_app`,
The `location` property specifies the required install location of the The `location` property specifies the required install location of the
extension. extension.
Accepted values are a single string from `component`, `external_component`, and Accepted values are a single string from `component`, `external_component`,
`policy`. `policy`, and `unpacked`.
### internal ### internal
......
...@@ -456,6 +456,8 @@ bool SimpleFeature::MatchesManifestLocation( ...@@ -456,6 +456,8 @@ bool SimpleFeature::MatchesManifestLocation(
case SimpleFeature::POLICY_LOCATION: case SimpleFeature::POLICY_LOCATION:
return manifest_location == Manifest::EXTERNAL_POLICY || return manifest_location == Manifest::EXTERNAL_POLICY ||
manifest_location == Manifest::EXTERNAL_POLICY_DOWNLOAD; manifest_location == Manifest::EXTERNAL_POLICY_DOWNLOAD;
case SimpleFeature::UNPACKED_LOCATION:
return Manifest::IsUnpackedLocation(manifest_location);
} }
NOTREACHED(); NOTREACHED();
return false; return false;
......
...@@ -90,6 +90,7 @@ class SimpleFeature : public Feature { ...@@ -90,6 +90,7 @@ class SimpleFeature : public Feature {
COMPONENT_LOCATION, COMPONENT_LOCATION,
EXTERNAL_COMPONENT_LOCATION, EXTERNAL_COMPONENT_LOCATION,
POLICY_LOCATION, POLICY_LOCATION,
UNPACKED_LOCATION,
}; };
// Setters used by generated code to create the feature. // Setters used by generated code to create the feature.
......
...@@ -549,6 +549,8 @@ TEST_F(SimpleFeatureTest, Location) { ...@@ -549,6 +549,8 @@ TEST_F(SimpleFeatureTest, Location) {
Manifest::COMPONENT)); Manifest::COMPONENT));
EXPECT_TRUE( EXPECT_TRUE(
LocationIsAvailable(SimpleFeature::POLICY_LOCATION, Manifest::COMPONENT)); LocationIsAvailable(SimpleFeature::POLICY_LOCATION, Manifest::COMPONENT));
EXPECT_TRUE(LocationIsAvailable(SimpleFeature::UNPACKED_LOCATION,
Manifest::COMPONENT));
// Only component extensions can access the "component" location. // Only component extensions can access the "component" location.
EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION, EXPECT_FALSE(LocationIsAvailable(SimpleFeature::COMPONENT_LOCATION,
...@@ -584,6 +586,15 @@ TEST_F(SimpleFeatureTest, Location) { ...@@ -584,6 +586,15 @@ TEST_F(SimpleFeatureTest, Location) {
// location. // location.
EXPECT_TRUE(LocationIsAvailable(SimpleFeature::EXTERNAL_COMPONENT_LOCATION, EXPECT_TRUE(LocationIsAvailable(SimpleFeature::EXTERNAL_COMPONENT_LOCATION,
Manifest::EXTERNAL_COMPONENT)); Manifest::EXTERNAL_COMPONENT));
// Only unpacked and command line extensions can access the "unpacked"
// location.
EXPECT_TRUE(LocationIsAvailable(SimpleFeature::UNPACKED_LOCATION,
Manifest::UNPACKED));
EXPECT_TRUE(LocationIsAvailable(SimpleFeature::UNPACKED_LOCATION,
Manifest::COMMAND_LINE));
EXPECT_FALSE(LocationIsAvailable(SimpleFeature::UNPACKED_LOCATION,
Manifest::INTERNAL));
} }
TEST_F(SimpleFeatureTest, Platform) { TEST_F(SimpleFeatureTest, Platform) {
......
...@@ -194,6 +194,7 @@ FEATURE_GRAMMAR = ( ...@@ -194,6 +194,7 @@ FEATURE_GRAMMAR = (
'component': 'SimpleFeature::COMPONENT_LOCATION', 'component': 'SimpleFeature::COMPONENT_LOCATION',
'external_component': 'SimpleFeature::EXTERNAL_COMPONENT_LOCATION', 'external_component': 'SimpleFeature::EXTERNAL_COMPONENT_LOCATION',
'policy': 'SimpleFeature::POLICY_LOCATION', 'policy': 'SimpleFeature::POLICY_LOCATION',
'unpacked': 'SimpleFeature::UNPACKED_LOCATION',
} }
} }
}, },
......
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