summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/url_pattern.cc
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 00:54:41 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-16 00:54:41 +0000
commit6451d8737f7c36dda01ace43d450f425598daf91 (patch)
treebe1f597ad96f799a399cdb6f95e03e1c8e3e98e7 /chrome/common/extensions/url_pattern.cc
parent8117fefbf48185d531c6a6d36c707a2114490686 (diff)
downloadchromium_src-6451d8737f7c36dda01ace43d450f425598daf91.zip
chromium_src-6451d8737f7c36dda01ace43d450f425598daf91.tar.gz
chromium_src-6451d8737f7c36dda01ace43d450f425598daf91.tar.bz2
Use WebCore's built in support for user styles instead of the
hack we were doing before. This has a side-effect of fixing a bunch of content-interaction bugs because we will be using real user-level styles (in the CSS sense) rather than content-level styles. BUG=29995 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=52581 Review URL: http://codereview.chromium.org/2932007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52584 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/url_pattern.cc')
-rw-r--r--chrome/common/extensions/url_pattern.cc36
1 files changed, 29 insertions, 7 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc
index 979d14b..70240b4 100644
--- a/chrome/common/extensions/url_pattern.cc
+++ b/chrome/common/extensions/url_pattern.cc
@@ -76,7 +76,7 @@ bool URLPattern::Parse(const std::string& pattern) {
// File URLs are special because they have no host. There are other schemes
// with the same structure, but we don't support them (yet).
- if (scheme_ == "file") {
+ if (scheme_ == chrome::kFileScheme) {
path_start_pos = host_start_pos;
} else {
size_t host_end_pos = pattern.find(kPathSeparator, host_start_pos);
@@ -206,15 +206,17 @@ std::string URLPattern::GetAsString() const {
std::string spec = scheme_ + chrome::kStandardSchemeSeparator;
- if (match_subdomains_) {
- spec += "*";
+ if (scheme_ != chrome::kFileScheme) {
+ if (match_subdomains_) {
+ spec += "*";
+ if (!host_.empty())
+ spec += ".";
+ }
+
if (!host_.empty())
- spec += ".";
+ spec += host_;
}
- if (!host_.empty())
- spec += host_;
-
if (!path_.empty())
spec += path_;
@@ -242,3 +244,23 @@ bool URLPattern::OverlapsWith(const URLPattern& other) const {
return true;
}
+
+std::vector<URLPattern> URLPattern::ConvertToExplicitSchemes() const {
+ std::vector<URLPattern> result;
+
+ if (scheme_ != "*" && !match_all_urls_) {
+ result.push_back(*this);
+ return result;
+ }
+
+ for (size_t i = 0; i < arraysize(kValidSchemes); ++i) {
+ if (MatchesScheme(kValidSchemes[i])) {
+ URLPattern temp = *this;
+ temp.SetScheme(kValidSchemes[i]);
+ temp.set_match_all_urls(false);
+ result.push_back(temp);
+ }
+ }
+
+ return result;
+}