| 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_handlers/app_file_handler_util.h" | 5 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" |
| 6 | 6 |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return NULL; | 210 return NULL; |
| 211 | 211 |
| 212 for (FileHandlersInfo::const_iterator i = file_handlers->begin(); | 212 for (FileHandlersInfo::const_iterator i = file_handlers->begin(); |
| 213 i != file_handlers->end(); i++) { | 213 i != file_handlers->end(); i++) { |
| 214 if (i->id == handler_id) | 214 if (i->id == handler_id) |
| 215 return &*i; | 215 return &*i; |
| 216 } | 216 } |
| 217 return NULL; | 217 return NULL; |
| 218 } | 218 } |
| 219 | 219 |
| 220 const FileHandlerInfo* FirstFileHandlerForEntry(const Extension& app, | |
| 221 const EntryInfo& entry) { | |
| 222 const FileHandlersInfo* file_handlers = FileHandlers::GetFileHandlers(&app); | |
| 223 if (!file_handlers) | |
| 224 return NULL; | |
| 225 | |
| 226 for (FileHandlersInfo::const_iterator i = file_handlers->begin(); | |
| 227 i != file_handlers->end(); i++) { | |
| 228 if (FileHandlerCanHandleEntry(*i, entry)) | |
| 229 return &*i; | |
| 230 } | |
| 231 return NULL; | |
| 232 } | |
| 233 | |
| 234 std::vector<const FileHandlerInfo*> FindFileHandlersForEntries( | 220 std::vector<const FileHandlerInfo*> FindFileHandlersForEntries( |
| 235 const Extension& app, | 221 const Extension& app, |
| 236 const std::vector<EntryInfo> entries) { | 222 const std::vector<EntryInfo> entries) { |
| 237 std::vector<const FileHandlerInfo*> handlers; | 223 std::vector<const FileHandlerInfo*> handlers; |
| 238 if (entries.empty()) | 224 if (entries.empty()) |
| 239 return handlers; | 225 return handlers; |
| 240 | 226 |
| 241 // Look for file handlers which can handle all the MIME types specified. | 227 // Look for file handlers which can handle all the MIME types specified. |
| 242 const FileHandlersInfo* file_handlers = FileHandlers::GetFileHandlers(&app); | 228 const FileHandlersInfo* file_handlers = FileHandlers::GetFileHandlers(&app); |
| 243 if (!file_handlers) | 229 if (!file_handlers) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 *error = kInvalidParameters; | 351 *error = kInvalidParameters; |
| 366 return false; | 352 return false; |
| 367 } | 353 } |
| 368 | 354 |
| 369 return true; | 355 return true; |
| 370 } | 356 } |
| 371 | 357 |
| 372 } // namespace app_file_handler_util | 358 } // namespace app_file_handler_util |
| 373 | 359 |
| 374 } // namespace extensions | 360 } // namespace extensions |
| OLD | NEW |