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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 RequestLocalFileSystemFunction* function, | 182 RequestLocalFileSystemFunction* function, |
| 183 Profile* profile, | 183 Profile* profile, |
| 184 int child_id, | 184 int child_id, |
| 185 scoped_refptr<const Extension> extension) | 185 scoped_refptr<const Extension> extension) |
| 186 : function_(function), | 186 : function_(function), |
| 187 profile_(profile), | 187 profile_(profile), |
| 188 child_id_(child_id), | 188 child_id_(child_id), |
| 189 extension_(extension) { | 189 extension_(extension) { |
| 190 DCHECK(function_); | 190 DCHECK(function_); |
| 191 } | 191 } |
| 192 | 192 |
|
ericu
2011/04/20 02:23:46
This comment should have stayed.
zel
2011/04/20 02:49:57
Done.
| |
| 193 // fileapi::FileSystemCallbackDispatcher overrides. | |
| 194 virtual void DidSucceed() OVERRIDE { | 193 virtual void DidSucceed() OVERRIDE { |
| 195 NOTREACHED(); | 194 NOTREACHED(); |
| 196 } | 195 } |
| 197 | 196 |
| 197 virtual void DidGetLocalPath(const FilePath& local_path) { | |
| 198 NOTREACHED(); | |
| 199 } | |
| 200 | |
| 198 virtual void DidReadMetadata(const base::PlatformFileInfo& info, | 201 virtual void DidReadMetadata(const base::PlatformFileInfo& info, |
| 199 const FilePath& unused) OVERRIDE { | 202 const FilePath& unused) OVERRIDE { |
| 200 NOTREACHED(); | 203 NOTREACHED(); |
| 201 } | 204 } |
| 202 | 205 |
| 203 virtual void DidReadDirectory( | 206 virtual void DidReadDirectory( |
| 204 const std::vector<base::FileUtilProxy::Entry>& entries, | 207 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 205 bool has_more) OVERRIDE { | 208 bool has_more) OVERRIDE { |
| 206 NOTREACHED(); | 209 NOTREACHED(); |
| 207 } | 210 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 task_id_(task_id), | 392 task_id_(task_id), |
| 390 origin_file_urls_(file_urls) { | 393 origin_file_urls_(file_urls) { |
| 391 DCHECK(function_); | 394 DCHECK(function_); |
| 392 } | 395 } |
| 393 | 396 |
| 394 // fileapi::FileSystemCallbackDispatcher overrides. | 397 // fileapi::FileSystemCallbackDispatcher overrides. |
| 395 virtual void DidSucceed() OVERRIDE { | 398 virtual void DidSucceed() OVERRIDE { |
| 396 NOTREACHED(); | 399 NOTREACHED(); |
| 397 } | 400 } |
| 398 | 401 |
| 402 virtual void DidGetLocalPath(const FilePath& local_path) { | |
| 403 NOTREACHED(); | |
| 404 } | |
| 405 | |
| 399 virtual void DidReadMetadata(const base::PlatformFileInfo& info, | 406 virtual void DidReadMetadata(const base::PlatformFileInfo& info, |
| 400 const FilePath& unused) OVERRIDE { | 407 const FilePath& unused) OVERRIDE { |
| 401 NOTREACHED(); | 408 NOTREACHED(); |
| 402 } | 409 } |
| 403 | 410 |
| 404 virtual void DidReadDirectory( | 411 virtual void DidReadDirectory( |
| 405 const std::vector<base::FileUtilProxy::Entry>& entries, | 412 const std::vector<base::FileUtilProxy::Entry>& entries, |
| 406 bool has_more) OVERRIDE { | 413 bool has_more) OVERRIDE { |
| 407 NOTREACHED(); | 414 NOTREACHED(); |
| 408 } | 415 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 virtual_path)) { | 477 virtual_path)) { |
| 471 return false; | 478 return false; |
| 472 } | 479 } |
| 473 | 480 |
| 474 // Make sure this url really being used by the right caller extension. | 481 // Make sure this url really being used by the right caller extension. |
| 475 if (source_url_.GetOrigin() != file_origin_url) { | 482 if (source_url_.GetOrigin() != file_origin_url) { |
| 476 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); | 483 DidFail(base::PLATFORM_FILE_ERROR_SECURITY); |
| 477 return false; | 484 return false; |
| 478 } | 485 } |
| 479 | 486 |
| 480 FilePath root_path = path_manager->GetFileSystemRootPathOnFileThread( | 487 FilePath root_path = |
| 481 file_origin_url, | 488 path_manager->ValidateFileSystemRootAndGetPathOnFileThread( |
| 482 fileapi::kFileSystemTypeExternal, | 489 file_origin_url, |
| 483 virtual_path, | 490 fileapi::kFileSystemTypeExternal, |
| 484 false); // create | 491 virtual_path, |
| 492 false); // create | |
| 485 FilePath final_file_path = root_path.Append(virtual_path); | 493 FilePath final_file_path = root_path.Append(virtual_path); |
| 486 | 494 |
| 487 // Check if this file system entry exists first. | 495 // Check if this file system entry exists first. |
| 488 base::PlatformFileInfo file_info; | 496 base::PlatformFileInfo file_info; |
| 489 FilePath platform_path; | 497 FilePath platform_path; |
| 490 fileapi::FileSystemOperationContext file_system_operation_context( | 498 fileapi::FileSystemOperationContext file_system_operation_context( |
| 491 profile_->GetFileSystemContext(), | 499 profile_->GetFileSystemContext(), |
| 492 fileapi::LocalFileSystemFileUtil::GetInstance()); | 500 fileapi::LocalFileSystemFileUtil::GetInstance()); |
| 493 if (base::PLATFORM_FILE_OK != | 501 if (base::PLATFORM_FILE_OK != |
| 494 fileapi::FileSystemFileUtil::GetInstance()->GetFileInfo( | 502 fileapi::FileSystemFileUtil::GetInstance()->GetFileInfo( |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 FilePath virtual_path; | 752 FilePath virtual_path; |
| 745 fileapi::FileSystemType type; | 753 fileapi::FileSystemType type; |
| 746 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, | 754 if (!CrackFileSystemURL(file_url, &file_origin_url, &type, |
| 747 &virtual_path)) { | 755 &virtual_path)) { |
| 748 continue; | 756 continue; |
| 749 } | 757 } |
| 750 if (type != fileapi::kFileSystemTypeExternal) { | 758 if (type != fileapi::kFileSystemTypeExternal) { |
| 751 NOTREACHED(); | 759 NOTREACHED(); |
| 752 continue; | 760 continue; |
| 753 } | 761 } |
| 754 FilePath root = path_manager->GetFileSystemRootPathOnFileThread( | 762 FilePath root = path_manager->ValidateFileSystemRootAndGetPathOnFileThread( |
| 755 origin_url, | 763 origin_url, |
| 756 fileapi::kFileSystemTypeExternal, | 764 fileapi::kFileSystemTypeExternal, |
| 757 FilePath(virtual_path), | 765 FilePath(virtual_path), |
| 758 false); | 766 false); |
| 759 if (!root.empty()) { | 767 if (!root.empty()) { |
| 760 selected_files.push_back(root.Append(virtual_path)); | 768 selected_files.push_back(root.Append(virtual_path)); |
| 761 } else { | 769 } else { |
| 762 LOG(WARNING) << "GetLocalPathsOnFileThread failed " | 770 LOG(WARNING) << "GetLocalPathsOnFileThread failed " |
| 763 << file_url.spec(); | 771 << file_url.spec(); |
| 764 } | 772 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); | 955 SET_STRING(IDS_FILE_BROWSER, COMPUTING_SELECTION); |
| 948 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); | 956 SET_STRING(IDS_FILE_BROWSER, NOTHING_SELECTED); |
| 949 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); | 957 SET_STRING(IDS_FILE_BROWSER, ONE_FILE_SELECTED); |
| 950 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); | 958 SET_STRING(IDS_FILE_BROWSER, MANY_FILES_SELECTED); |
| 951 | 959 |
| 952 #undef SET_STRING | 960 #undef SET_STRING |
| 953 | 961 |
| 954 SendResponse(true); | 962 SendResponse(true); |
| 955 return true; | 963 return true; |
| 956 } | 964 } |
| OLD | NEW |