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

Unified Diff: chrome/common/extensions/url_pattern.cc

Issue 2932007: Use WebCore's built in support for user styles (Closed)
Patch Set: whoops Created 10 years, 5 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
« no previous file with comments | « chrome/common/extensions/url_pattern.h ('k') | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/url_pattern.cc
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc
index 979d14b6b3ae4270b7419d85922318d0ec3d26cd..70240b48bd67e53e87f4b399391cb6f564a94042 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;
+}
« no previous file with comments | « chrome/common/extensions/url_pattern.h ('k') | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698