| 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/extensions/api/file_system/file_system_api.h" | 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 // Expand the mime-types and extensions provided in an AcceptOption, returning | 140 // Expand the mime-types and extensions provided in an AcceptOption, returning |
| 141 // them within the passed extension vector. Returns false if no valid types | 141 // them within the passed extension vector. Returns false if no valid types |
| 142 // were found. | 142 // were found. |
| 143 bool GetFileTypesFromAcceptOption( | 143 bool GetFileTypesFromAcceptOption( |
| 144 const file_system::AcceptOption& accept_option, | 144 const file_system::AcceptOption& accept_option, |
| 145 std::vector<FilePath::StringType>* extensions, | 145 std::vector<FilePath::StringType>* extensions, |
| 146 string16* description) { | 146 string16* description) { |
| 147 std::set<FilePath::StringType> extension_set; | 147 std::set<FilePath::StringType> extension_set; |
| 148 int description_id = 0; | 148 int description_id = 0; |
| 149 bool valid_type = false; | |
| 150 | 149 |
| 151 if (accept_option.mime_types.get()) { | 150 if (accept_option.mime_types.get()) { |
| 152 std::vector<std::string>* list = accept_option.mime_types.get(); | 151 std::vector<std::string>* list = accept_option.mime_types.get(); |
| 152 bool valid_type = false; |
| 153 for (std::vector<std::string>::const_iterator iter = list->begin(); | 153 for (std::vector<std::string>::const_iterator iter = list->begin(); |
| 154 iter != list->end(); ++iter) { | 154 iter != list->end(); ++iter) { |
| 155 std::vector<FilePath::StringType> inner; | 155 std::vector<FilePath::StringType> inner; |
| 156 std::string accept_type = *iter; | 156 std::string accept_type = *iter; |
| 157 StringToLowerASCII(&accept_type); | 157 StringToLowerASCII(&accept_type); |
| 158 net::GetExtensionsForMimeType(*iter, &inner); | 158 net::GetExtensionsForMimeType(accept_type, &inner); |
| 159 if (inner.empty()) | 159 if (inner.empty()) |
| 160 continue; | 160 continue; |
| 161 | 161 |
| 162 if (valid_type) | 162 if (valid_type) |
| 163 description_id = 0; // We already have an accept type with label; if | 163 description_id = 0; // We already have an accept type with label; if |
| 164 // we find another, give up and use the default. | 164 // we find another, give up and use the default. |
| 165 else if (accept_type == "image/*") | 165 else if (accept_type == "image/*") |
| 166 description_id = IDS_IMAGE_FILES; | 166 description_id = IDS_IMAGE_FILES; |
| 167 else if (accept_type == "audio/*") | 167 else if (accept_type == "audio/*") |
| 168 description_id = IDS_AUDIO_FILES; | 168 description_id = IDS_AUDIO_FILES; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 | 546 |
| 547 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) { | 547 if (entry_type == WRITABLE && !HasFileSystemWritePermission()) { |
| 548 error_ = kRequiresFileSystemWriteError; | 548 error_ = kRequiresFileSystemWriteError; |
| 549 return false; | 549 return false; |
| 550 } | 550 } |
| 551 | 551 |
| 552 return ShowPicker(suggested_name, file_type_info, picker_type, entry_type); | 552 return ShowPicker(suggested_name, file_type_info, picker_type, entry_type); |
| 553 } | 553 } |
| 554 | 554 |
| 555 } // namespace extensions | 555 } // namespace extensions |
| OLD | NEW |