OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extension.h" | 5 #include "extensions/common/extension.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 std::string path = relative_path; | 148 std::string path = relative_path; |
149 | 149 |
150 // If the relative path starts with "/", it is "absolute" relative to the | 150 // If the relative path starts with "/", it is "absolute" relative to the |
151 // extension base directory, but extension_url is already specified to refer | 151 // extension base directory, but extension_url is already specified to refer |
152 // to that base directory, so strip the leading "/" if present. | 152 // to that base directory, so strip the leading "/" if present. |
153 if (relative_path.size() > 0 && relative_path[0] == '/') | 153 if (relative_path.size() > 0 && relative_path[0] == '/') |
154 path = relative_path.substr(1); | 154 path = relative_path.substr(1); |
155 | 155 |
156 GURL ret_val = GURL(extension_url.spec() + path); | 156 GURL ret_val = GURL(extension_url.spec() + path); |
157 DCHECK(base::StartsWithASCII(ret_val.spec(), extension_url.spec(), false)); | 157 DCHECK(base::StartsWith(ret_val.spec(), extension_url.spec(), |
| 158 base::CompareCase::INSENSITIVE_ASCII)); |
158 | 159 |
159 return ret_val; | 160 return ret_val; |
160 } | 161 } |
161 | 162 |
162 bool Extension::ResourceMatches(const URLPatternSet& pattern_set, | 163 bool Extension::ResourceMatches(const URLPatternSet& pattern_set, |
163 const std::string& resource) const { | 164 const std::string& resource) const { |
164 return pattern_set.MatchesURL(extension_url_.Resolve(resource)); | 165 return pattern_set.MatchesURL(extension_url_.Resolve(resource)); |
165 } | 166 } |
166 | 167 |
167 ExtensionResource Extension::GetResource( | 168 ExtensionResource Extension::GetResource( |
(...skipping 30 matching lines...) Expand all Loading... |
198 // static | 199 // static |
199 bool Extension::ParsePEMKeyBytes(const std::string& input, | 200 bool Extension::ParsePEMKeyBytes(const std::string& input, |
200 std::string* output) { | 201 std::string* output) { |
201 DCHECK(output); | 202 DCHECK(output); |
202 if (!output) | 203 if (!output) |
203 return false; | 204 return false; |
204 if (input.length() == 0) | 205 if (input.length() == 0) |
205 return false; | 206 return false; |
206 | 207 |
207 std::string working = input; | 208 std::string working = input; |
208 if (base::StartsWithASCII(working, kKeyBeginHeaderMarker, true)) { | 209 if (base::StartsWith(working, kKeyBeginHeaderMarker, |
| 210 base::CompareCase::SENSITIVE)) { |
209 working = base::CollapseWhitespaceASCII(working, true); | 211 working = base::CollapseWhitespaceASCII(working, true); |
210 size_t header_pos = working.find(kKeyInfoEndMarker, | 212 size_t header_pos = working.find(kKeyInfoEndMarker, |
211 sizeof(kKeyBeginHeaderMarker) - 1); | 213 sizeof(kKeyBeginHeaderMarker) - 1); |
212 if (header_pos == std::string::npos) | 214 if (header_pos == std::string::npos) |
213 return false; | 215 return false; |
214 size_t start_pos = header_pos + sizeof(kKeyInfoEndMarker) - 1; | 216 size_t start_pos = header_pos + sizeof(kKeyInfoEndMarker) - 1; |
215 size_t end_pos = working.rfind(kKeyBeginFooterMarker); | 217 size_t end_pos = working.rfind(kKeyBeginFooterMarker); |
216 if (end_pos == std::string::npos) | 218 if (end_pos == std::string::npos) |
217 return false; | 219 return false; |
218 if (start_pos >= end_pos) | 220 if (start_pos >= end_pos) |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 | 781 |
780 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 782 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
781 const Extension* extension, | 783 const Extension* extension, |
782 const PermissionSet* permissions, | 784 const PermissionSet* permissions, |
783 Reason reason) | 785 Reason reason) |
784 : reason(reason), | 786 : reason(reason), |
785 extension(extension), | 787 extension(extension), |
786 permissions(permissions) {} | 788 permissions(permissions) {} |
787 | 789 |
788 } // namespace extensions | 790 } // namespace extensions |
OLD | NEW |