Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5817)

Unified Diff: chrome/common/content_settings_pattern_parser.cc

Issue 9254028: Added support for file URI path wildcards in content settings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on trunk Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/content_settings_pattern_parser.cc
diff --git a/chrome/common/content_settings_pattern_parser.cc b/chrome/common/content_settings_pattern_parser.cc
index e54834a3cbba6a6120964d29a5d8c51ba8bfb39d..e98b4d50d1de78448ab1acd905dd5bf3b013c6d3 100644
--- a/chrome/common/content_settings_pattern_parser.cc
+++ b/chrome/common/content_settings_pattern_parser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -42,6 +42,8 @@ const char* PatternParser::kHostWildcard = "*";
const char* PatternParser::kPortWildcard = "*";
+const char* PatternParser::kPathWildcard = "*";
+
// static
void PatternParser::Parse(const std::string& pattern_spec,
ContentSettingsPattern::BuilderInterface* builder) {
@@ -169,13 +171,18 @@ void PatternParser::Parse(const std::string& pattern_spec,
builder->WithPort(port);
}
} else {
- if (scheme != std::string(chrome::kExtensionScheme))
+ if (scheme != std::string(chrome::kExtensionScheme) &&
+ scheme != std::string(chrome::kFileScheme))
builder->WithPortWildcard();
}
if (path_component.IsNonEmpty()) {
- builder->WithPath(pattern_spec.substr(path_component.start,
- path_component.len));
+ const std::string path = pattern_spec.substr(path_component.start,
+ path_component.len);
+ if (path.substr(1) == kPathWildcard)
+ builder->WithPathWildcard();
+ else
+ builder->WithPath(path);
}
}
@@ -194,8 +201,12 @@ std::string PatternParser::ToString(
if (!parts.is_scheme_wildcard)
str += parts.scheme + chrome::kStandardSchemeSeparator;
- if (parts.scheme == std::string(chrome::kFileScheme))
- return str + parts.path;
+ if (parts.scheme == chrome::kFileScheme) {
+ if (parts.is_path_wildcard)
+ return str + kUrlPathSeparator + kPathWildcard;
+ else
+ return str + parts.path;
+ }
if (parts.has_domain_wildcard) {
if (parts.host.empty())
« no previous file with comments | « chrome/common/content_settings_pattern_parser.h ('k') | chrome/common/content_settings_pattern_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698