| 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/extensions/file_manager/file_handler_util.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/file_handler_util.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 extensions::ExtensionSystem::Get(profile)->process_manager(); | 91 extensions::ExtensionSystem::Get(profile)->process_manager(); |
| 92 | 92 |
| 93 SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url); | 93 SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url); |
| 94 if (!site_instance || !site_instance->HasProcess()) | 94 if (!site_instance || !site_instance->HasProcess()) |
| 95 return -1; | 95 return -1; |
| 96 content::RenderProcessHost* process = site_instance->GetProcess(); | 96 content::RenderProcessHost* process = site_instance->GetProcess(); |
| 97 | 97 |
| 98 return process->GetID(); | 98 return process->GetID(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // Returns true if the task should be used as a fallback. Such tasks are | |
| 102 // Files.app's internal handlers as well as quick office extensions. | |
| 103 bool IsFallbackTask(const FileBrowserHandler* task) { | |
| 104 return (task->extension_id() == kFileBrowserDomain || | |
| 105 task->extension_id() == | |
| 106 extension_misc::kQuickOfficeComponentExtensionId || | |
| 107 task->extension_id() == extension_misc::kQuickOfficeDevExtensionId || | |
| 108 task->extension_id() == extension_misc::kQuickOfficeExtensionId); | |
| 109 } | |
| 110 | |
| 111 const FileBrowserHandler* FindFileBrowserHandler(const Extension* extension, | 101 const FileBrowserHandler* FindFileBrowserHandler(const Extension* extension, |
| 112 const std::string& action_id) { | 102 const std::string& action_id) { |
| 113 FileBrowserHandler::List* handler_list = | 103 FileBrowserHandler::List* handler_list = |
| 114 FileBrowserHandler::GetHandlers(extension); | 104 FileBrowserHandler::GetHandlers(extension); |
| 115 for (FileBrowserHandler::List::const_iterator action_iter = | 105 for (FileBrowserHandler::List::const_iterator action_iter = |
| 116 handler_list->begin(); | 106 handler_list->begin(); |
| 117 action_iter != handler_list->end(); | 107 action_iter != handler_list->end(); |
| 118 ++action_iter) { | 108 ++action_iter) { |
| 119 if (action_iter->get()->id() == action_id) | 109 if (action_iter->get()->id() == action_id) |
| 120 return action_iter->get(); | 110 return action_iter->get(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 continue; | 169 continue; |
| 180 | 170 |
| 181 results->push_back(action_iter->get()); | 171 results->push_back(action_iter->get()); |
| 182 } | 172 } |
| 183 } | 173 } |
| 184 return true; | 174 return true; |
| 185 } | 175 } |
| 186 | 176 |
| 187 } // namespace | 177 } // namespace |
| 188 | 178 |
| 179 bool IsFallbackTask(const FileBrowserHandler* task) { |
| 180 return (task->extension_id() == kFileBrowserDomain || |
| 181 task->extension_id() == |
| 182 extension_misc::kQuickOfficeComponentExtensionId || |
| 183 task->extension_id() == extension_misc::kQuickOfficeDevExtensionId || |
| 184 task->extension_id() == extension_misc::kQuickOfficeExtensionId); |
| 185 } |
| 186 |
| 189 void UpdateDefaultTask(Profile* profile, | 187 void UpdateDefaultTask(Profile* profile, |
| 190 const std::string& task_id, | 188 const std::string& task_id, |
| 191 const std::set<std::string>& suffixes, | 189 const std::set<std::string>& suffixes, |
| 192 const std::set<std::string>& mime_types) { | 190 const std::set<std::string>& mime_types) { |
| 193 if (!profile || !profile->GetPrefs()) | 191 if (!profile || !profile->GetPrefs()) |
| 194 return; | 192 return; |
| 195 | 193 |
| 196 if (!mime_types.empty()) { | 194 if (!mime_types.empty()) { |
| 197 DictionaryPrefUpdate mime_type_pref(profile->GetPrefs(), | 195 DictionaryPrefUpdate mime_type_pref(profile->GetPrefs(), |
| 198 prefs::kDefaultTasksByMimeType); | 196 prefs::kDefaultTasksByMimeType); |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), | 970 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), |
| 973 action_id_, file_urls[i].path()); | 971 action_id_, file_urls[i].path()); |
| 974 } | 972 } |
| 975 | 973 |
| 976 if (!done.is_null()) | 974 if (!done.is_null()) |
| 977 done.Run(true); | 975 done.Run(true); |
| 978 return true; | 976 return true; |
| 979 } | 977 } |
| 980 | 978 |
| 981 } // namespace file_handler_util | 979 } // namespace file_handler_util |
| OLD | NEW |