| 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_tasks.h" | 5 #include "chrome/browser/chromeos/extensions/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" |
| 11 #include "chrome/browser/chromeos/drive/drive_app_registry.h" | 11 #include "chrome/browser/chromeos/drive/drive_app_registry.h" |
| 12 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 12 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 13 #include "chrome/browser/chromeos/drive/file_task_executor.h" | 14 #include "chrome/browser/chromeos/drive/file_task_executor.h" |
| 14 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handlers.
h" | 15 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handlers.
h" |
| 15 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h" | 16 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h" |
| 16 #include "chrome/browser/chromeos/extensions/file_manager/open_util.h" | 17 #include "chrome/browser/chromeos/extensions/file_manager/open_util.h" |
| 17 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 18 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 18 #include "chrome/browser/extensions/extension_host.h" | 19 #include "chrome/browser/extensions/extension_host.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_system.h" | 22 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/extensions/extension_system.h" | 23 #include "chrome/browser/extensions/extension_system.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 icon_url_(icon_url), | 125 icon_url_(icon_url), |
| 125 is_default_(is_default){ | 126 is_default_(is_default){ |
| 126 } | 127 } |
| 127 | 128 |
| 128 scoped_ptr<base::DictionaryValue> | 129 scoped_ptr<base::DictionaryValue> |
| 129 FullTaskDescriptor::AsDictionaryValue() const { | 130 FullTaskDescriptor::AsDictionaryValue() const { |
| 130 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); | 131 scoped_ptr<base::DictionaryValue> dictionary(new base::DictionaryValue); |
| 131 dictionary->SetString("taskId", TaskDescriptorToId(task_descriptor_)); | 132 dictionary->SetString("taskId", TaskDescriptorToId(task_descriptor_)); |
| 132 if (!icon_url_.is_empty()) | 133 if (!icon_url_.is_empty()) |
| 133 dictionary->SetString("iconUrl", icon_url_.spec()); | 134 dictionary->SetString("iconUrl", icon_url_.spec()); |
| 134 dictionary->SetBoolean("driveApp", | |
| 135 task_descriptor_.task_type == TASK_TYPE_DRIVE_APP); | |
| 136 dictionary->SetString("title", task_title_); | 135 dictionary->SetString("title", task_title_); |
| 137 dictionary->SetBoolean("isDefault", is_default_); | 136 dictionary->SetBoolean("isDefault", is_default_); |
| 138 return dictionary.Pass(); | 137 return dictionary.Pass(); |
| 139 } | 138 } |
| 140 | 139 |
| 141 void UpdateDefaultTask(PrefService* pref_service, | 140 void UpdateDefaultTask(PrefService* pref_service, |
| 142 const std::string& task_id, | 141 const std::string& task_id, |
| 143 const std::set<std::string>& suffixes, | 142 const std::set<std::string>& suffixes, |
| 144 const std::set<std::string>& mime_types) { | 143 const std::set<std::string>& mime_types) { |
| 145 if (!pref_service) | 144 if (!pref_service) |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 DCHECK(result_list); | 311 DCHECK(result_list); |
| 313 | 312 |
| 314 bool is_first = true; | 313 bool is_first = true; |
| 315 typedef std::map<std::string, drive::DriveAppInfo> DriveAppInfoMap; | 314 typedef std::map<std::string, drive::DriveAppInfo> DriveAppInfoMap; |
| 316 DriveAppInfoMap drive_app_map; | 315 DriveAppInfoMap drive_app_map; |
| 317 | 316 |
| 318 for (PathAndMimeTypeSet::const_iterator it = path_mime_set.begin(); | 317 for (PathAndMimeTypeSet::const_iterator it = path_mime_set.begin(); |
| 319 it != path_mime_set.end(); ++it) { | 318 it != path_mime_set.end(); ++it) { |
| 320 const base::FilePath& file_path = it->first; | 319 const base::FilePath& file_path = it->first; |
| 321 const std::string& mime_type = it->second; | 320 const std::string& mime_type = it->second; |
| 322 if (file_path.empty()) | 321 // Return immediately if a file not on Drive is found, as Drive app tasks |
| 323 continue; | 322 // work only if all files are on Drive. |
| 323 if (!drive::util::IsUnderDriveMountPoint(file_path)) |
| 324 return; |
| 324 | 325 |
| 325 ScopedVector<drive::DriveAppInfo> app_info_list; | 326 ScopedVector<drive::DriveAppInfo> app_info_list; |
| 326 drive_app_registry.GetAppsForFile(file_path.Extension(), | 327 drive_app_registry.GetAppsForFile(file_path.Extension(), |
| 327 mime_type, | 328 mime_type, |
| 328 &app_info_list); | 329 &app_info_list); |
| 329 | 330 |
| 330 if (is_first) { | 331 if (is_first) { |
| 331 // For the first file, we store all the info. | 332 // For the first file, we store all the info. |
| 332 for (size_t j = 0; j < app_info_list.size(); ++j) { | 333 for (size_t j = 0; j < app_info_list.size(); ++j) { |
| 333 const drive::DriveAppInfo& app_info = *app_info_list[j]; | 334 const drive::DriveAppInfo& app_info = *app_info_list[j]; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 if (file_browser_handlers::IsFallbackFileBrowserHandler( | 551 if (file_browser_handlers::IsFallbackFileBrowserHandler( |
| 551 task->task_descriptor())) { | 552 task->task_descriptor())) { |
| 552 task->set_is_default(true); | 553 task->set_is_default(true); |
| 553 return; | 554 return; |
| 554 } | 555 } |
| 555 } | 556 } |
| 556 } | 557 } |
| 557 | 558 |
| 558 } // namespace file_tasks | 559 } // namespace file_tasks |
| 559 } // namespace file_manager | 560 } // namespace file_manager |
| OLD | NEW |