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 <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/saved_files_service.h" | 10 #include "apps/saved_files_service.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 base::string16* description) { | 144 base::string16* description) { |
145 std::set<base::FilePath::StringType> extension_set; | 145 std::set<base::FilePath::StringType> extension_set; |
146 int description_id = 0; | 146 int description_id = 0; |
147 | 147 |
148 if (accept_option.mime_types.get()) { | 148 if (accept_option.mime_types.get()) { |
149 std::vector<std::string>* list = accept_option.mime_types.get(); | 149 std::vector<std::string>* list = accept_option.mime_types.get(); |
150 bool valid_type = false; | 150 bool valid_type = false; |
151 for (std::vector<std::string>::const_iterator iter = list->begin(); | 151 for (std::vector<std::string>::const_iterator iter = list->begin(); |
152 iter != list->end(); ++iter) { | 152 iter != list->end(); ++iter) { |
153 std::vector<base::FilePath::StringType> inner; | 153 std::vector<base::FilePath::StringType> inner; |
154 std::string accept_type = *iter; | 154 std::string accept_type = base::ToLowerASCII(*iter); |
155 base::StringToLowerASCII(&accept_type); | |
156 net::GetExtensionsForMimeType(accept_type, &inner); | 155 net::GetExtensionsForMimeType(accept_type, &inner); |
157 if (inner.empty()) | 156 if (inner.empty()) |
158 continue; | 157 continue; |
159 | 158 |
160 if (valid_type) | 159 if (valid_type) |
161 description_id = 0; // We already have an accept type with label; if | 160 description_id = 0; // We already have an accept type with label; if |
162 // we find another, give up and use the default. | 161 // we find another, give up and use the default. |
163 else if (accept_type == "image/*") | 162 else if (accept_type == "image/*") |
164 description_id = IDS_IMAGE_FILES; | 163 description_id = IDS_IMAGE_FILES; |
165 else if (accept_type == "audio/*") | 164 else if (accept_type == "audio/*") |
166 description_id = IDS_AUDIO_FILES; | 165 description_id = IDS_AUDIO_FILES; |
167 else if (accept_type == "video/*") | 166 else if (accept_type == "video/*") |
168 description_id = IDS_VIDEO_FILES; | 167 description_id = IDS_VIDEO_FILES; |
169 | 168 |
170 extension_set.insert(inner.begin(), inner.end()); | 169 extension_set.insert(inner.begin(), inner.end()); |
171 valid_type = true; | 170 valid_type = true; |
172 } | 171 } |
173 } | 172 } |
174 | 173 |
175 if (accept_option.extensions.get()) { | 174 if (accept_option.extensions.get()) { |
176 std::vector<std::string>* list = accept_option.extensions.get(); | 175 std::vector<std::string>* list = accept_option.extensions.get(); |
177 for (std::vector<std::string>::const_iterator iter = list->begin(); | 176 for (std::vector<std::string>::const_iterator iter = list->begin(); |
178 iter != list->end(); ++iter) { | 177 iter != list->end(); ++iter) { |
179 std::string extension = *iter; | 178 std::string extension = base::ToLowerASCII(*iter); |
180 base::StringToLowerASCII(&extension); | |
181 #if defined(OS_WIN) | 179 #if defined(OS_WIN) |
182 extension_set.insert(base::UTF8ToWide(*iter)); | 180 extension_set.insert(base::UTF8ToWide(*iter)); |
183 #else | 181 #else |
184 extension_set.insert(*iter); | 182 extension_set.insert(*iter); |
185 #endif | 183 #endif |
186 } | 184 } |
187 } | 185 } |
188 | 186 |
189 extensions->assign(extension_set.begin(), extension_set.end()); | 187 extensions->assign(extension_set.begin(), extension_set.end()); |
190 if (extensions->empty()) | 188 if (extensions->empty()) |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 std::vector<linked_ptr<Volume>> result_volume_list; | 1440 std::vector<linked_ptr<Volume>> result_volume_list; |
1443 FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); | 1441 FillVolumeList(chrome_details_.GetProfile(), &result_volume_list); |
1444 | 1442 |
1445 return RespondNow( | 1443 return RespondNow( |
1446 ArgumentList(api::file_system::GetVolumeList::Results::Create( | 1444 ArgumentList(api::file_system::GetVolumeList::Results::Create( |
1447 result_volume_list).Pass())); | 1445 result_volume_list).Pass())); |
1448 } | 1446 } |
1449 #endif | 1447 #endif |
1450 | 1448 |
1451 } // namespace extensions | 1449 } // namespace extensions |
OLD | NEW |