| 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" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
| 13 #include "content/public/common/url_constants.h" | |
| 14 #include "extensions/common/error_utils.h" | 13 #include "extensions/common/error_utils.h" |
| 15 #include "extensions/common/manifest.h" | 14 #include "extensions/common/manifest.h" |
| 16 #include "extensions/common/manifest_constants.h" | 15 #include "extensions/common/manifest_constants.h" |
| 17 #include "extensions/common/url_pattern.h" | 16 #include "extensions/common/url_pattern.h" |
| 17 #include "url/url_constants.h" |
| 18 | 18 |
| 19 namespace keys = extensions::manifest_keys; | 19 namespace keys = extensions::manifest_keys; |
| 20 namespace errors = extensions::manifest_errors; | 20 namespace errors = extensions::manifest_errors; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const char kReadAccessString[] = "read"; | 24 const char kReadAccessString[] = "read"; |
| 25 const char kReadWriteAccessString[] = "read-write"; | 25 const char kReadWriteAccessString[] = "read-write"; |
| 26 const char kCreateAccessString[] = "create"; | 26 const char kCreateAccessString[] = "create"; |
| 27 | 27 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } | 190 } |
| 191 for (size_t i = 0; i < file_filters->GetSize(); ++i) { | 191 for (size_t i = 0; i < file_filters->GetSize(); ++i) { |
| 192 std::string filter; | 192 std::string filter; |
| 193 if (!file_filters->GetString(i, &filter)) { | 193 if (!file_filters->GetString(i, &filter)) { |
| 194 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( | 194 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( |
| 195 errors::kInvalidFileFilterValue, base::IntToString(i)); | 195 errors::kInvalidFileFilterValue, base::IntToString(i)); |
| 196 return NULL; | 196 return NULL; |
| 197 } | 197 } |
| 198 StringToLowerASCII(&filter); | 198 StringToLowerASCII(&filter); |
| 199 if (!StartsWithASCII(filter, | 199 if (!StartsWithASCII(filter, |
| 200 std::string(content::kFileSystemScheme) + ':', | 200 std::string(url::kFileSystemScheme) + ':', |
| 201 true)) { | 201 true)) { |
| 202 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( | 202 *error = extensions::ErrorUtils::FormatErrorMessageUTF16( |
| 203 errors::kInvalidURLPatternError, filter); | 203 errors::kInvalidURLPatternError, filter); |
| 204 return NULL; | 204 return NULL; |
| 205 } | 205 } |
| 206 // The user inputs filesystem:*; we don't actually implement scheme | 206 // The user inputs filesystem:*; we don't actually implement scheme |
| 207 // wildcards in URLPattern, so transform to what will match correctly. | 207 // wildcards in URLPattern, so transform to what will match correctly. |
| 208 filter.replace(0, 11, "chrome-extension://*/"); | 208 filter.replace(0, 11, "chrome-extension://*/"); |
| 209 URLPattern pattern(URLPattern::SCHEME_EXTENSION); | 209 URLPattern pattern(URLPattern::SCHEME_EXTENSION); |
| 210 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { | 210 if (pattern.Parse(filter) != URLPattern::PARSE_SUCCESS) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 return false; // Failed to parse file browser actions definition. | 282 return false; // Failed to parse file browser actions definition. |
| 283 } | 283 } |
| 284 | 284 |
| 285 extension->SetManifestData(keys::kFileBrowserHandlers, info.release()); | 285 extension->SetManifestData(keys::kFileBrowserHandlers, info.release()); |
| 286 return true; | 286 return true; |
| 287 } | 287 } |
| 288 | 288 |
| 289 const std::vector<std::string> FileBrowserHandlerParser::Keys() const { | 289 const std::vector<std::string> FileBrowserHandlerParser::Keys() const { |
| 290 return SingleKey(keys::kFileBrowserHandlers); | 290 return SingleKey(keys::kFileBrowserHandlers); |
| 291 } | 291 } |
| OLD | NEW |