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

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

Issue 6804032: Add TLS-SRP (RFC 5054) support Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: use system srp and mpi libs, not local copies Created 9 years, 8 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_piece.h" 7 #include "base/string_piece.h"
8 #include "base/string_split.h" 8 #include "base/string_split.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "googleurl/src/url_util.h" 12 #include "googleurl/src/url_util.h"
13 13
14 // TODO(aa): Consider adding chrome-extension? What about more obscure ones 14 // TODO(aa): Consider adding chrome-extension? What about more obscure ones
15 // like data: and javascript: ? 15 // like data: and javascript: ?
16 // Note: keep this array in sync with kValidSchemeMasks. 16 // Note: keep this array in sync with kValidSchemeMasks.
17 static const char* kValidSchemes[] = { 17 static const char* kValidSchemes[] = {
18 chrome::kHttpScheme, 18 chrome::kHttpScheme,
19 chrome::kHttpsScheme, 19 chrome::kHttpsScheme,
20 chrome::kHttpsvScheme,
20 chrome::kFileScheme, 21 chrome::kFileScheme,
21 chrome::kFtpScheme, 22 chrome::kFtpScheme,
22 chrome::kChromeUIScheme, 23 chrome::kChromeUIScheme,
23 }; 24 };
24 25
25 static const int kValidSchemeMasks[] = { 26 static const int kValidSchemeMasks[] = {
26 URLPattern::SCHEME_HTTP, 27 URLPattern::SCHEME_HTTP,
27 URLPattern::SCHEME_HTTPS, 28 URLPattern::SCHEME_HTTPS,
29 URLPattern::SCHEME_HTTPSV,
28 URLPattern::SCHEME_FILE, 30 URLPattern::SCHEME_FILE,
29 URLPattern::SCHEME_FTP, 31 URLPattern::SCHEME_FTP,
30 URLPattern::SCHEME_CHROMEUI, 32 URLPattern::SCHEME_CHROMEUI,
31 }; 33 };
32 34
33 COMPILE_ASSERT(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks), 35 COMPILE_ASSERT(arraysize(kValidSchemes) == arraysize(kValidSchemeMasks),
34 must_keep_these_arrays_in_sync); 36 must_keep_these_arrays_in_sync);
35 37
36 static const char kPathSeparator[] = "/"; 38 static const char kPathSeparator[] = "/";
37 39
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 143 }
142 144
143 path_ = pattern.substr(path_start_pos); 145 path_ = pattern.substr(path_start_pos);
144 146
145 return PARSE_SUCCESS; 147 return PARSE_SUCCESS;
146 } 148 }
147 149
148 bool URLPattern::SetScheme(const std::string& scheme) { 150 bool URLPattern::SetScheme(const std::string& scheme) {
149 scheme_ = scheme; 151 scheme_ = scheme;
150 if (scheme_ == "*") { 152 if (scheme_ == "*") {
151 valid_schemes_ &= (SCHEME_HTTP | SCHEME_HTTPS); 153 valid_schemes_ &= (SCHEME_HTTP | SCHEME_HTTPS | SCHEME_HTTPSV);
152 } else if (!IsValidScheme(scheme_)) { 154 } else if (!IsValidScheme(scheme_)) {
153 return false; 155 return false;
154 } 156 }
155 return true; 157 return true;
156 } 158 }
157 159
158 bool URLPattern::IsValidScheme(const std::string& scheme) const { 160 bool URLPattern::IsValidScheme(const std::string& scheme) const {
159 if (valid_schemes_ == SCHEME_ALL) 161 if (valid_schemes_ == SCHEME_ALL)
160 return true; 162 return true;
161 163
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (MatchesScheme(kValidSchemes[i])) { 304 if (MatchesScheme(kValidSchemes[i])) {
303 URLPattern temp = *this; 305 URLPattern temp = *this;
304 temp.SetScheme(kValidSchemes[i]); 306 temp.SetScheme(kValidSchemes[i]);
305 temp.set_match_all_urls(false); 307 temp.set_match_all_urls(false);
306 result.push_back(temp); 308 result.push_back(temp);
307 } 309 }
308 } 310 }
309 311
310 return result; 312 return result;
311 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698