| 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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, | 179 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, |
| 180 const std::string& mime_type, | 180 const std::string& mime_type, |
| 181 const std::string& suffix) { | 181 const std::string& suffix) { |
| 182 VLOG(1) << "Looking for default for MIME type: " << mime_type | 182 VLOG(1) << "Looking for default for MIME type: " << mime_type |
| 183 << " and suffix: " << suffix; | 183 << " and suffix: " << suffix; |
| 184 std::string task_id; | 184 std::string task_id; |
| 185 if (!mime_type.empty()) { | 185 if (!mime_type.empty()) { |
| 186 const DictionaryValue* mime_task_prefs = | 186 const base::DictionaryValue* mime_task_prefs = |
| 187 pref_service.GetDictionary(prefs::kDefaultTasksByMimeType); | 187 pref_service.GetDictionary(prefs::kDefaultTasksByMimeType); |
| 188 DCHECK(mime_task_prefs); | 188 DCHECK(mime_task_prefs); |
| 189 LOG_IF(ERROR, !mime_task_prefs) << "Unable to open MIME type prefs"; | 189 LOG_IF(ERROR, !mime_task_prefs) << "Unable to open MIME type prefs"; |
| 190 if (mime_task_prefs && | 190 if (mime_task_prefs && |
| 191 mime_task_prefs->GetStringWithoutPathExpansion(mime_type, &task_id)) { | 191 mime_task_prefs->GetStringWithoutPathExpansion(mime_type, &task_id)) { |
| 192 VLOG(1) << "Found MIME default handler: " << task_id; | 192 VLOG(1) << "Found MIME default handler: " << task_id; |
| 193 return task_id; | 193 return task_id; |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 const DictionaryValue* suffix_task_prefs = | 197 const base::DictionaryValue* suffix_task_prefs = |
| 198 pref_service.GetDictionary(prefs::kDefaultTasksBySuffix); | 198 pref_service.GetDictionary(prefs::kDefaultTasksBySuffix); |
| 199 DCHECK(suffix_task_prefs); | 199 DCHECK(suffix_task_prefs); |
| 200 LOG_IF(ERROR, !suffix_task_prefs) << "Unable to open suffix prefs"; | 200 LOG_IF(ERROR, !suffix_task_prefs) << "Unable to open suffix prefs"; |
| 201 std::string lower_suffix = StringToLowerASCII(suffix); | 201 std::string lower_suffix = StringToLowerASCII(suffix); |
| 202 if (suffix_task_prefs) | 202 if (suffix_task_prefs) |
| 203 suffix_task_prefs->GetStringWithoutPathExpansion(lower_suffix, &task_id); | 203 suffix_task_prefs->GetStringWithoutPathExpansion(lower_suffix, &task_id); |
| 204 VLOG_IF(1, !task_id.empty()) << "Found suffix default handler: " << task_id; | 204 VLOG_IF(1, !task_id.empty()) << "Found suffix default handler: " << task_id; |
| 205 return task_id; | 205 return task_id; |
| 206 } | 206 } |
| 207 | 207 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 if (file_browser_handlers::IsFallbackFileBrowserHandler( | 537 if (file_browser_handlers::IsFallbackFileBrowserHandler( |
| 538 task->task_descriptor())) { | 538 task->task_descriptor())) { |
| 539 task->set_is_default(true); | 539 task->set_is_default(true); |
| 540 return; | 540 return; |
| 541 } | 541 } |
| 542 } | 542 } |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace file_tasks | 545 } // namespace file_tasks |
| 546 } // namespace file_manager | 546 } // namespace file_manager |
| OLD | NEW |