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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 180 } |
181 } | 181 } |
182 | 182 |
183 if (!suffixes.empty()) { | 183 if (!suffixes.empty()) { |
184 DictionaryPrefUpdate mime_type_pref(pref_service, | 184 DictionaryPrefUpdate mime_type_pref(pref_service, |
185 prefs::kDefaultTasksBySuffix); | 185 prefs::kDefaultTasksBySuffix); |
186 for (std::set<std::string>::const_iterator iter = suffixes.begin(); | 186 for (std::set<std::string>::const_iterator iter = suffixes.begin(); |
187 iter != suffixes.end(); ++iter) { | 187 iter != suffixes.end(); ++iter) { |
188 base::StringValue* value = new base::StringValue(task_id); | 188 base::StringValue* value = new base::StringValue(task_id); |
189 // Suffixes are case insensitive. | 189 // Suffixes are case insensitive. |
190 std::string lower_suffix = StringToLowerASCII(*iter); | 190 std::string lower_suffix = base::StringToLowerASCII(*iter); |
191 mime_type_pref->SetWithoutPathExpansion(lower_suffix, value); | 191 mime_type_pref->SetWithoutPathExpansion(lower_suffix, value); |
192 } | 192 } |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, | 196 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, |
197 const std::string& mime_type, | 197 const std::string& mime_type, |
198 const std::string& suffix) { | 198 const std::string& suffix) { |
199 VLOG(1) << "Looking for default for MIME type: " << mime_type | 199 VLOG(1) << "Looking for default for MIME type: " << mime_type |
200 << " and suffix: " << suffix; | 200 << " and suffix: " << suffix; |
201 std::string task_id; | 201 std::string task_id; |
202 if (!mime_type.empty()) { | 202 if (!mime_type.empty()) { |
203 const base::DictionaryValue* mime_task_prefs = | 203 const base::DictionaryValue* mime_task_prefs = |
204 pref_service.GetDictionary(prefs::kDefaultTasksByMimeType); | 204 pref_service.GetDictionary(prefs::kDefaultTasksByMimeType); |
205 DCHECK(mime_task_prefs); | 205 DCHECK(mime_task_prefs); |
206 LOG_IF(ERROR, !mime_task_prefs) << "Unable to open MIME type prefs"; | 206 LOG_IF(ERROR, !mime_task_prefs) << "Unable to open MIME type prefs"; |
207 if (mime_task_prefs && | 207 if (mime_task_prefs && |
208 mime_task_prefs->GetStringWithoutPathExpansion(mime_type, &task_id)) { | 208 mime_task_prefs->GetStringWithoutPathExpansion(mime_type, &task_id)) { |
209 VLOG(1) << "Found MIME default handler: " << task_id; | 209 VLOG(1) << "Found MIME default handler: " << task_id; |
210 return task_id; | 210 return task_id; |
211 } | 211 } |
212 } | 212 } |
213 | 213 |
214 const base::DictionaryValue* suffix_task_prefs = | 214 const base::DictionaryValue* suffix_task_prefs = |
215 pref_service.GetDictionary(prefs::kDefaultTasksBySuffix); | 215 pref_service.GetDictionary(prefs::kDefaultTasksBySuffix); |
216 DCHECK(suffix_task_prefs); | 216 DCHECK(suffix_task_prefs); |
217 LOG_IF(ERROR, !suffix_task_prefs) << "Unable to open suffix prefs"; | 217 LOG_IF(ERROR, !suffix_task_prefs) << "Unable to open suffix prefs"; |
218 std::string lower_suffix = StringToLowerASCII(suffix); | 218 std::string lower_suffix = base::StringToLowerASCII(suffix); |
219 if (suffix_task_prefs) | 219 if (suffix_task_prefs) |
220 suffix_task_prefs->GetStringWithoutPathExpansion(lower_suffix, &task_id); | 220 suffix_task_prefs->GetStringWithoutPathExpansion(lower_suffix, &task_id); |
221 VLOG_IF(1, !task_id.empty()) << "Found suffix default handler: " << task_id; | 221 VLOG_IF(1, !task_id.empty()) << "Found suffix default handler: " << task_id; |
222 return task_id; | 222 return task_id; |
223 } | 223 } |
224 | 224 |
225 std::string MakeTaskID(const std::string& app_id, | 225 std::string MakeTaskID(const std::string& app_id, |
226 TaskType task_type, | 226 TaskType task_type, |
227 const std::string& action_id) { | 227 const std::string& action_id) { |
228 return base::StringPrintf("%s|%s|%s", | 228 return base::StringPrintf("%s|%s|%s", |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 DCHECK(!task->is_default()); | 541 DCHECK(!task->is_default()); |
542 if (IsFallbackFileHandler(task->task_descriptor())) { | 542 if (IsFallbackFileHandler(task->task_descriptor())) { |
543 task->set_is_default(true); | 543 task->set_is_default(true); |
544 return; | 544 return; |
545 } | 545 } |
546 } | 546 } |
547 } | 547 } |
548 | 548 |
549 } // namespace file_tasks | 549 } // namespace file_tasks |
550 } // namespace file_manager | 550 } // namespace file_manager |
OLD | NEW |