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

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::vector<fileapi::IsolatedContext::FileInfo> files;
522 for (std::vector<WebDropData::FileInfo>::const_iterator iter( 522 for (std::vector<WebDropData::FileInfo>::iterator iter(
523 filtered_data.filenames.begin()); 523 filtered_data.filenames.begin());
524 iter != filtered_data.filenames.end(); ++iter) { 524 iter != filtered_data.filenames.end(); ++iter) {
525 // A dragged file may wind up as the value of an input element, or it 525 // 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 526 // 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 527 // which will happen at this point, so generously grant both access
528 // and request permissions to the specific file to cover both cases. 528 // and request permissions to the specific file to cover both cases.
529 // We do not give it the permission to request all file:// URLs. 529 // We do not give it the permission to request all file:// URLs.
530 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); 530 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path));
531
532 // Make sure we have non-empty display name.
533 std::string name = UTF16ToUTF8(iter->display_name);
534 if (name.empty()) {
535 name = fileapi::IsolatedContext::GetNameForPath(path);
536 iter->display_name = UTF8ToUTF16(name);
537 }
538
benwells 2012/06/29 17:41:09 Nit - should the TODO about making sure names are
kinuko 2012/07/02 13:51:54 Done in a way that adding a new helper class, File
531 policy->GrantRequestSpecificFileURL(renderer_id, 539 policy->GrantRequestSpecificFileURL(renderer_id,
532 net::FilePathToFileURL(path)); 540 net::FilePathToFileURL(path));
533 541
534 // If the renderer already has permission to read these paths, we don't need 542 // 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 543 // 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 544 // 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 545 // 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 546 // overwritten with read-only access, making them impossible to delete or
539 // rename until the renderer was killed. 547 // rename until the renderer was killed.
540 if (!policy->CanReadFile(renderer_id, path)) { 548 if (!policy->CanReadFile(renderer_id, path)) {
541 policy->GrantReadFile(renderer_id, path); 549 policy->GrantReadFile(renderer_id, path);
542 // Allow dragged directories to be enumerated by the child process. 550 // 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. 551 // Note that we can't tell a file from a directory at this point.
544 policy->GrantReadDirectory(renderer_id, path); 552 policy->GrantReadDirectory(renderer_id, path);
545 } 553 }
546 554
547 filesets.insert(path); 555 files.push_back(fileapi::IsolatedContext::FileInfo(name, path));
548 } 556 }
549 557
550 fileapi::IsolatedContext* isolated_context = 558 fileapi::IsolatedContext* isolated_context =
551 fileapi::IsolatedContext::GetInstance(); 559 fileapi::IsolatedContext::GetInstance();
552 DCHECK(isolated_context); 560 DCHECK(isolated_context);
553 std::string filesystem_id = isolated_context->RegisterIsolatedFileSystem( 561 std::string filesystem_id = isolated_context->RegisterFileSystem(files);
554 filesets);
555 if (!filesystem_id.empty()) { 562 if (!filesystem_id.empty()) {
556 // Grant the permission iff the ID is valid. 563 // Grant the permission iff the ID is valid.
557 policy->GrantReadFileSystem(renderer_id, filesystem_id); 564 policy->GrantReadFileSystem(renderer_id, filesystem_id);
558 } 565 }
559 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); 566 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id);
560 567
561 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, 568 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
562 screen_pt, operations_allowed, 569 screen_pt, operations_allowed,
563 key_modifiers)); 570 key_modifiers));
564 } 571 }
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 // can cause navigations to be ignored in OnMsgNavigate. 1853 // can cause navigations to be ignored in OnMsgNavigate.
1847 is_waiting_for_beforeunload_ack_ = false; 1854 is_waiting_for_beforeunload_ack_ = false;
1848 is_waiting_for_unload_ack_ = false; 1855 is_waiting_for_unload_ack_ = false;
1849 } 1856 }
1850 1857
1851 void RenderViewHostImpl::ClearPowerSaveBlockers() { 1858 void RenderViewHostImpl::ClearPowerSaveBlockers() {
1852 STLDeleteValues(&power_save_blockers_); 1859 STLDeleteValues(&power_save_blockers_);
1853 } 1860 }
1854 1861
1855 } // namespace content 1862 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698