| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 | 10 |
| 11 // TODO(aa): Consider adding chrome-extension? What about more obscure ones | 11 // TODO(aa): Consider adding chrome-extension? What about more obscure ones |
| 12 // like data: and javascript: ? | 12 // like data: and javascript: ? |
| 13 static const char* kValidSchemes[] = { | 13 static const char* kValidSchemes[] = { |
| 14 chrome::kHttpScheme, | 14 chrome::kHttpScheme, |
| 15 chrome::kHttpsScheme, | 15 chrome::kHttpsScheme, |
| 16 chrome::kFileScheme, | 16 chrome::kFileScheme, |
| 17 chrome::kFtpScheme, | 17 chrome::kFtpScheme, |
| 18 chrome::kChromeUIScheme, | |
| 19 }; | 18 }; |
| 20 | 19 |
| 21 static const char kPathSeparator[] = "/"; | 20 static const char kPathSeparator[] = "/"; |
| 22 | 21 |
| 23 static bool IsValidScheme(const std::string& scheme) { | 22 // static |
| 23 bool URLPattern::IsValidScheme(const std::string& scheme) { |
| 24 for (size_t i = 0; i < arraysize(kValidSchemes); ++i) { | 24 for (size_t i = 0; i < arraysize(kValidSchemes); ++i) { |
| 25 if (scheme == kValidSchemes[i]) | 25 if (scheme == kValidSchemes[i]) |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 | 28 |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 bool URLPattern::Parse(const std::string& pattern) { | 32 bool URLPattern::Parse(const std::string& pattern) { |
| 33 size_t scheme_end_pos = pattern.find(chrome::kStandardSchemeSeparator); | 33 size_t scheme_end_pos = pattern.find(chrome::kStandardSchemeSeparator); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 if (!host_.empty()) | 141 if (!host_.empty()) |
| 142 spec += host_; | 142 spec += host_; |
| 143 | 143 |
| 144 if (!path_.empty()) | 144 if (!path_.empty()) |
| 145 spec += path_; | 145 spec += path_; |
| 146 | 146 |
| 147 return spec; | 147 return spec; |
| 148 } | 148 } |
| OLD | NEW |