| 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_browser_handlers.h" | 5 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/chromeos/drive/file_system_util.h" | 11 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 12 #include "chrome/browser/chromeos/file_manager/app_id.h" | 12 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 13 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 13 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
| 14 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" | 14 #include "chrome/browser/chromeos/file_manager/open_with_browser.h" |
| 15 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 15 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_util.h" | 17 #include "chrome/browser/extensions/extension_util.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" | 20 #include "chrome/common/extensions/api/file_browser_handlers/file_browser_handle
r.h" |
| 21 #include "chrome/common/extensions/api/file_browser_private.h" | 21 #include "chrome/common/extensions/api/file_manager_private.h" |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/child_process_security_policy.h" | 23 #include "content/public/browser/child_process_security_policy.h" |
| 24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/site_instance.h" | 25 #include "content/public/browser/site_instance.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "extensions/browser/event_router.h" | 27 #include "extensions/browser/event_router.h" |
| 28 #include "extensions/browser/extension_host.h" | 28 #include "extensions/browser/extension_host.h" |
| 29 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
| 30 #include "extensions/browser/extension_util.h" | 30 #include "extensions/browser/extension_util.h" |
| 31 #include "extensions/browser/lazy_background_task_queue.h" | 31 #include "extensions/browser/lazy_background_task_queue.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 base::Bind(&FileBrowserHandlerExecutor::ExecuteFileActionsOnUIThread, | 296 base::Bind(&FileBrowserHandlerExecutor::ExecuteFileActionsOnUIThread, |
| 297 weak_ptr_factory_.GetWeakPtr(), | 297 weak_ptr_factory_.GetWeakPtr(), |
| 298 base::Passed(&file_definition_list))); | 298 base::Passed(&file_definition_list))); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void FileBrowserHandlerExecutor::ExecuteDoneOnUIThread(bool success) { | 301 void FileBrowserHandlerExecutor::ExecuteDoneOnUIThread(bool success) { |
| 302 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 302 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 303 if (!done_.is_null()) | 303 if (!done_.is_null()) |
| 304 done_.Run( | 304 done_.Run( |
| 305 success | 305 success |
| 306 ? extensions::api::file_browser_private::TASK_RESULT_MESSAGE_SENT | 306 ? extensions::api::file_manager_private::TASK_RESULT_MESSAGE_SENT |
| 307 : extensions::api::file_browser_private::TASK_RESULT_FAILED); | 307 : extensions::api::file_manager_private::TASK_RESULT_FAILED); |
| 308 delete this; | 308 delete this; |
| 309 } | 309 } |
| 310 | 310 |
| 311 void FileBrowserHandlerExecutor::ExecuteFileActionsOnUIThread( | 311 void FileBrowserHandlerExecutor::ExecuteFileActionsOnUIThread( |
| 312 scoped_ptr<FileDefinitionList> file_definition_list, | 312 scoped_ptr<FileDefinitionList> file_definition_list, |
| 313 scoped_ptr<EntryDefinitionList> entry_definition_list) { | 313 scoped_ptr<EntryDefinitionList> entry_definition_list) { |
| 314 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 314 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 315 | 315 |
| 316 if (file_definition_list->empty() || entry_definition_list->empty()) { | 316 if (file_definition_list->empty() || entry_definition_list->empty()) { |
| 317 ExecuteDoneOnUIThread(false); | 317 ExecuteDoneOnUIThread(false); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 const file_tasks::FileTaskFinishedCallback& done) { | 466 const file_tasks::FileTaskFinishedCallback& done) { |
| 467 // Forbid calling undeclared handlers. | 467 // Forbid calling undeclared handlers. |
| 468 if (!FindFileBrowserHandlerForActionId(extension, action_id)) | 468 if (!FindFileBrowserHandlerForActionId(extension, action_id)) |
| 469 return false; | 469 return false; |
| 470 | 470 |
| 471 // Some action IDs of the file manager's file browser handlers require the | 471 // Some action IDs of the file manager's file browser handlers require the |
| 472 // files to be directly opened with the browser. | 472 // files to be directly opened with the browser. |
| 473 if (ShouldBeOpenedWithBrowser(extension->id(), action_id)) { | 473 if (ShouldBeOpenedWithBrowser(extension->id(), action_id)) { |
| 474 const bool result = OpenFilesWithBrowser(profile, file_urls); | 474 const bool result = OpenFilesWithBrowser(profile, file_urls); |
| 475 if (result && !done.is_null()) | 475 if (result && !done.is_null()) |
| 476 done.Run(extensions::api::file_browser_private::TASK_RESULT_OPENED); | 476 done.Run(extensions::api::file_manager_private::TASK_RESULT_OPENED); |
| 477 return result; | 477 return result; |
| 478 } | 478 } |
| 479 | 479 |
| 480 // The executor object will be self deleted on completion. | 480 // The executor object will be self deleted on completion. |
| 481 (new FileBrowserHandlerExecutor( | 481 (new FileBrowserHandlerExecutor( |
| 482 profile, extension, action_id))->Execute(file_urls, done); | 482 profile, extension, action_id))->Execute(file_urls, done); |
| 483 return true; | 483 return true; |
| 484 } | 484 } |
| 485 | 485 |
| 486 FileBrowserHandlerList FindFileBrowserHandlers( | 486 FileBrowserHandlerList FindFileBrowserHandlers( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 516 if (common_handlers.empty()) | 516 if (common_handlers.empty()) |
| 517 return FileBrowserHandlerList(); | 517 return FileBrowserHandlerList(); |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 return common_handlers; | 521 return common_handlers; |
| 522 } | 522 } |
| 523 | 523 |
| 524 } // namespace file_browser_handlers | 524 } // namespace file_browser_handlers |
| 525 } // namespace file_manager | 525 } // namespace file_manager |
| OLD | NEW |