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

Side by Side Diff: chrome/common/extensions/url_pattern.cc

Issue 8138004: Fix issues related to <all_urls> in extensions. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: make the plugin.dll empty so it loads everywhere Created 9 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/extensions/url_pattern.h" 5 #include "chrome/common/extensions/url_pattern.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_piece.h" 8 #include "base/string_piece.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 bool URLPattern::operator==(const URLPattern& other) const { 131 bool URLPattern::operator==(const URLPattern& other) const {
132 return GetAsString() == other.GetAsString(); 132 return GetAsString() == other.GetAsString();
133 } 133 }
134 134
135 URLPattern::ParseResult URLPattern::Parse(const std::string& pattern, 135 URLPattern::ParseResult URLPattern::Parse(const std::string& pattern,
136 ParseOption strictness) { 136 ParseOption strictness) {
137 spec_.clear(); 137 spec_.clear();
138 138
139 // Special case pattern to match every valid URL. 139 // Special case pattern to match every valid URL.
140 if (pattern == kAllUrlsPattern) { 140 if (pattern == kAllUrlsPattern) {
141 match_all_urls_ = true; 141 SetMatchAllURLs(true);
142 match_subdomains_ = true;
143 scheme_ = "*";
144 host_.clear();
145 SetPath("/*");
146 return PARSE_SUCCESS; 142 return PARSE_SUCCESS;
147 } 143 }
148 144
149 // Parse out the scheme. 145 // Parse out the scheme.
150 size_t scheme_end_pos = pattern.find(chrome::kStandardSchemeSeparator); 146 size_t scheme_end_pos = pattern.find(chrome::kStandardSchemeSeparator);
151 bool has_standard_scheme_separator = true; 147 bool has_standard_scheme_separator = true;
152 148
153 // Some urls also use ':' alone as the scheme separator. 149 // Some urls also use ':' alone as the scheme separator.
154 if (scheme_end_pos == std::string::npos) { 150 if (scheme_end_pos == std::string::npos) {
155 scheme_end_pos = pattern.find(':'); 151 scheme_end_pos = pattern.find(':');
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 } 246 }
251 247
252 void URLPattern::SetHost(const std::string& host) { 248 void URLPattern::SetHost(const std::string& host) {
253 spec_.clear(); 249 spec_.clear();
254 host_ = host; 250 host_ = host;
255 } 251 }
256 252
257 void URLPattern::SetMatchAllURLs(bool val) { 253 void URLPattern::SetMatchAllURLs(bool val) {
258 spec_.clear(); 254 spec_.clear();
259 match_all_urls_ = val; 255 match_all_urls_ = val;
256
257 if (val) {
258 match_subdomains_ = true;
259 scheme_ = "*";
260 host_.clear();
261 SetPath("/*");
262 }
260 } 263 }
261 264
262 void URLPattern::SetMatchSubdomains(bool val) { 265 void URLPattern::SetMatchSubdomains(bool val) {
263 spec_.clear(); 266 spec_.clear();
264 match_subdomains_ = val; 267 match_subdomains_ = val;
265 } 268 }
266 269
267 bool URLPattern::SetScheme(const std::string& scheme) { 270 bool URLPattern::SetScheme(const std::string& scheme) {
268 spec_.clear(); 271 spec_.clear();
269 scheme_ = scheme; 272 scheme_ = scheme;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 493 }
491 494
492 return result; 495 return result;
493 } 496 }
494 497
495 // static 498 // static
496 const char* URLPattern::GetParseResultString( 499 const char* URLPattern::GetParseResultString(
497 URLPattern::ParseResult parse_result) { 500 URLPattern::ParseResult parse_result) {
498 return kParseResultMessages[parse_result]; 501 return kParseResultMessages[parse_result];
499 } 502 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_permission_set_unittest.cc ('k') | chrome/common/extensions/url_pattern_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698