OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 5 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 *error = base::ASCIIToUTF16(errors::kInvalidFileFiltersList); | 192 *error = base::ASCIIToUTF16(errors::kInvalidFileFiltersList); |
193 return NULL; | 193 return NULL; |
194 } | 194 } |
195 for (size_t i = 0; i < file_filters->GetSize(); ++i) { | 195 for (size_t i = 0; i < file_filters->GetSize(); ++i) { |
196 std::string filter; | 196 std::string filter; |
197 if (!file_filters->GetString(i, &filter)) { | 197 if (!file_filters->GetString(i, &filter)) { |
198 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( | 198 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( |
199 errors::kInvalidFileFilterValue, base::IntToString(i)); | 199 errors::kInvalidFileFilterValue, base::IntToString(i)); |
200 return NULL; | 200 return NULL; |
201 } | 201 } |
202 base::StringToLowerASCII(&filter); | 202 filter = base::ToLowerASCII(filter); |
203 if (!base::StartsWith(filter, std::string(url::kFileSystemScheme) + ':', | 203 if (!base::StartsWith(filter, std::string(url::kFileSystemScheme) + ':', |
204 base::CompareCase::SENSITIVE)) { | 204 base::CompareCase::SENSITIVE)) { |
205 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( | 205 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( |
206 errors::kInvalidURLPatternError, filter); | 206 errors::kInvalidURLPatternError, filter); |
207 return NULL; | 207 return NULL; |
208 } | 208 } |
209 // The user inputs filesystem:*; we don't actually implement scheme | 209 // The user inputs filesystem:*; we don't actually implement scheme |
210 // wildcards in URLPattern, so transform to what will match correctly. | 210 // wildcards in URLPattern, so transform to what will match correctly. |
211 filter.replace(0, 11, "chrome-extension://*/"); | 211 filter.replace(0, 11, "chrome-extension://*/"); |
212 URLPattern pattern(URLPattern::SCHEME_EXTENSION); | 212 URLPattern pattern(URLPattern::SCHEME_EXTENSION); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return false; // Failed to parse file browser actions definition. | 298 return false; // Failed to parse file browser actions definition. |
299 } | 299 } |
300 | 300 |
301 extension->SetManifestData(keys::kFileBrowserHandlers, info.release()); | 301 extension->SetManifestData(keys::kFileBrowserHandlers, info.release()); |
302 return true; | 302 return true; |
303 } | 303 } |
304 | 304 |
305 const std::vector<std::string> FileBrowserHandlerParser::Keys() const { | 305 const std::vector<std::string> FileBrowserHandlerParser::Keys() const { |
306 return SingleKey(keys::kFileBrowserHandlers); | 306 return SingleKey(keys::kFileBrowserHandlers); |
307 } | 307 } |
OLD | NEW |