Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_file_browser_private_api.h" | 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
| 40 #include "webkit/fileapi/file_system_context.h" | 40 #include "webkit/fileapi/file_system_context.h" |
| 41 #include "webkit/fileapi/file_system_mount_point_provider.h" | 41 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 42 #include "webkit/fileapi/file_system_operation.h" | 42 #include "webkit/fileapi/file_system_operation.h" |
| 43 #include "webkit/fileapi/file_system_operation_context.h" | 43 #include "webkit/fileapi/file_system_operation_context.h" |
| 44 #include "webkit/fileapi/file_system_path_manager.h" | 44 #include "webkit/fileapi/file_system_path_manager.h" |
| 45 #include "webkit/fileapi/file_system_types.h" | 45 #include "webkit/fileapi/file_system_types.h" |
| 46 #include "webkit/fileapi/file_system_util.h" | 46 #include "webkit/fileapi/file_system_util.h" |
| 47 #include "webkit/fileapi/file_system_file_util.h" | 47 #include "webkit/fileapi/file_system_file_util.h" |
| 48 #include "webkit/fileapi/local_file_system_file_util.h" | 48 #include "webkit/fileapi/local_file_system_file_util.h" |
| 49 #include "webkit/fileapi/quota_file_util.h" | |
| 49 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
| 50 | 51 |
| 51 #ifdef OS_CHROMEOS | 52 #ifdef OS_CHROMEOS |
| 52 #include "chrome/browser/chromeos/cros/cros_library.h" | 53 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 53 #endif | 54 #endif |
| 54 | 55 |
| 55 // Error messages. | 56 // Error messages. |
| 56 const char kFileError[] = "File error %d"; | 57 const char kFileError[] = "File error %d"; |
| 57 const char kInvalidFileUrl[] = "Invalid file URL"; | 58 const char kInvalidFileUrl[] = "Invalid file URL"; |
| 58 #ifdef OS_CHROMEOS | 59 #ifdef OS_CHROMEOS |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 535 int child_id, | 536 int child_id, |
| 536 const GURL& source_url, | 537 const GURL& source_url, |
| 537 scoped_refptr<const Extension> extension, | 538 scoped_refptr<const Extension> extension, |
| 538 const std::string task_id, | 539 const std::string task_id, |
| 539 const std::vector<GURL>& file_urls) | 540 const std::vector<GURL>& file_urls) |
| 540 : function_(function), | 541 : function_(function), |
| 541 profile_(profile), | 542 profile_(profile), |
| 542 source_url_(source_url), | 543 source_url_(source_url), |
| 543 extension_(extension), | 544 extension_(extension), |
| 544 task_id_(task_id), | 545 task_id_(task_id), |
| 545 origin_file_urls_(file_urls) { | 546 origin_file_urls_(file_urls), |
| 547 local_file_util_(NULL) { | |
| 546 DCHECK(function_); | 548 DCHECK(function_); |
| 547 } | 549 } |
| 548 | 550 |
| 549 // fileapi::FileSystemCallbackDispatcher overrides. | 551 // fileapi::FileSystemCallbackDispatcher overrides. |
| 550 virtual void DidSucceed() OVERRIDE { | 552 virtual void DidSucceed() OVERRIDE { |
| 551 NOTREACHED(); | 553 NOTREACHED(); |
| 552 } | 554 } |
| 553 | 555 |
| 554 virtual void DidReadMetadata(const base::PlatformFileInfo& info, | 556 virtual void DidReadMetadata(const base::PlatformFileInfo& info, |
| 555 const FilePath& unused) OVERRIDE { | 557 const FilePath& unused) OVERRIDE { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 path_manager->ValidateFileSystemRootAndGetPathOnFileThread( | 647 path_manager->ValidateFileSystemRootAndGetPathOnFileThread( |
| 646 file_origin_url, | 648 file_origin_url, |
| 647 fileapi::kFileSystemTypeExternal, | 649 fileapi::kFileSystemTypeExternal, |
| 648 virtual_path, | 650 virtual_path, |
| 649 false); // create | 651 false); // create |
| 650 FilePath final_file_path = root_path.Append(virtual_path); | 652 FilePath final_file_path = root_path.Append(virtual_path); |
| 651 | 653 |
| 652 // Check if this file system entry exists first. | 654 // Check if this file system entry exists first. |
| 653 base::PlatformFileInfo file_info; | 655 base::PlatformFileInfo file_info; |
| 654 FilePath platform_path; | 656 FilePath platform_path; |
| 657 if (!local_file_util_.get()) | |
|
ericu
2011/06/17 20:32:07
Why use lazy initialization? Can we just set this
Dai Mikurube (NOT FULLTIME)
2011/06/23 08:13:32
Agreed. Changed to use external_provider's GetFil
| |
| 658 local_file_util_.reset(new fileapi::LocalFileSystemFileUtil( | |
| 659 fileapi::QuotaFileUtil::GetInstance())); | |
| 655 fileapi::FileSystemOperationContext file_system_operation_context( | 660 fileapi::FileSystemOperationContext file_system_operation_context( |
| 656 profile_->GetFileSystemContext(), | 661 profile_->GetFileSystemContext(), local_file_util_.get()); |
| 657 fileapi::LocalFileSystemFileUtil::GetInstance()); | |
| 658 if (base::PLATFORM_FILE_OK != | 662 if (base::PLATFORM_FILE_OK != |
| 659 fileapi::FileSystemFileUtil::GetInstance()->GetFileInfo( | 663 fileapi::FileSystemFileUtil::GetInstance()->GetFileInfo( |
| 660 &file_system_operation_context, final_file_path, &file_info, | 664 &file_system_operation_context, final_file_path, &file_info, |
| 661 &platform_path)) { | 665 &platform_path)) { |
| 662 return false; | 666 return false; |
| 663 } | 667 } |
| 664 | 668 |
| 665 fileapi::ExternalFileSystemMountPointProvider* external_provider = | 669 fileapi::ExternalFileSystemMountPointProvider* external_provider = |
| 666 path_manager->external_provider(); | 670 path_manager->external_provider(); |
| 667 if (!external_provider) | 671 if (!external_provider) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 return true; | 721 return true; |
| 718 } | 722 } |
| 719 | 723 |
| 720 ExecuteTasksFileBrowserFunction* function_; | 724 ExecuteTasksFileBrowserFunction* function_; |
| 721 Profile* profile_; | 725 Profile* profile_; |
| 722 // Extension source URL. | 726 // Extension source URL. |
| 723 GURL source_url_; | 727 GURL source_url_; |
| 724 scoped_refptr<const Extension> extension_; | 728 scoped_refptr<const Extension> extension_; |
| 725 std::string task_id_; | 729 std::string task_id_; |
| 726 std::vector<GURL> origin_file_urls_; | 730 std::vector<GURL> origin_file_urls_; |
| 731 scoped_ptr<fileapi::LocalFileSystemFileUtil> local_file_util_; | |
| 727 DISALLOW_COPY_AND_ASSIGN(ExecuteTasksFileSystemCallbackDispatcher); | 732 DISALLOW_COPY_AND_ASSIGN(ExecuteTasksFileSystemCallbackDispatcher); |
| 728 }; | 733 }; |
| 729 | 734 |
| 730 bool ExecuteTasksFileBrowserFunction::RunImpl() { | 735 bool ExecuteTasksFileBrowserFunction::RunImpl() { |
| 731 // First param is task id that was to the extension with getFileTasks call. | 736 // First param is task id that was to the extension with getFileTasks call. |
| 732 std::string task_id; | 737 std::string task_id; |
| 733 if (!args_->GetString(0, &task_id) || !task_id.size()) | 738 if (!args_->GetString(0, &task_id) || !task_id.size()) |
| 734 return false; | 739 return false; |
| 735 | 740 |
| 736 // The second param is the list of files that need to be executed with this | 741 // The second param is the list of files that need to be executed with this |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1307 #undef SET_STRING | 1312 #undef SET_STRING |
| 1308 | 1313 |
| 1309 // TODO(serya): Create a new string in .grd file for this one in M13. | 1314 // TODO(serya): Create a new string in .grd file for this one in M13. |
| 1310 dict->SetString("PREVIEW_IMAGE", | 1315 dict->SetString("PREVIEW_IMAGE", |
| 1311 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1316 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
| 1312 dict->SetString("PLAY_MEDIA", | 1317 dict->SetString("PLAY_MEDIA", |
| 1313 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1318 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
| 1314 | 1319 |
| 1315 return true; | 1320 return true; |
| 1316 } | 1321 } |
| OLD | NEW |