Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: content/browser/fileapi/fileapi_message_filter.cc

Issue 11308360: Merge 170159 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/fileapi/fileapi_message_filter.h" 5 #include "content/browser/fileapi/fileapi_message_filter.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 517
518 void FileAPIMessageFilter::OnSyncGetPlatformPath( 518 void FileAPIMessageFilter::OnSyncGetPlatformPath(
519 const GURL& path, FilePath* platform_path) { 519 const GURL& path, FilePath* platform_path) {
520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
521 DCHECK(platform_path); 521 DCHECK(platform_path);
522 *platform_path = FilePath(); 522 *platform_path = FilePath();
523 FileSystemURL url(path); 523 FileSystemURL url(path);
524 if (!url.is_valid()) 524 if (!url.is_valid())
525 return; 525 return;
526 526
527 // Make sure if this file is ok to be read (in the current architecture
528 // which means roughly same as the renderer is allowed to get the platform
529 // path to the file).
530 base::PlatformFileError error;
531 if (!HasPermissionsForFile(url, kReadFilePermissions, &error))
532 return;
533
527 // This is called only by pepper plugin as of writing to get the 534 // This is called only by pepper plugin as of writing to get the
528 // underlying platform path to upload a file in the sandboxed filesystem 535 // underlying platform path to upload a file in the sandboxed filesystem
529 // (e.g. TEMPORARY or PERSISTENT). 536 // (e.g. TEMPORARY or PERSISTENT).
530 // TODO(kinuko): this hack should go away once appropriate upload-stream 537 // TODO(kinuko): this hack should go away once appropriate upload-stream
531 // handling based on element types is supported. 538 // handling based on element types is supported.
532 LocalFileSystemOperation* operation = 539 LocalFileSystemOperation* operation =
533 context_->CreateFileSystemOperation( 540 context_->CreateFileSystemOperation(
534 url, NULL)->AsLocalFileSystemOperation(); 541 url, NULL)->AsLocalFileSystemOperation();
535 DCHECK(operation); 542 DCHECK(operation);
536 if (operation) 543 if (!operation)
537 operation->SyncGetPlatformPath(url, platform_path); 544 return;
545
546 operation->SyncGetPlatformPath(url, platform_path);
547
548 // The path is to be attached to URLLoader so we grant read permission
549 // for the file. (We first need to check if it can already be read not to
550 // overwrite existing permissions)
551 if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
552 process_id_, *platform_path)) {
553 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
554 process_id_, *platform_path);
555 }
538 } 556 }
539 557
540 void FileAPIMessageFilter::OnCreateSnapshotFile( 558 void FileAPIMessageFilter::OnCreateSnapshotFile(
541 int request_id, const GURL& blob_url, const GURL& path) { 559 int request_id, const GURL& blob_url, const GURL& path) {
542 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 560 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
543 FileSystemURL url(path); 561 FileSystemURL url(path);
544 base::Callback<void(const FilePath&)> register_file_callback = 562 base::Callback<void(const FilePath&)> register_file_callback =
545 base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob, 563 base::Bind(&FileAPIMessageFilter::RegisterFileAsBlob,
546 this, blob_url, url.path()); 564 this, blob_url, url.path());
547 565
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 830
813 // Access permission to the file system overrides the file permission 831 // Access permission to the file system overrides the file permission
814 // (if and only if they accessed via an isolated file system). 832 // (if and only if they accessed via an isolated file system).
815 bool success = policy->HasPermissionsForFileSystem( 833 bool success = policy->HasPermissionsForFileSystem(
816 process_id_, url.filesystem_id(), permissions); 834 process_id_, url.filesystem_id(), permissions);
817 if (!success) 835 if (!success)
818 *error = base::PLATFORM_FILE_ERROR_SECURITY; 836 *error = base::PLATFORM_FILE_ERROR_SECURITY;
819 return success; 837 return success;
820 } 838 }
821 839
840 if (fileapi::SandboxMountPointProvider::CanHandleType(url.type())) {
841 // Sandboxed file system permissions should be implicitly granted.
842 // (And the application should not be given direct permission to the actual
843 // data directory in the sandboxed area.)
844 CHECK(mount_point_provider == context_->sandbox_provider());
845 return true;
846 }
847
822 file_path = mount_point_provider->GetPathForPermissionsCheck(url.path()); 848 file_path = mount_point_provider->GetPathForPermissionsCheck(url.path());
823 if (file_path.empty()) { 849 if (file_path.empty()) {
824 *error = base::PLATFORM_FILE_ERROR_SECURITY; 850 *error = base::PLATFORM_FILE_ERROR_SECURITY;
825 return false; 851 return false;
826 } 852 }
827 853
828 bool success = policy->HasPermissionsForFile( 854 bool success = policy->HasPermissionsForFile(
829 process_id_, file_path, permissions); 855 process_id_, file_path, permissions);
830 if (!success) 856 if (!success)
831 *error = base::PLATFORM_FILE_ERROR_SECURITY; 857 *error = base::PLATFORM_FILE_ERROR_SECURITY;
(...skipping 10 matching lines...) Expand all
842 Send(new FileSystemMsg_DidFail(request_id, error_code)); 868 Send(new FileSystemMsg_DidFail(request_id, error_code));
843 return NULL; 869 return NULL;
844 } 870 }
845 871
846 DCHECK(operation); 872 DCHECK(operation);
847 operations_.AddWithID(operation, request_id); 873 operations_.AddWithID(operation, request_id);
848 return operation; 874 return operation;
849 } 875 }
850 876
851 } // namespace content 877 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698