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

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

Issue 2449913002: Support WebSocket in WebRequest API. (Closed)
Patch Set: Extract process and frame ID from WS requests. Created 4 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/common/url_pattern.h" 5 #include "extensions/common/url_pattern.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <ostream> 9 #include <ostream>
10 10
(...skipping 13 matching lines...) Expand all
24 const char URLPattern::kAllUrlsPattern[] = "<all_urls>"; 24 const char URLPattern::kAllUrlsPattern[] = "<all_urls>";
25 25
26 namespace { 26 namespace {
27 27
28 // TODO(aa): What about more obscure schemes like data: and javascript: ? 28 // TODO(aa): What about more obscure schemes like data: and javascript: ?
29 // Note: keep this array in sync with kValidSchemeMasks. 29 // Note: keep this array in sync with kValidSchemeMasks.
30 const char* const kValidSchemes[] = { 30 const char* const kValidSchemes[] = {
31 url::kHttpScheme, url::kHttpsScheme, 31 url::kHttpScheme, url::kHttpsScheme,
32 url::kFileScheme, url::kFtpScheme, 32 url::kFileScheme, url::kFtpScheme,
33 content::kChromeUIScheme, extensions::kExtensionScheme, 33 content::kChromeUIScheme, extensions::kExtensionScheme,
34 url::kFileSystemScheme, 34 url::kFileSystemScheme, url::kWsScheme,
35 url::kWssScheme,
35 }; 36 };
36 37
37 const int kValidSchemeMasks[] = { 38 const int kValidSchemeMasks[] = {
38 URLPattern::SCHEME_HTTP, 39 URLPattern::SCHEME_HTTP,
39 URLPattern::SCHEME_HTTPS, 40 URLPattern::SCHEME_HTTPS,
40 URLPattern::SCHEME_FILE, 41 URLPattern::SCHEME_FILE,
41 URLPattern::SCHEME_FTP, 42 URLPattern::SCHEME_FTP,
42 URLPattern::SCHEME_CHROMEUI, 43 URLPattern::SCHEME_CHROMEUI,
43 URLPattern::SCHEME_EXTENSION, 44 URLPattern::SCHEME_EXTENSION,
44 URLPattern::SCHEME_FILESYSTEM, 45 URLPattern::SCHEME_FILESYSTEM,
46 URLPattern::SCHEME_WS,
47 URLPattern::SCHEME_WSS,
45 }; 48 };
46 49
47 static_assert(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks), 50 static_assert(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks),
48 "must keep these arrays in sync"); 51 "must keep these arrays in sync");
49 52
50 const char kParseSuccess[] = "Success."; 53 const char kParseSuccess[] = "Success.";
51 const char kParseErrorMissingSchemeSeparator[] = "Missing scheme separator."; 54 const char kParseErrorMissingSchemeSeparator[] = "Missing scheme separator.";
52 const char kParseErrorInvalidScheme[] = "Invalid scheme."; 55 const char kParseErrorInvalidScheme[] = "Invalid scheme.";
53 const char kParseErrorWrongSchemeType[] = "Wrong scheme type."; 56 const char kParseErrorWrongSchemeType[] = "Wrong scheme type.";
54 const char kParseErrorEmptyHost[] = "Host can not be empty."; 57 const char kParseErrorEmptyHost[] = "Host can not be empty.";
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 312
310 void URLPattern::SetMatchSubdomains(bool val) { 313 void URLPattern::SetMatchSubdomains(bool val) {
311 spec_.clear(); 314 spec_.clear();
312 match_subdomains_ = val; 315 match_subdomains_ = val;
313 } 316 }
314 317
315 bool URLPattern::SetScheme(const std::string& scheme) { 318 bool URLPattern::SetScheme(const std::string& scheme) {
316 spec_.clear(); 319 spec_.clear();
317 scheme_ = scheme; 320 scheme_ = scheme;
318 if (scheme_ == "*") { 321 if (scheme_ == "*") {
319 valid_schemes_ &= (SCHEME_HTTP | SCHEME_HTTPS); 322 valid_schemes_ &= (SCHEME_HTTP | SCHEME_HTTPS | SCHEME_WS | SCHEME_WSS);
320 } else if (!IsValidScheme(scheme_)) { 323 } else if (!IsValidScheme(scheme_)) {
321 return false; 324 return false;
322 } 325 }
323 return true; 326 return true;
324 } 327 }
325 328
326 bool URLPattern::IsValidScheme(const std::string& scheme) const { 329 bool URLPattern::IsValidScheme(const std::string& scheme) const {
327 if (valid_schemes_ == SCHEME_ALL) 330 if (valid_schemes_ == SCHEME_ALL)
328 return true; 331 return true;
329 332
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 } 618 }
616 619
617 return result; 620 return result;
618 } 621 }
619 622
620 // static 623 // static
621 const char* URLPattern::GetParseResultString( 624 const char* URLPattern::GetParseResultString(
622 URLPattern::ParseResult parse_result) { 625 URLPattern::ParseResult parse_result) {
623 return kParseResultMessages[parse_result]; 626 return kParseResultMessages[parse_result];
624 } 627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698