Commit 27cdb41a authored by Istiaque Ahmed's avatar Istiaque Ahmed Committed by Commit Bot

[Extensions] Change GetIndexedRulesetPath to return relative path.

This allows ContentVerifier::ShouldVerifyAnyPaths to compare
relative paths against indexed ruleset's relative path in future. This
will obviate the need to construct full path (which can be tricky some
times). Note that this will be done in a follow up.

Bug: 796395
Test: No behavior changes expected.
Change-Id: I05febe27eb52c2c823e6e609f1be6d9803b471bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071335Reviewed-by: default avatarOleg Davydov <burunduk@chromium.org>
Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744287}
parent e1634397
...@@ -157,8 +157,9 @@ class RuleIndexingTest : public DNRTestBase { ...@@ -157,8 +157,9 @@ class RuleIndexingTest : public DNRTestBase {
if (persist_initial_indexed_ruleset_) { if (persist_initial_indexed_ruleset_) {
std::string data = "user ruleset"; std::string data = "user ruleset";
base::WriteFile(file_util::GetIndexedRulesetPath(extension_dir_), base::WriteFile(
data.c_str(), data.size()); extension_dir_.Append(file_util::GetIndexedRulesetRelativePath()),
data.c_str(), data.size());
} }
} }
......
...@@ -232,9 +232,9 @@ const size_t RulesetSource::kDynamicRulesetID = 2; ...@@ -232,9 +232,9 @@ const size_t RulesetSource::kDynamicRulesetID = 2;
RulesetSource RulesetSource::CreateStatic(const Extension& extension) { RulesetSource RulesetSource::CreateStatic(const Extension& extension) {
return RulesetSource( return RulesetSource(
declarative_net_request::DNRManifestData::GetRulesetPath(extension), declarative_net_request::DNRManifestData::GetRulesetPath(extension),
file_util::GetIndexedRulesetPath(extension.path()), kStaticRulesetID, extension.path().Append(file_util::GetIndexedRulesetRelativePath()),
dnr_api::SOURCE_TYPE_MANIFEST, dnr_api::MAX_NUMBER_OF_RULES, kStaticRulesetID, dnr_api::SOURCE_TYPE_MANIFEST,
extension.id()); dnr_api::MAX_NUMBER_OF_RULES, extension.id());
} }
// static // static
......
...@@ -716,8 +716,10 @@ bool ContentVerifier::ShouldVerifyAnyPaths( ...@@ -716,8 +716,10 @@ bool ContentVerifier::ShouldVerifyAnyPaths(
base::FilePath relative_path = relative_unix_path.NormalizePathSeparators(); base::FilePath relative_path = relative_unix_path.NormalizePathSeparators();
base::FilePath full_path = extension_root.Append(relative_path); base::FilePath full_path = extension_root.Append(relative_path);
if (full_path == file_util::GetIndexedRulesetPath(extension_root)) if (full_path ==
extension_root.Append(file_util::GetIndexedRulesetRelativePath())) {
continue; continue;
}
if (locales_relative_dir.IsParent(relative_path)) { if (locales_relative_dir.IsParent(relative_path)) {
if (!all_locales) { if (!all_locales) {
......
...@@ -585,17 +585,15 @@ base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) { ...@@ -585,17 +585,15 @@ base::FilePath GetVerifiedContentsPath(const base::FilePath& extension_path) {
base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) { base::FilePath GetComputedHashesPath(const base::FilePath& extension_path) {
return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename); return extension_path.Append(kMetadataFolder).Append(kComputedHashesFilename);
} }
base::FilePath GetIndexedRulesetPath(const base::FilePath& extension_path) { base::FilePath GetIndexedRulesetRelativePath() {
return extension_path.Append(kMetadataFolder).Append(kIndexedRulesetFilename); return base::FilePath(kMetadataFolder).Append(kIndexedRulesetFilename);
} }
std::vector<base::FilePath> GetReservedMetadataFilePaths( std::vector<base::FilePath> GetReservedMetadataFilePaths(
const base::FilePath& extension_path) { const base::FilePath& extension_path) {
return { return {GetVerifiedContentsPath(extension_path),
GetVerifiedContentsPath(extension_path), GetComputedHashesPath(extension_path),
GetComputedHashesPath(extension_path), extension_path.Append(GetIndexedRulesetRelativePath())};
GetIndexedRulesetPath(extension_path),
};
} }
} // namespace file_util } // namespace file_util
......
...@@ -172,7 +172,7 @@ base::FilePath GetComputedHashesPath(const base::FilePath& extension_path); ...@@ -172,7 +172,7 @@ base::FilePath GetComputedHashesPath(const base::FilePath& extension_path);
// Helper function to get path used for the indexed ruleset by the Declarative // Helper function to get path used for the indexed ruleset by the Declarative
// Net Request API. // Net Request API.
base::FilePath GetIndexedRulesetPath(const base::FilePath& extension_path); base::FilePath GetIndexedRulesetRelativePath();
// Returns the list of file-paths reserved for use by the Extension system in // Returns the list of file-paths reserved for use by the Extension system in
// the kMetadataFolder. // the kMetadataFolder.
......
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