| 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" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "chrome/browser/chromeos/drive/file_system_util.h" | 13 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 14 #include "chrome/browser/chromeos/drive/file_task_executor.h" | 14 #include "chrome/browser/chromeos/drive/file_task_executor.h" |
| 15 #include "chrome/browser/chromeos/file_manager/app_id.h" | 15 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 16 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" | 16 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
| 17 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 17 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 18 #include "chrome/browser/chromeos/file_manager/open_util.h" | 18 #include "chrome/browser/chromeos/file_manager/open_util.h" |
| 19 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 19 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 20 #include "chrome/browser/drive/drive_api_util.h" |
| 20 #include "chrome/browser/drive/drive_app_registry.h" | 21 #include "chrome/browser/drive/drive_app_registry.h" |
| 21 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
| 22 #include "chrome/browser/extensions/extension_util.h" | 23 #include "chrome/browser/extensions/extension_util.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 25 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 25 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 26 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
| 26 #include "chrome/common/extensions/api/file_browser_private.h" | 27 #include "chrome/common/extensions/api/file_browser_private.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chromeos/chromeos_switches.h" | 29 #include "chromeos/chromeos_switches.h" |
| 29 #include "extensions/browser/extension_host.h" | 30 #include "extensions/browser/extension_host.h" |
| 30 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 31 #include "extensions/browser/extension_system.h" | 32 #include "extensions/browser/extension_system.h" |
| 32 #include "extensions/browser/extension_util.h" | 33 #include "extensions/browser/extension_util.h" |
| 33 #include "extensions/common/constants.h" | 34 #include "extensions/common/constants.h" |
| 34 #include "extensions/common/extension_set.h" | 35 #include "extensions/common/extension_set.h" |
| 35 #include "google_apis/drive/gdata_wapi_parser.h" | |
| 36 #include "webkit/browser/fileapi/file_system_context.h" | 36 #include "webkit/browser/fileapi/file_system_context.h" |
| 37 #include "webkit/browser/fileapi/file_system_url.h" | 37 #include "webkit/browser/fileapi/file_system_url.h" |
| 38 | 38 |
| 39 using extensions::Extension; | 39 using extensions::Extension; |
| 40 using extensions::app_file_handler_util::FindFileHandlersForFiles; | 40 using extensions::app_file_handler_util::FindFileHandlersForFiles; |
| 41 using fileapi::FileSystemURL; | 41 using fileapi::FileSystemURL; |
| 42 | 42 |
| 43 namespace file_manager { | 43 namespace file_manager { |
| 44 namespace file_tasks { | 44 namespace file_tasks { |
| 45 | 45 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 // Legacy Drive task extension prefix, used by CrackTaskID. | 84 // Legacy Drive task extension prefix, used by CrackTaskID. |
| 85 const char kDriveTaskExtensionPrefix[] = "drive-app:"; | 85 const char kDriveTaskExtensionPrefix[] = "drive-app:"; |
| 86 const size_t kDriveTaskExtensionPrefixLength = | 86 const size_t kDriveTaskExtensionPrefixLength = |
| 87 arraysize(kDriveTaskExtensionPrefix) - 1; | 87 arraysize(kDriveTaskExtensionPrefix) - 1; |
| 88 | 88 |
| 89 // Returns true if path_mime_set contains a Google document. | 89 // Returns true if path_mime_set contains a Google document. |
| 90 bool ContainsGoogleDocument(const PathAndMimeTypeSet& path_mime_set) { | 90 bool ContainsGoogleDocument(const PathAndMimeTypeSet& path_mime_set) { |
| 91 for (PathAndMimeTypeSet::const_iterator iter = path_mime_set.begin(); | 91 for (PathAndMimeTypeSet::const_iterator iter = path_mime_set.begin(); |
| 92 iter != path_mime_set.end(); ++iter) { | 92 iter != path_mime_set.end(); ++iter) { |
| 93 if (google_apis::ResourceEntry::ClassifyEntryKindByFileExtension( | 93 std::string extension = |
| 94 iter->first) & | 94 base::FilePath(iter->first.Extension()).AsUTF8Unsafe(); |
| 95 google_apis::ResourceEntry::KIND_OF_GOOGLE_DOCUMENT) { | 95 if (drive::util::IsHostedDocumentByExtension(extension)) |
| 96 return true; | 96 return true; |
| 97 } | |
| 98 } | 97 } |
| 99 return false; | 98 return false; |
| 100 } | 99 } |
| 101 | 100 |
| 102 // Leaves tasks handled by the file manger itself as is and removes all others. | 101 // Leaves tasks handled by the file manger itself as is and removes all others. |
| 103 void KeepOnlyFileManagerInternalTasks(std::vector<FullTaskDescriptor>* tasks) { | 102 void KeepOnlyFileManagerInternalTasks(std::vector<FullTaskDescriptor>* tasks) { |
| 104 std::vector<FullTaskDescriptor> filtered; | 103 std::vector<FullTaskDescriptor> filtered; |
| 105 for (size_t i = 0; i < tasks->size(); ++i) { | 104 for (size_t i = 0; i < tasks->size(); ++i) { |
| 106 if ((*tasks)[i].task_descriptor().app_id == kFileManagerAppId) | 105 if ((*tasks)[i].task_descriptor().app_id == kFileManagerAppId) |
| 107 filtered.push_back((*tasks)[i]); | 106 filtered.push_back((*tasks)[i]); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 if (file_browser_handlers::IsFallbackFileBrowserHandler( | 527 if (file_browser_handlers::IsFallbackFileBrowserHandler( |
| 529 task->task_descriptor())) { | 528 task->task_descriptor())) { |
| 530 task->set_is_default(true); | 529 task->set_is_default(true); |
| 531 return; | 530 return; |
| 532 } | 531 } |
| 533 } | 532 } |
| 534 } | 533 } |
| 535 | 534 |
| 536 } // namespace file_tasks | 535 } // namespace file_tasks |
| 537 } // namespace file_manager | 536 } // namespace file_manager |
| OLD | NEW |