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

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 10713007: Make isolated file system works for a device root (e.g. X:\\) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months 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
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/renderer_host/render_view_host_impl.h" 5 #include "content/browser/renderer_host/render_view_host_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 ChildProcessSecurityPolicyImpl* policy = 511 ChildProcessSecurityPolicyImpl* policy =
512 ChildProcessSecurityPolicyImpl::GetInstance(); 512 ChildProcessSecurityPolicyImpl::GetInstance();
513 513
514 // The URL could have been cobbled together from any highlighted text string, 514 // The URL could have been cobbled together from any highlighted text string,
515 // and can't be interpreted as a capability. 515 // and can't be interpreted as a capability.
516 WebDropData filtered_data(drop_data); 516 WebDropData filtered_data(drop_data);
517 FilterURL(policy, renderer_id, true, &filtered_data.url); 517 FilterURL(policy, renderer_id, true, &filtered_data.url);
518 518
519 // The filenames vector, on the other hand, does represent a capability to 519 // The filenames vector, on the other hand, does represent a capability to
520 // access the given files. 520 // access the given files.
521 std::set<FilePath> filesets; 521 std::set<FilePath> filesets;
tzik 2012/06/29 02:56:35 can be removed?
kinuko 2012/06/29 08:31:22 Done.
522 for (std::vector<WebDropData::FileInfo>::const_iterator iter( 522 std::vector<fileapi::IsolatedContext::FileInfo> files;
523 for (std::vector<WebDropData::FileInfo>::iterator iter(
523 filtered_data.filenames.begin()); 524 filtered_data.filenames.begin());
524 iter != filtered_data.filenames.end(); ++iter) { 525 iter != filtered_data.filenames.end(); ++iter) {
525 // A dragged file may wind up as the value of an input element, or it 526 // A dragged file may wind up as the value of an input element, or it
526 // may be used as the target of a navigation instead. We don't know 527 // may be used as the target of a navigation instead. We don't know
527 // which will happen at this point, so generously grant both access 528 // which will happen at this point, so generously grant both access
528 // and request permissions to the specific file to cover both cases. 529 // and request permissions to the specific file to cover both cases.
529 // We do not give it the permission to request all file:// URLs. 530 // We do not give it the permission to request all file:// URLs.
530 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); 531 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path));
532
533 // Make sure we have non-empty display name.
534 std::string name = UTF16ToUTF8(iter->display_name);
535 if (name.empty()) {
536 name = fileapi::IsolatedContext::GetNameForPath(path);
537 iter->display_name = UTF8ToUTF16(name);
538 }
539
531 policy->GrantRequestSpecificFileURL(renderer_id, 540 policy->GrantRequestSpecificFileURL(renderer_id,
532 net::FilePathToFileURL(path)); 541 net::FilePathToFileURL(path));
533 542
534 // If the renderer already has permission to read these paths, we don't need 543 // If the renderer already has permission to read these paths, we don't need
535 // to re-grant them. This prevents problems with DnD for files in the CrOS 544 // to re-grant them. This prevents problems with DnD for files in the CrOS
536 // file manager--the file manager already had read/write access to those 545 // file manager--the file manager already had read/write access to those
537 // directories, but dragging a file would cause the read/write access to be 546 // directories, but dragging a file would cause the read/write access to be
538 // overwritten with read-only access, making them impossible to delete or 547 // overwritten with read-only access, making them impossible to delete or
539 // rename until the renderer was killed. 548 // rename until the renderer was killed.
540 if (!policy->CanReadFile(renderer_id, path)) { 549 if (!policy->CanReadFile(renderer_id, path)) {
541 policy->GrantReadFile(renderer_id, path); 550 policy->GrantReadFile(renderer_id, path);
542 // Allow dragged directories to be enumerated by the child process. 551 // Allow dragged directories to be enumerated by the child process.
543 // Note that we can't tell a file from a directory at this point. 552 // Note that we can't tell a file from a directory at this point.
544 policy->GrantReadDirectory(renderer_id, path); 553 policy->GrantReadDirectory(renderer_id, path);
545 } 554 }
546 555
547 filesets.insert(path); 556 files.push_back(fileapi::IsolatedContext::FileInfo(name, path));
548 } 557 }
549 558
550 fileapi::IsolatedContext* isolated_context = 559 fileapi::IsolatedContext* isolated_context =
551 fileapi::IsolatedContext::GetInstance(); 560 fileapi::IsolatedContext::GetInstance();
552 DCHECK(isolated_context); 561 DCHECK(isolated_context);
553 std::string filesystem_id = isolated_context->RegisterIsolatedFileSystem( 562 std::string filesystem_id = isolated_context->RegisterFileSystem(files);
554 filesets);
555 if (!filesystem_id.empty()) { 563 if (!filesystem_id.empty()) {
556 // Grant the permission iff the ID is valid. 564 // Grant the permission iff the ID is valid.
557 policy->GrantReadFileSystem(renderer_id, filesystem_id); 565 policy->GrantReadFileSystem(renderer_id, filesystem_id);
558 } 566 }
559 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); 567 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id);
560 568
561 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, 569 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
562 screen_pt, operations_allowed, 570 screen_pt, operations_allowed,
563 key_modifiers)); 571 key_modifiers));
564 } 572 }
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 // can cause navigations to be ignored in OnMsgNavigate. 1854 // can cause navigations to be ignored in OnMsgNavigate.
1847 is_waiting_for_beforeunload_ack_ = false; 1855 is_waiting_for_beforeunload_ack_ = false;
1848 is_waiting_for_unload_ack_ = false; 1856 is_waiting_for_unload_ack_ = false;
1849 } 1857 }
1850 1858
1851 void RenderViewHostImpl::ClearPowerSaveBlockers() { 1859 void RenderViewHostImpl::ClearPowerSaveBlockers() {
1852 STLDeleteValues(&power_save_blockers_); 1860 STLDeleteValues(&power_save_blockers_);
1853 } 1861 }
1854 1862
1855 } // namespace content 1863 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698