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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 const scoped_refptr<const Extension>& handler_extension, | 706 const scoped_refptr<const Extension>& handler_extension, |
707 int handler_pid, | 707 int handler_pid, |
708 const std::string& action_id, | 708 const std::string& action_id, |
709 const std::vector<FileSystemURL>& file_urls) | 709 const std::vector<FileSystemURL>& file_urls) |
710 : executor_(executor), | 710 : executor_(executor), |
711 file_system_context_handler_(file_system_context_handler), | 711 file_system_context_handler_(file_system_context_handler), |
712 handler_extension_(handler_extension), | 712 handler_extension_(handler_extension), |
713 handler_pid_(handler_pid), | 713 handler_pid_(handler_pid), |
714 action_id_(action_id), | 714 action_id_(action_id), |
715 urls_(file_urls) { | 715 urls_(file_urls) { |
716 DCHECK(executor_); | 716 DCHECK(executor_.get()); |
717 } | 717 } |
718 | 718 |
719 // Checks legitimacy of file url and grants file RO access permissions from | 719 // Checks legitimacy of file url and grants file RO access permissions from |
720 // handler (target) extension and its renderer process. | 720 // handler (target) extension and its renderer process. |
721 bool SetupFileAccessPermissions(const FileSystemURL& url, | 721 bool SetupFileAccessPermissions(const FileSystemURL& url, |
722 FileDefinition* file) { | 722 FileDefinition* file) { |
723 if (!handler_extension_.get()) | 723 if (!handler_extension_.get()) |
724 return false; | 724 return false; |
725 | 725 |
726 if (handler_pid_ == 0) | 726 if (handler_pid_ == 0) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 const FileTaskFinishedCallback& done) { | 789 const FileTaskFinishedCallback& done) { |
790 if (!FileBrowserHasAccessPermissionForFiles(file_urls)) | 790 if (!FileBrowserHasAccessPermissionForFiles(file_urls)) |
791 return false; | 791 return false; |
792 | 792 |
793 // Find the target extension. | 793 // Find the target extension. |
794 scoped_refptr<const Extension> extension = GetExtension(); | 794 scoped_refptr<const Extension> extension = GetExtension(); |
795 if (!extension.get()) | 795 if (!extension.get()) |
796 return false; | 796 return false; |
797 | 797 |
798 // Forbid calling undeclared handlers. | 798 // Forbid calling undeclared handlers. |
799 if (!FindFileBrowserHandler(extension, action_id_)) | 799 if (!FindFileBrowserHandler(extension.get(), action_id_)) |
800 return false; | 800 return false; |
801 | 801 |
802 int extension_pid = ExtractProcessFromExtensionId(profile(), extension->id()); | 802 int extension_pid = ExtractProcessFromExtensionId(profile(), extension->id()); |
803 if (extension_pid <= 0) { | 803 if (extension_pid <= 0) { |
804 if (!extensions::BackgroundInfo::HasLazyBackgroundPage(extension)) | 804 if (!extensions::BackgroundInfo::HasLazyBackgroundPage(extension.get())) |
805 return false; | 805 return false; |
806 } | 806 } |
807 | 807 |
808 done_ = done; | 808 done_ = done; |
809 | 809 |
810 // Get file system context for the extension to which onExecute event will be | 810 // Get file system context for the extension to which onExecute event will be |
811 // send. The file access permissions will be granted to the extension in the | 811 // send. The file access permissions will be granted to the extension in the |
812 // file system context for the files in |file_urls|. | 812 // file system context for the files in |file_urls|. |
813 GURL site = extensions::ExtensionSystem::Get(profile())->extension_service()-> | 813 GURL site = extensions::ExtensionSystem::Get(profile())->extension_service()-> |
814 GetSiteForExtensionId(extension->id()); | 814 GetSiteForExtensionId(extension->id()); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), | 970 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), |
971 action_id_, file_urls[i].path()); | 971 action_id_, file_urls[i].path()); |
972 } | 972 } |
973 | 973 |
974 if (!done.is_null()) | 974 if (!done.is_null()) |
975 done.Run(true); | 975 done.Run(true); |
976 return true; | 976 return true; |
977 } | 977 } |
978 | 978 |
979 } // namespace file_handler_util | 979 } // namespace file_handler_util |
OLD | NEW |