Chromium Code Reviews| 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_handler_util.h" | 5 #include "chrome/browser/chromeos/extensions/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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 using extensions::Extension; | 50 using extensions::Extension; |
| 51 | 51 |
| 52 namespace file_handler_util { | 52 namespace file_handler_util { |
| 53 | 53 |
| 54 const char kTaskFile[] = "file"; | 54 const char kTaskFile[] = "file"; |
| 55 const char kTaskDrive[] = "drive"; | 55 const char kTaskDrive[] = "drive"; |
| 56 const char kTaskWebIntent[] = "web-intent"; | 56 const char kTaskWebIntent[] = "web-intent"; |
| 57 | 57 |
| 58 namespace { | 58 namespace { |
| 59 | 59 |
| 60 typedef std::set<const FileBrowserHandler*> FileBrowserHandlerSet; | |
| 61 | |
| 60 // Legacy Drive task extension prefix, used by CrackTaskID. | 62 // Legacy Drive task extension prefix, used by CrackTaskID. |
| 61 const char kDriveTaskExtensionPrefix[] = "drive-app:"; | 63 const char kDriveTaskExtensionPrefix[] = "drive-app:"; |
| 62 const size_t kDriveTaskExtensionPrefixLength = | 64 const size_t kDriveTaskExtensionPrefixLength = |
| 63 arraysize(kDriveTaskExtensionPrefix) - 1; | 65 arraysize(kDriveTaskExtensionPrefix) - 1; |
| 64 | 66 |
| 65 typedef std::set<const FileBrowserHandler*> FileBrowserHandlerSet; | 67 const char kOemMountPointID[] = "oem"; |
| 66 | 68 |
| 67 const int kReadWriteFilePermissions = base::PLATFORM_FILE_OPEN | | 69 const int kReadWriteFilePermissions = base::PLATFORM_FILE_OPEN | |
| 68 base::PLATFORM_FILE_CREATE | | 70 base::PLATFORM_FILE_CREATE | |
| 69 base::PLATFORM_FILE_OPEN_ALWAYS | | 71 base::PLATFORM_FILE_OPEN_ALWAYS | |
| 70 base::PLATFORM_FILE_CREATE_ALWAYS | | 72 base::PLATFORM_FILE_CREATE_ALWAYS | |
| 71 base::PLATFORM_FILE_OPEN_TRUNCATED | | 73 base::PLATFORM_FILE_OPEN_TRUNCATED | |
| 72 base::PLATFORM_FILE_READ | | 74 base::PLATFORM_FILE_READ | |
| 73 base::PLATFORM_FILE_WRITE | | 75 base::PLATFORM_FILE_WRITE | |
| 74 base::PLATFORM_FILE_EXCLUSIVE_READ | | 76 base::PLATFORM_FILE_EXCLUSIVE_READ | |
| 75 base::PLATFORM_FILE_EXCLUSIVE_WRITE | | 77 base::PLATFORM_FILE_EXCLUSIVE_WRITE | |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 712 if (!handler_extension_.get()) | 714 if (!handler_extension_.get()) |
| 713 return false; | 715 return false; |
| 714 | 716 |
| 715 if (handler_pid_ == 0) | 717 if (handler_pid_ == 0) |
| 716 return false; | 718 return false; |
| 717 | 719 |
| 718 fileapi::FileSystemURL url(origin_file_url); | 720 fileapi::FileSystemURL url(origin_file_url); |
| 719 if (!chromeos::CrosMountPointProvider::CanHandleURL(url)) | 721 if (!chromeos::CrosMountPointProvider::CanHandleURL(url)) |
| 720 return false; | 722 return false; |
| 721 | 723 |
| 724 if (url.filesystem_id() == kOemMountPointID) { | |
|
zel
2012/09/27 20:11:10
let's create a more general concept of read-only m
| |
| 725 LOG(ERROR) << "Can't grant permissions for oem mount point."; | |
| 726 return false; | |
| 727 } | |
| 728 | |
| 722 fileapi::ExternalFileSystemMountPointProvider* external_provider = | 729 fileapi::ExternalFileSystemMountPointProvider* external_provider = |
| 723 file_system_context_->external_provider(); | 730 file_system_context_->external_provider(); |
| 724 if (!external_provider || !external_provider->IsAccessAllowed(url)) | 731 if (!external_provider || !external_provider->IsAccessAllowed(url)) |
| 725 return false; | 732 return false; |
| 726 | 733 |
| 727 // Make sure this url really being used by the right caller extension. | 734 // Make sure this url really being used by the right caller extension. |
| 728 if (source_url_.GetOrigin() != url.origin()) { | 735 if (source_url_.GetOrigin() != url.origin()) { |
| 729 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 736 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 730 return false; | 737 return false; |
| 731 } | 738 } |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 done.Run(success); | 1045 done.Run(success); |
| 1039 | 1046 |
| 1040 return true; | 1047 return true; |
| 1041 } | 1048 } |
| 1042 | 1049 |
| 1043 bool WebIntentTaskExecutor::ExecuteForURL(const GURL& file_url) { | 1050 bool WebIntentTaskExecutor::ExecuteForURL(const GURL& file_url) { |
| 1044 fileapi::FileSystemURL url(file_url); | 1051 fileapi::FileSystemURL url(file_url); |
| 1045 if (!chromeos::CrosMountPointProvider::CanHandleURL(url)) | 1052 if (!chromeos::CrosMountPointProvider::CanHandleURL(url)) |
| 1046 return false; | 1053 return false; |
| 1047 | 1054 |
| 1055 if (url.filesystem_id() == kOemMountPointID) { | |
| 1056 LOG(ERROR) << "Can't grant permissions for oem mount point."; | |
| 1057 return false; | |
| 1058 } | |
| 1059 | |
| 1048 scoped_refptr<fileapi::FileSystemContext> file_system_context = | 1060 scoped_refptr<fileapi::FileSystemContext> file_system_context = |
| 1049 BrowserContext::GetDefaultStoragePartition(profile())-> | 1061 BrowserContext::GetDefaultStoragePartition(profile())-> |
| 1050 GetFileSystemContext(); | 1062 GetFileSystemContext(); |
| 1051 fileapi::ExternalFileSystemMountPointProvider* external_provider = | 1063 fileapi::ExternalFileSystemMountPointProvider* external_provider = |
| 1052 file_system_context->external_provider(); | 1064 file_system_context->external_provider(); |
| 1053 if (!external_provider || !external_provider->IsAccessAllowed(url)) | 1065 if (!external_provider || !external_provider->IsAccessAllowed(url)) |
| 1054 return false; | 1066 return false; |
| 1055 | 1067 |
| 1056 // Make sure this url really being used by the right caller extension. | 1068 // Make sure this url really being used by the right caller extension. |
| 1057 if (source_url_.GetOrigin() != url.origin()) | 1069 if (source_url_.GetOrigin() != url.origin()) |
| 1058 return false; | 1070 return false; |
| 1059 | 1071 |
| 1060 FilePath local_path = url.path(); | 1072 FilePath local_path = url.path(); |
| 1061 extensions::LaunchPlatformAppWithPath(profile(), GetExtension(), local_path); | 1073 extensions::LaunchPlatformAppWithPath(profile(), GetExtension(), local_path); |
| 1062 return true; | 1074 return true; |
| 1063 } | 1075 } |
| 1064 | 1076 |
| 1065 } // namespace file_handler_util | 1077 } // namespace file_handler_util |
| OLD | NEW |