| 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/chromeos/file_manager/file_tasks.h" | 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h" |
| 6 | 6 |
| 7 #include "apps/launcher.h" | 7 #include "apps/launcher.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 if (profile->IsOffTheRecord() && | 406 if (profile->IsOffTheRecord() && |
| 407 !extensions::util::IsIncognitoEnabled(extension->id(), profile)) | 407 !extensions::util::IsIncognitoEnabled(extension->id(), profile)) |
| 408 continue; | 408 continue; |
| 409 | 409 |
| 410 typedef std::vector<const extensions::FileHandlerInfo*> FileHandlerList; | 410 typedef std::vector<const extensions::FileHandlerInfo*> FileHandlerList; |
| 411 FileHandlerList file_handlers = | 411 FileHandlerList file_handlers = |
| 412 FindFileHandlersForFiles(*extension, path_mime_set); | 412 FindFileHandlersForFiles(*extension, path_mime_set); |
| 413 if (file_handlers.empty()) | 413 if (file_handlers.empty()) |
| 414 continue; | 414 continue; |
| 415 | 415 |
| 416 for (FileHandlerList::iterator i = file_handlers.begin(); | 416 // Only show the first matching handler from each app. |
| 417 i != file_handlers.end(); ++i) { | 417 const extensions::FileHandlerInfo* file_handler = file_handlers.front(); |
| 418 std::string task_id = file_tasks::MakeTaskID( | 418 std::string task_id = file_tasks::MakeTaskID( |
| 419 extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, (*i)->id); | 419 extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, file_handler->id); |
| 420 | 420 |
| 421 GURL best_icon = extensions::ExtensionIconSource::GetIconURL( | 421 GURL best_icon = extensions::ExtensionIconSource::GetIconURL( |
| 422 extension, | 422 extension, |
| 423 drive::util::kPreferredIconSize, | 423 drive::util::kPreferredIconSize, |
| 424 ExtensionIconSet::MATCH_BIGGER, | 424 ExtensionIconSet::MATCH_BIGGER, |
| 425 false, // grayscale | 425 false, // grayscale |
| 426 NULL); // exists | 426 NULL); // exists |
| 427 | 427 |
| 428 result_list->push_back(FullTaskDescriptor( | 428 result_list->push_back( |
| 429 TaskDescriptor( | 429 FullTaskDescriptor(TaskDescriptor(extension->id(), |
| 430 extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, (*i)->id), | 430 file_tasks::TASK_TYPE_FILE_HANDLER, |
| 431 extension->name(), | 431 file_handler->id), |
| 432 best_icon, | 432 extension->name(), |
| 433 false /* is_default */)); | 433 best_icon, |
| 434 } | 434 false /* is_default */)); |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 | 437 |
| 438 void FindFileBrowserHandlerTasks( | 438 void FindFileBrowserHandlerTasks( |
| 439 Profile* profile, | 439 Profile* profile, |
| 440 const std::vector<GURL>& file_urls, | 440 const std::vector<GURL>& file_urls, |
| 441 std::vector<FullTaskDescriptor>* result_list) { | 441 std::vector<FullTaskDescriptor>* result_list) { |
| 442 DCHECK(!file_urls.empty()); | 442 DCHECK(!file_urls.empty()); |
| 443 DCHECK(result_list); | 443 DCHECK(result_list); |
| 444 | 444 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 DCHECK(!task->is_default()); | 541 DCHECK(!task->is_default()); |
| 542 if (IsFallbackFileHandler(task->task_descriptor())) { | 542 if (IsFallbackFileHandler(task->task_descriptor())) { |
| 543 task->set_is_default(true); | 543 task->set_is_default(true); |
| 544 return; | 544 return; |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| 549 } // namespace file_tasks | 549 } // namespace file_tasks |
| 550 } // namespace file_manager | 550 } // namespace file_manager |
| OLD | NEW |