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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 pref_service, mime_type, file_path.Extension()); | 623 pref_service, mime_type, file_path.Extension()); |
624 default_task_ids.insert(task_id); | 624 default_task_ids.insert(task_id); |
625 } | 625 } |
626 | 626 |
627 // Go through all the tasks from the beginning and see if there is any | 627 // Go through all the tasks from the beginning and see if there is any |
628 // default task. If found, pick and set it as default and return. | 628 // default task. If found, pick and set it as default and return. |
629 for (size_t i = 0; i < tasks->size(); ++i) { | 629 for (size_t i = 0; i < tasks->size(); ++i) { |
630 FullTaskDescriptor* task = &tasks->at(i); | 630 FullTaskDescriptor* task = &tasks->at(i); |
631 DCHECK(!task->is_default()); | 631 DCHECK(!task->is_default()); |
632 const std::string task_id = TaskDescriptorToId(task->task_descriptor()); | 632 const std::string task_id = TaskDescriptorToId(task->task_descriptor()); |
633 if (ContainsKey(default_task_ids, task_id)) { | 633 if (base::ContainsKey(default_task_ids, task_id)) { |
634 task->set_is_default(true); | 634 task->set_is_default(true); |
635 return; | 635 return; |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 // No default tasks found. If there is any fallback file browser handler, | 639 // No default tasks found. If there is any fallback file browser handler, |
640 // make it as default task, so it's selected by default. | 640 // make it as default task, so it's selected by default. |
641 for (size_t i = 0; i < tasks->size(); ++i) { | 641 for (size_t i = 0; i < tasks->size(); ++i) { |
642 FullTaskDescriptor* task = &tasks->at(i); | 642 FullTaskDescriptor* task = &tasks->at(i); |
643 DCHECK(!task->is_default()); | 643 DCHECK(!task->is_default()); |
644 if (IsFallbackFileHandler(task->task_descriptor())) { | 644 if (IsFallbackFileHandler(task->task_descriptor())) { |
645 task->set_is_default(true); | 645 task->set_is_default(true); |
646 return; | 646 return; |
647 } | 647 } |
648 } | 648 } |
649 } | 649 } |
650 | 650 |
651 } // namespace file_tasks | 651 } // namespace file_tasks |
652 } // namespace file_manager | 652 } // namespace file_manager |
OLD | NEW |