| 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_browser_handlers.h" | 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 if (ContainsKey(common_handler_set, *itr)) | 537 if (ContainsKey(common_handler_set, *itr)) |
| 538 intersection.push_back(*itr); | 538 intersection.push_back(*itr); |
| 539 } | 539 } |
| 540 | 540 |
| 541 std::swap(common_handlers, intersection); | 541 std::swap(common_handlers, intersection); |
| 542 if (common_handlers.empty()) | 542 if (common_handlers.empty()) |
| 543 return FileBrowserHandlerList(); | 543 return FileBrowserHandlerList(); |
| 544 } | 544 } |
| 545 } | 545 } |
| 546 | 546 |
| 547 // "watch" and "gallery" are defined in the file manager's manifest.json. | |
| 548 FileBrowserHandlerList::iterator watch_iter = | |
| 549 FindFileBrowserHandlerForExtensionIdAndActionId( | |
| 550 &common_handlers, kFileManagerAppId, "watch"); | |
| 551 FileBrowserHandlerList::iterator gallery_iter = | |
| 552 FindFileBrowserHandlerForExtensionIdAndActionId( | |
| 553 &common_handlers, kFileManagerAppId, "gallery"); | |
| 554 if (watch_iter != common_handlers.end() && | |
| 555 gallery_iter != common_handlers.end()) { | |
| 556 // Both "watch" and "gallery" actions are applicable which means that the | |
| 557 // selection is all videos. Showing them both is confusing, so we only keep | |
| 558 // the one that makes more sense ("watch" for single selection, "gallery" | |
| 559 // for multiple selection). | |
| 560 if (file_list.size() == 1) | |
| 561 common_handlers.erase(gallery_iter); | |
| 562 else | |
| 563 common_handlers.erase(watch_iter); | |
| 564 } | |
| 565 | |
| 566 return common_handlers; | 547 return common_handlers; |
| 567 } | 548 } |
| 568 | 549 |
| 569 } // namespace file_browser_handlers | 550 } // namespace file_browser_handlers |
| 570 } // namespace file_manager | 551 } // namespace file_manager |
| OLD | NEW |