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 |
11 #include "apps/launcher.h" | 11 #include "apps/launcher.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | |
15 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
16 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
17 #include "chrome/browser/chromeos/drive/file_system_util.h" | 16 #include "chrome/browser/chromeos/drive/file_system_util.h" |
18 #include "chrome/browser/chromeos/drive/file_task_executor.h" | 17 #include "chrome/browser/chromeos/drive/file_task_executor.h" |
19 #include "chrome/browser/chromeos/file_manager/app_id.h" | 18 #include "chrome/browser/chromeos/file_manager/app_id.h" |
20 #include "chrome/browser/chromeos/file_manager/arc_file_tasks.h" | 19 #include "chrome/browser/chromeos/file_manager/arc_file_tasks.h" |
21 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" | 20 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
22 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
23 #include "chrome/browser/chromeos/file_manager/open_util.h" | 22 #include "chrome/browser/chromeos/file_manager/open_util.h" |
24 #include "chrome/browser/extensions/extension_tab_util.h" | 23 #include "chrome/browser/extensions/extension_tab_util.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 const std::set<std::string>& suffixes, | 190 const std::set<std::string>& suffixes, |
192 const std::set<std::string>& mime_types) { | 191 const std::set<std::string>& mime_types) { |
193 if (!pref_service) | 192 if (!pref_service) |
194 return; | 193 return; |
195 | 194 |
196 if (!mime_types.empty()) { | 195 if (!mime_types.empty()) { |
197 DictionaryPrefUpdate mime_type_pref(pref_service, | 196 DictionaryPrefUpdate mime_type_pref(pref_service, |
198 prefs::kDefaultTasksByMimeType); | 197 prefs::kDefaultTasksByMimeType); |
199 for (std::set<std::string>::const_iterator iter = mime_types.begin(); | 198 for (std::set<std::string>::const_iterator iter = mime_types.begin(); |
200 iter != mime_types.end(); ++iter) { | 199 iter != mime_types.end(); ++iter) { |
201 mime_type_pref->SetWithoutPathExpansion( | 200 base::Value* value = new base::Value(task_id); |
202 *iter, base::MakeUnique<base::Value>(task_id)); | 201 mime_type_pref->SetWithoutPathExpansion(*iter, value); |
203 } | 202 } |
204 } | 203 } |
205 | 204 |
206 if (!suffixes.empty()) { | 205 if (!suffixes.empty()) { |
207 DictionaryPrefUpdate mime_type_pref(pref_service, | 206 DictionaryPrefUpdate mime_type_pref(pref_service, |
208 prefs::kDefaultTasksBySuffix); | 207 prefs::kDefaultTasksBySuffix); |
209 for (std::set<std::string>::const_iterator iter = suffixes.begin(); | 208 for (std::set<std::string>::const_iterator iter = suffixes.begin(); |
210 iter != suffixes.end(); ++iter) { | 209 iter != suffixes.end(); ++iter) { |
| 210 base::Value* value = new base::Value(task_id); |
211 // Suffixes are case insensitive. | 211 // Suffixes are case insensitive. |
212 std::string lower_suffix = base::ToLowerASCII(*iter); | 212 std::string lower_suffix = base::ToLowerASCII(*iter); |
213 mime_type_pref->SetWithoutPathExpansion( | 213 mime_type_pref->SetWithoutPathExpansion(lower_suffix, value); |
214 lower_suffix, base::MakeUnique<base::Value>(task_id)); | |
215 } | 214 } |
216 } | 215 } |
217 } | 216 } |
218 | 217 |
219 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, | 218 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, |
220 const std::string& mime_type, | 219 const std::string& mime_type, |
221 const std::string& suffix) { | 220 const std::string& suffix) { |
222 VLOG(1) << "Looking for default for MIME type: " << mime_type | 221 VLOG(1) << "Looking for default for MIME type: " << mime_type |
223 << " and suffix: " << suffix; | 222 << " and suffix: " << suffix; |
224 std::string task_id; | 223 std::string task_id; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 DCHECK(!task->is_default()); | 639 DCHECK(!task->is_default()); |
641 if (IsFallbackFileHandler(task->task_descriptor())) { | 640 if (IsFallbackFileHandler(task->task_descriptor())) { |
642 task->set_is_default(true); | 641 task->set_is_default(true); |
643 return; | 642 return; |
644 } | 643 } |
645 } | 644 } |
646 } | 645 } |
647 | 646 |
648 } // namespace file_tasks | 647 } // namespace file_tasks |
649 } // namespace file_manager | 648 } // namespace file_manager |
OLD | NEW |