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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 const std::string& extension_id, | 565 const std::string& extension_id, |
566 const std::string& task_type, | 566 const std::string& task_type, |
567 const std::string& action_id) { | 567 const std::string& action_id) { |
568 if (task_type == kTaskFile) | 568 if (task_type == kTaskFile) |
569 return new ExtensionTaskExecutor(profile, | 569 return new ExtensionTaskExecutor(profile, |
570 source_url, | 570 source_url, |
571 extension_id, | 571 extension_id, |
572 action_id); | 572 action_id); |
573 | 573 |
574 if (task_type == kTaskDrive) | 574 if (task_type == kTaskDrive) |
575 return new gdata::DriveTaskExecutor(profile, | 575 return new drive::DriveTaskExecutor(profile, |
576 extension_id, // really app_id | 576 extension_id, // really app_id |
577 action_id); | 577 action_id); |
578 | 578 |
579 if (task_type == kTaskWebIntent) | 579 if (task_type == kTaskWebIntent) |
580 return new WebIntentTaskExecutor(profile, | 580 return new WebIntentTaskExecutor(profile, |
581 source_url, | 581 source_url, |
582 extension_id, | 582 extension_id, |
583 action_id); | 583 action_id); |
584 | 584 |
585 NOTREACHED(); | 585 NOTREACHED(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 return false; | 730 return false; |
731 } | 731 } |
732 | 732 |
733 // Check if this file system entry exists first. | 733 // Check if this file system entry exists first. |
734 base::PlatformFileInfo file_info; | 734 base::PlatformFileInfo file_info; |
735 | 735 |
736 FilePath local_path = url.path(); | 736 FilePath local_path = url.path(); |
737 FilePath virtual_path = url.virtual_path(); | 737 FilePath virtual_path = url.virtual_path(); |
738 | 738 |
739 bool is_drive_file = url.type() == fileapi::kFileSystemTypeDrive; | 739 bool is_drive_file = url.type() == fileapi::kFileSystemTypeDrive; |
740 DCHECK(!is_drive_file || gdata::util::IsUnderDriveMountPoint(local_path)); | 740 DCHECK(!is_drive_file || drive::util::IsUnderDriveMountPoint(local_path)); |
741 | 741 |
742 // If the file is under gdata mount point, there is no actual file to be | 742 // If the file is under gdata mount point, there is no actual file to be |
743 // found on the url.path(). | 743 // found on the url.path(). |
744 if (!is_drive_file) { | 744 if (!is_drive_file) { |
745 if (!file_util::PathExists(local_path) || | 745 if (!file_util::PathExists(local_path) || |
746 file_util::IsLink(local_path) || | 746 file_util::IsLink(local_path) || |
747 !file_util::GetFileInfo(local_path, &file_info)) { | 747 !file_util::GetFileInfo(local_path, &file_info)) { |
748 return false; | 748 return false; |
749 } | 749 } |
750 } | 750 } |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 973 |
974 scoped_ptr<std::vector<FilePath> > gdata_paths(new std::vector<FilePath>); | 974 scoped_ptr<std::vector<FilePath> > gdata_paths(new std::vector<FilePath>); |
975 for (FileDefinitionList::const_iterator iter = file_list.begin(); | 975 for (FileDefinitionList::const_iterator iter = file_list.begin(); |
976 iter != file_list.end(); | 976 iter != file_list.end(); |
977 ++iter) { | 977 ++iter) { |
978 // Setup permission for file's absolute file. | 978 // Setup permission for file's absolute file. |
979 handler_host_permissions_.push_back(std::make_pair(iter->absolute_path, | 979 handler_host_permissions_.push_back(std::make_pair(iter->absolute_path, |
980 GetAccessPermissionsForFileBrowserHandler(handler_extension, | 980 GetAccessPermissionsForFileBrowserHandler(handler_extension, |
981 action_id_))); | 981 action_id_))); |
982 | 982 |
983 if (gdata::util::IsUnderDriveMountPoint(iter->absolute_path)) | 983 if (drive::util::IsUnderDriveMountPoint(iter->absolute_path)) |
984 gdata_paths->push_back(iter->virtual_path); | 984 gdata_paths->push_back(iter->virtual_path); |
985 } | 985 } |
986 | 986 |
987 if (gdata_paths->empty()) { | 987 if (gdata_paths->empty()) { |
988 // Invoke callback if none of the files are on gdata mount point. | 988 // Invoke callback if none of the files are on gdata mount point. |
989 callback.Run(); | 989 callback.Run(); |
990 return; | 990 return; |
991 } | 991 } |
992 | 992 |
993 // For files on gdata mount point, we'll have to give handler host permissions | 993 // For files on gdata mount point, we'll have to give handler host permissions |
994 // for their cache paths. This has to be called on UI thread. | 994 // for their cache paths. This has to be called on UI thread. |
995 gdata::util::InsertDriveCachePathsPermissions(profile(), | 995 drive::util::InsertDriveCachePathsPermissions(profile(), |
996 gdata_paths.Pass(), | 996 gdata_paths.Pass(), |
997 &handler_host_permissions_, | 997 &handler_host_permissions_, |
998 callback); | 998 callback); |
999 } | 999 } |
1000 | 1000 |
1001 void ExtensionTaskExecutor::SetupHandlerHostFileAccessPermissions( | 1001 void ExtensionTaskExecutor::SetupHandlerHostFileAccessPermissions( |
1002 int handler_pid) { | 1002 int handler_pid) { |
1003 for (size_t i = 0; i < handler_host_permissions_.size(); i++) { | 1003 for (size_t i = 0; i < handler_host_permissions_.size(); i++) { |
1004 content::ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( | 1004 content::ChildProcessSecurityPolicy::GetInstance()->GrantPermissionsForFile( |
1005 handler_pid, | 1005 handler_pid, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 // Make sure this url really being used by the right caller extension. | 1056 // Make sure this url really being used by the right caller extension. |
1057 if (source_url_.GetOrigin() != url.origin()) | 1057 if (source_url_.GetOrigin() != url.origin()) |
1058 return false; | 1058 return false; |
1059 | 1059 |
1060 FilePath local_path = url.path(); | 1060 FilePath local_path = url.path(); |
1061 extensions::LaunchPlatformAppWithPath(profile(), GetExtension(), local_path); | 1061 extensions::LaunchPlatformAppWithPath(profile(), GetExtension(), local_path); |
1062 return true; | 1062 return true; |
1063 } | 1063 } |
1064 | 1064 |
1065 } // namespace file_handler_util | 1065 } // namespace file_handler_util |
OLD | NEW |