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 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 } | 810 } |
811 | 811 |
812 ExtensionTaskExecutor::~ExtensionTaskExecutor() {} | 812 ExtensionTaskExecutor::~ExtensionTaskExecutor() {} |
813 | 813 |
814 bool ExtensionTaskExecutor::ExecuteAndNotify( | 814 bool ExtensionTaskExecutor::ExecuteAndNotify( |
815 const std::vector<FileSystemURL>& file_urls, | 815 const std::vector<FileSystemURL>& file_urls, |
816 const FileTaskFinishedCallback& done) { | 816 const FileTaskFinishedCallback& done) { |
817 if (!FileBrowserHasAccessPermissionForFiles(file_urls)) | 817 if (!FileBrowserHasAccessPermissionForFiles(file_urls)) |
818 return false; | 818 return false; |
819 | 819 |
820 scoped_refptr<const Extension> handler = GetExtension(); | 820 // Find the target extension. |
821 if (!handler.get()) | 821 scoped_refptr<const Extension> extension = GetExtension(); |
| 822 if (!extension.get()) |
822 return false; | 823 return false; |
823 | 824 |
824 int handler_pid = ExtractProcessFromExtensionId(profile(), handler->id()); | 825 // Forbid calling undeclared handlers. |
825 if (handler_pid <= 0) { | 826 if (!FindFileBrowserHandler(extension, action_id_)) |
826 if (!extensions::BackgroundInfo::HasLazyBackgroundPage(handler)) | 827 return false; |
| 828 |
| 829 int extension_pid = ExtractProcessFromExtensionId(profile(), extension->id()); |
| 830 if (extension_pid <= 0) { |
| 831 if (!extensions::BackgroundInfo::HasLazyBackgroundPage(extension)) |
827 return false; | 832 return false; |
828 } | 833 } |
829 | 834 |
830 done_ = done; | 835 done_ = done; |
831 | 836 |
832 // Get file system context for the extension to which onExecute event will be | 837 // Get file system context for the extension to which onExecute event will be |
833 // send. The file access permissions will be granted to the extension in the | 838 // send. The file access permissions will be granted to the extension in the |
834 // file system context for the files in |file_urls|. | 839 // file system context for the files in |file_urls|. |
835 GURL site = extensions::ExtensionSystem::Get(profile())->extension_service()-> | 840 GURL site = extensions::ExtensionSystem::Get(profile())->extension_service()-> |
836 GetSiteForExtensionId(handler->id()); | 841 GetSiteForExtensionId(extension->id()); |
837 scoped_refptr<fileapi::FileSystemContext> file_system_context_handler = | 842 scoped_refptr<fileapi::FileSystemContext> file_system_context_handler = |
838 BrowserContext::GetStoragePartitionForSite(profile(), site)-> | 843 BrowserContext::GetStoragePartitionForSite(profile(), site)-> |
839 GetFileSystemContext(); | 844 GetFileSystemContext(); |
840 | 845 |
841 BrowserThread::PostTask( | 846 BrowserThread::PostTask( |
842 BrowserThread::FILE, FROM_HERE, | 847 BrowserThread::FILE, FROM_HERE, |
843 base::Bind( | 848 base::Bind( |
844 &ExtensionTaskExecutor::RequestFileEntryOnFileThread, | 849 &ExtensionTaskExecutor::RequestFileEntryOnFileThread, |
845 this, | 850 this, |
846 file_system_context_handler, | 851 file_system_context_handler, |
847 Extension::GetBaseURLFromExtensionId(handler->id()), | 852 Extension::GetBaseURLFromExtensionId(extension->id()), |
848 handler, | 853 extension, |
849 handler_pid, | 854 extension_pid, |
850 file_urls)); | 855 file_urls)); |
851 return true; | 856 return true; |
852 } | 857 } |
853 | 858 |
854 void ExtensionTaskExecutor::RequestFileEntryOnFileThread( | 859 void ExtensionTaskExecutor::RequestFileEntryOnFileThread( |
855 scoped_refptr<fileapi::FileSystemContext> file_system_context_handler, | 860 scoped_refptr<fileapi::FileSystemContext> file_system_context_handler, |
856 const GURL& handler_base_url, | 861 const GURL& handler_base_url, |
857 const scoped_refptr<const Extension>& handler, | 862 const scoped_refptr<const Extension>& handler, |
858 int handler_pid, | 863 int handler_pid, |
859 const std::vector<FileSystemURL>& file_urls) { | 864 const std::vector<FileSystemURL>& file_urls) { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), | 1011 extensions::LaunchPlatformAppWithFileHandler(profile(), GetExtension(), |
1007 action_id_, file_urls[i].path()); | 1012 action_id_, file_urls[i].path()); |
1008 } | 1013 } |
1009 | 1014 |
1010 if (!done.is_null()) | 1015 if (!done.is_null()) |
1011 done.Run(true); | 1016 done.Run(true); |
1012 return true; | 1017 return true; |
1013 } | 1018 } |
1014 | 1019 |
1015 } // namespace file_handler_util | 1020 } // namespace file_handler_util |
OLD | NEW |