| 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 "apps/app_window.h" | 7 #include "apps/app_window.h" |
| 8 #include "apps/app_window_registry.h" | 8 #include "apps/app_window_registry.h" |
| 9 #include "apps/saved_files_service.h" | 9 #include "apps/saved_files_service.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 std::set<base::FilePath::StringType> extension_set; | 95 std::set<base::FilePath::StringType> extension_set; |
| 96 int description_id = 0; | 96 int description_id = 0; |
| 97 | 97 |
| 98 if (accept_option.mime_types.get()) { | 98 if (accept_option.mime_types.get()) { |
| 99 std::vector<std::string>* list = accept_option.mime_types.get(); | 99 std::vector<std::string>* list = accept_option.mime_types.get(); |
| 100 bool valid_type = false; | 100 bool valid_type = false; |
| 101 for (std::vector<std::string>::const_iterator iter = list->begin(); | 101 for (std::vector<std::string>::const_iterator iter = list->begin(); |
| 102 iter != list->end(); ++iter) { | 102 iter != list->end(); ++iter) { |
| 103 std::vector<base::FilePath::StringType> inner; | 103 std::vector<base::FilePath::StringType> inner; |
| 104 std::string accept_type = *iter; | 104 std::string accept_type = *iter; |
| 105 StringToLowerASCII(&accept_type); | 105 base::StringToLowerASCII(&accept_type); |
| 106 net::GetExtensionsForMimeType(accept_type, &inner); | 106 net::GetExtensionsForMimeType(accept_type, &inner); |
| 107 if (inner.empty()) | 107 if (inner.empty()) |
| 108 continue; | 108 continue; |
| 109 | 109 |
| 110 if (valid_type) | 110 if (valid_type) |
| 111 description_id = 0; // We already have an accept type with label; if | 111 description_id = 0; // We already have an accept type with label; if |
| 112 // we find another, give up and use the default. | 112 // we find another, give up and use the default. |
| 113 else if (accept_type == "image/*") | 113 else if (accept_type == "image/*") |
| 114 description_id = IDS_IMAGE_FILES; | 114 description_id = IDS_IMAGE_FILES; |
| 115 else if (accept_type == "audio/*") | 115 else if (accept_type == "audio/*") |
| 116 description_id = IDS_AUDIO_FILES; | 116 description_id = IDS_AUDIO_FILES; |
| 117 else if (accept_type == "video/*") | 117 else if (accept_type == "video/*") |
| 118 description_id = IDS_VIDEO_FILES; | 118 description_id = IDS_VIDEO_FILES; |
| 119 | 119 |
| 120 extension_set.insert(inner.begin(), inner.end()); | 120 extension_set.insert(inner.begin(), inner.end()); |
| 121 valid_type = true; | 121 valid_type = true; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 if (accept_option.extensions.get()) { | 125 if (accept_option.extensions.get()) { |
| 126 std::vector<std::string>* list = accept_option.extensions.get(); | 126 std::vector<std::string>* list = accept_option.extensions.get(); |
| 127 for (std::vector<std::string>::const_iterator iter = list->begin(); | 127 for (std::vector<std::string>::const_iterator iter = list->begin(); |
| 128 iter != list->end(); ++iter) { | 128 iter != list->end(); ++iter) { |
| 129 std::string extension = *iter; | 129 std::string extension = *iter; |
| 130 StringToLowerASCII(&extension); | 130 base::StringToLowerASCII(&extension); |
| 131 #if defined(OS_WIN) | 131 #if defined(OS_WIN) |
| 132 extension_set.insert(base::UTF8ToWide(*iter)); | 132 extension_set.insert(base::UTF8ToWide(*iter)); |
| 133 #else | 133 #else |
| 134 extension_set.insert(*iter); | 134 extension_set.insert(*iter); |
| 135 #endif | 135 #endif |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 extensions->assign(extension_set.begin(), extension_set.end()); | 139 extensions->assign(extension_set.begin(), extension_set.end()); |
| 140 if (extensions->empty()) | 140 if (extensions->empty()) |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 if (needs_new_entry) { | 924 if (needs_new_entry) { |
| 925 is_directory_ = file_entry->is_directory; | 925 is_directory_ = file_entry->is_directory; |
| 926 CreateResponse(); | 926 CreateResponse(); |
| 927 AddEntryToResponse(file_entry->path, file_entry->id); | 927 AddEntryToResponse(file_entry->path, file_entry->id); |
| 928 } | 928 } |
| 929 SendResponse(true); | 929 SendResponse(true); |
| 930 return true; | 930 return true; |
| 931 } | 931 } |
| 932 | 932 |
| 933 } // namespace extensions | 933 } // namespace extensions |
| OLD | NEW |