| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 new ui::SelectFileDialog::FileTypeInfo(*base_file_type)); | 243 new ui::SelectFileDialog::FileTypeInfo(*base_file_type)); |
| 244 file_type->include_all_files = true; | 244 file_type->include_all_files = true; |
| 245 file_type->extensions.resize(1); | 245 file_type->extensions.resize(1); |
| 246 std::vector<base::FilePath::StringType>* extensions = | 246 std::vector<base::FilePath::StringType>* extensions = |
| 247 &file_type->extensions.back(); | 247 &file_type->extensions.back(); |
| 248 | 248 |
| 249 // Find the corresponding extensions. | 249 // Find the corresponding extensions. |
| 250 int valid_type_count = 0; | 250 int valid_type_count = 0; |
| 251 int description_id = 0; | 251 int description_id = 0; |
| 252 for (size_t i = 0; i < accept_types.size(); ++i) { | 252 for (size_t i = 0; i < accept_types.size(); ++i) { |
| 253 std::string ascii_type = UTF16ToASCII(accept_types[i]); | 253 std::string ascii_type = base::UTF16ToASCII(accept_types[i]); |
| 254 if (!IsAcceptTypeValid(ascii_type)) | 254 if (!IsAcceptTypeValid(ascii_type)) |
| 255 continue; | 255 continue; |
| 256 | 256 |
| 257 size_t old_extension_size = extensions->size(); | 257 size_t old_extension_size = extensions->size(); |
| 258 if (ascii_type[0] == '.') { | 258 if (ascii_type[0] == '.') { |
| 259 // If the type starts with a period it is assumed to be a file extension | 259 // If the type starts with a period it is assumed to be a file extension |
| 260 // so we just have to add it to the list. | 260 // so we just have to add it to the list. |
| 261 base::FilePath::StringType ext(ascii_type.begin(), ascii_type.end()); | 261 base::FilePath::StringType ext(ascii_type.begin(), ascii_type.end()); |
| 262 extensions->push_back(ext.substr(1)); | 262 extensions->push_back(ext.substr(1)); |
| 263 } else { | 263 } else { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 // of an extension or a "/" in the case of a MIME type). | 478 // of an extension or a "/" in the case of a MIME type). |
| 479 std::string unused; | 479 std::string unused; |
| 480 if (accept_type.length() <= 1 || | 480 if (accept_type.length() <= 1 || |
| 481 StringToLowerASCII(accept_type) != accept_type || | 481 StringToLowerASCII(accept_type) != accept_type || |
| 482 base::TrimWhitespaceASCII(accept_type, base::TRIM_ALL, &unused) != | 482 base::TrimWhitespaceASCII(accept_type, base::TRIM_ALL, &unused) != |
| 483 base::TRIM_NONE) { | 483 base::TRIM_NONE) { |
| 484 return false; | 484 return false; |
| 485 } | 485 } |
| 486 return true; | 486 return true; |
| 487 } | 487 } |
| OLD | NEW |