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(StartsWithASCII(ret_val.spec(), extension_url.spec(), false)); | 157 DCHECK(base::StartsWithASCII(ret_val.spec(), extension_url.spec(), false)); |
158 | 158 |
159 return ret_val; | 159 return ret_val; |
160 } | 160 } |
161 | 161 |
162 bool Extension::ResourceMatches(const URLPatternSet& pattern_set, | 162 bool Extension::ResourceMatches(const URLPatternSet& pattern_set, |
163 const std::string& resource) const { | 163 const std::string& resource) const { |
164 return pattern_set.MatchesURL(extension_url_.Resolve(resource)); | 164 return pattern_set.MatchesURL(extension_url_.Resolve(resource)); |
165 } | 165 } |
166 | 166 |
167 ExtensionResource Extension::GetResource( | 167 ExtensionResource Extension::GetResource( |
(...skipping 30 matching lines...) Expand all Loading... |
198 // static | 198 // static |
199 bool Extension::ParsePEMKeyBytes(const std::string& input, | 199 bool Extension::ParsePEMKeyBytes(const std::string& input, |
200 std::string* output) { | 200 std::string* output) { |
201 DCHECK(output); | 201 DCHECK(output); |
202 if (!output) | 202 if (!output) |
203 return false; | 203 return false; |
204 if (input.length() == 0) | 204 if (input.length() == 0) |
205 return false; | 205 return false; |
206 | 206 |
207 std::string working = input; | 207 std::string working = input; |
208 if (StartsWithASCII(working, kKeyBeginHeaderMarker, true)) { | 208 if (base::StartsWithASCII(working, kKeyBeginHeaderMarker, true)) { |
209 working = base::CollapseWhitespaceASCII(working, true); | 209 working = base::CollapseWhitespaceASCII(working, true); |
210 size_t header_pos = working.find(kKeyInfoEndMarker, | 210 size_t header_pos = working.find(kKeyInfoEndMarker, |
211 sizeof(kKeyBeginHeaderMarker) - 1); | 211 sizeof(kKeyBeginHeaderMarker) - 1); |
212 if (header_pos == std::string::npos) | 212 if (header_pos == std::string::npos) |
213 return false; | 213 return false; |
214 size_t start_pos = header_pos + sizeof(kKeyInfoEndMarker) - 1; | 214 size_t start_pos = header_pos + sizeof(kKeyInfoEndMarker) - 1; |
215 size_t end_pos = working.rfind(kKeyBeginFooterMarker); | 215 size_t end_pos = working.rfind(kKeyBeginFooterMarker); |
216 if (end_pos == std::string::npos) | 216 if (end_pos == std::string::npos) |
217 return false; | 217 return false; |
218 if (start_pos >= end_pos) | 218 if (start_pos >= end_pos) |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 | 779 |
780 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( | 780 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( |
781 const Extension* extension, | 781 const Extension* extension, |
782 const PermissionSet* permissions, | 782 const PermissionSet* permissions, |
783 Reason reason) | 783 Reason reason) |
784 : reason(reason), | 784 : reason(reason), |
785 extension(extension), | 785 extension(extension), |
786 permissions(permissions) {} | 786 permissions(permissions) {} |
787 | 787 |
788 } // namespace extensions | 788 } // namespace extensions |
OLD | NEW |