OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/file_manager/private_api_tasks.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_tasks.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/drive/file_system_util.h" | 7 #include "chrome/browser/chromeos/drive/file_system_util.h" |
8 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 8 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
9 #include "chrome/browser/chromeos/file_manager/file_tasks.h" | 9 #include "chrome/browser/chromeos/file_manager/file_tasks.h" |
10 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 10 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 suffixes.insert(url.path().Extension()); | 40 suffixes.insert(url.path().Extension()); |
41 } | 41 } |
42 return suffixes; | 42 return suffixes; |
43 } | 43 } |
44 | 44 |
45 // Make a set of unique MIME types out of the list of MIME types. | 45 // Make a set of unique MIME types out of the list of MIME types. |
46 std::set<std::string> GetUniqueMimeTypes( | 46 std::set<std::string> GetUniqueMimeTypes( |
47 const std::vector<std::string>& mime_type_list) { | 47 const std::vector<std::string>& mime_type_list) { |
48 std::set<std::string> mime_types; | 48 std::set<std::string> mime_types; |
49 for (size_t i = 0; i < mime_type_list.size(); ++i) { | 49 for (size_t i = 0; i < mime_type_list.size(); ++i) { |
50 std::string mime_type; | 50 const std::string mime_type = mime_type_list[i]; |
51 // We'll skip empty MIME types. | 51 // We'll skip empty MIME types and existing MIME types. |
52 if (!mime_type.empty()) | 52 if (!mime_type.empty() || |
53 std::find(mime_types.begin(), mime_types.end(), mime_type) == | |
yoshiki
2013/12/10 07:00:29
We don't need to check duplication explicitly sinc
hirono
2013/12/10 10:05:33
Oops, I missed it. Thanks!
| |
54 mime_types.end()) | |
53 mime_types.insert(mime_type); | 55 mime_types.insert(mime_type); |
54 } | 56 } |
55 return mime_types; | 57 return mime_types; |
56 } | 58 } |
57 | 59 |
58 } // namespace | 60 } // namespace |
59 | 61 |
60 bool FileBrowserPrivateExecuteTaskFunction::RunImpl() { | 62 bool FileBrowserPrivateExecuteTaskFunction::RunImpl() { |
61 using extensions::api::file_browser_private::ExecuteTask::Params; | 63 using extensions::api::file_browser_private::ExecuteTask::Params; |
62 const scoped_ptr<Params> params(Params::Create(*args_)); | 64 const scoped_ptr<Params> params(Params::Create(*args_)); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 SetResult(new base::FundamentalValue(true)); | 205 SetResult(new base::FundamentalValue(true)); |
204 return true; | 206 return true; |
205 } | 207 } |
206 | 208 |
207 file_manager::file_tasks::UpdateDefaultTask( | 209 file_manager::file_tasks::UpdateDefaultTask( |
208 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types); | 210 GetProfile()->GetPrefs(), params->task_id, suffixes, mime_types); |
209 return true; | 211 return true; |
210 } | 212 } |
211 | 213 |
212 } // namespace extensions | 214 } // namespace extensions |
OLD | NEW |