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

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: rebased 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
« no previous file with comments | « content/browser/intents/intent_injector.cc ('k') | content/common/intents_messages.h » ('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/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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "content/public/common/result_codes.h" 55 #include "content/public/common/result_codes.h"
56 #include "content/public/common/url_constants.h" 56 #include "content/public/common/url_constants.h"
57 #include "net/base/net_util.h" 57 #include "net/base/net_util.h"
58 #include "net/url_request/url_request_context_getter.h" 58 #include "net/url_request/url_request_context_getter.h"
59 #include "third_party/skia/include/core/SkBitmap.h" 59 #include "third_party/skia/include/core/SkBitmap.h"
60 #include "ui/base/dialogs/selected_file_info.h" 60 #include "ui/base/dialogs/selected_file_info.h"
61 #include "ui/gfx/image/image_skia.h" 61 #include "ui/gfx/image/image_skia.h"
62 #include "ui/gfx/native_widget_types.h" 62 #include "ui/gfx/native_widget_types.h"
63 #include "webkit/fileapi/isolated_context.h" 63 #include "webkit/fileapi/isolated_context.h"
64 #include "webkit/glue/webdropdata.h" 64 #include "webkit/glue/webdropdata.h"
65 #include "webkit/glue/webkit_glue.h"
65 66
66 #if defined(OS_WIN) 67 #if defined(OS_WIN)
67 #include "base/win/windows_version.h" 68 #include "base/win/windows_version.h"
68 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFact ory.h" 69 #include "third_party/WebKit/Source/WebKit/chromium/public/win/WebScreenInfoFact ory.h"
69 #elif defined(OS_MACOSX) 70 #elif defined(OS_MACOSX)
70 #include "content/browser/renderer_host/popup_menu_helper_mac.h" 71 #include "content/browser/renderer_host/popup_menu_helper_mac.h"
71 #endif 72 #endif
72 73
73 using base::TimeDelta; 74 using base::TimeDelta;
74 using content::NativeWebKeyboardEvent; 75 using content::NativeWebKeyboardEvent;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 ChildProcessSecurityPolicyImpl* policy = 514 ChildProcessSecurityPolicyImpl* policy =
514 ChildProcessSecurityPolicyImpl::GetInstance(); 515 ChildProcessSecurityPolicyImpl::GetInstance();
515 516
516 // The URL could have been cobbled together from any highlighted text string, 517 // The URL could have been cobbled together from any highlighted text string,
517 // and can't be interpreted as a capability. 518 // and can't be interpreted as a capability.
518 WebDropData filtered_data(drop_data); 519 WebDropData filtered_data(drop_data);
519 FilterURL(policy, renderer_id, true, &filtered_data.url); 520 FilterURL(policy, renderer_id, true, &filtered_data.url);
520 521
521 // The filenames vector, on the other hand, does represent a capability to 522 // The filenames vector, on the other hand, does represent a capability to
522 // access the given files. 523 // access the given files.
523 std::set<FilePath> filesets; 524 fileapi::IsolatedContext::FileInfoSet files;
524 for (std::vector<WebDropData::FileInfo>::const_iterator iter( 525 for (std::vector<WebDropData::FileInfo>::iterator iter(
525 filtered_data.filenames.begin()); 526 filtered_data.filenames.begin());
526 iter != filtered_data.filenames.end(); ++iter) { 527 iter != filtered_data.filenames.end(); ++iter) {
527 // A dragged file may wind up as the value of an input element, or it 528 // A dragged file may wind up as the value of an input element, or it
528 // may be used as the target of a navigation instead. We don't know 529 // may be used as the target of a navigation instead. We don't know
529 // which will happen at this point, so generously grant both access 530 // which will happen at this point, so generously grant both access
530 // and request permissions to the specific file to cover both cases. 531 // and request permissions to the specific file to cover both cases.
531 // We do not give it the permission to request all file:// URLs. 532 // We do not give it the permission to request all file:// URLs.
532 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); 533 FilePath path = FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path));
534
535 // Make sure we have the same display_name as the one we register.
536 std::string name = files.AddPath(path);
537 iter->display_name = UTF8ToUTF16(name);
538
533 policy->GrantRequestSpecificFileURL(renderer_id, 539 policy->GrantRequestSpecificFileURL(renderer_id,
534 net::FilePathToFileURL(path)); 540 net::FilePathToFileURL(path));
535 541
536 // 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
537 // 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
538 // 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
539 // 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
540 // overwritten with read-only access, making them impossible to delete or 546 // overwritten with read-only access, making them impossible to delete or
541 // rename until the renderer was killed. 547 // rename until the renderer was killed.
542 if (!policy->CanReadFile(renderer_id, path)) { 548 if (!policy->CanReadFile(renderer_id, path)) {
543 policy->GrantReadFile(renderer_id, path); 549 policy->GrantReadFile(renderer_id, path);
544 // Allow dragged directories to be enumerated by the child process. 550 // Allow dragged directories to be enumerated by the child process.
545 // 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.
546 policy->GrantReadDirectory(renderer_id, path); 552 policy->GrantReadDirectory(renderer_id, path);
547 } 553 }
548
549 filesets.insert(path);
550 } 554 }
551 555
552 fileapi::IsolatedContext* isolated_context = 556 fileapi::IsolatedContext* isolated_context =
553 fileapi::IsolatedContext::GetInstance(); 557 fileapi::IsolatedContext::GetInstance();
554 DCHECK(isolated_context); 558 DCHECK(isolated_context);
555 std::string filesystem_id = isolated_context->RegisterIsolatedFileSystem( 559 std::string filesystem_id = isolated_context->RegisterFileSystem(files);
556 filesets);
557 if (!filesystem_id.empty()) { 560 if (!filesystem_id.empty()) {
558 // Grant the permission iff the ID is valid. 561 // Grant the permission iff the ID is valid.
559 policy->GrantReadFileSystem(renderer_id, filesystem_id); 562 policy->GrantReadFileSystem(renderer_id, filesystem_id);
560 } 563 }
561 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); 564 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id);
562 565
563 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, 566 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
564 screen_pt, operations_allowed, 567 screen_pt, operations_allowed,
565 key_modifiers)); 568 key_modifiers));
566 } 569 }
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1852 // can cause navigations to be ignored in OnMsgNavigate. 1855 // can cause navigations to be ignored in OnMsgNavigate.
1853 is_waiting_for_beforeunload_ack_ = false; 1856 is_waiting_for_beforeunload_ack_ = false;
1854 is_waiting_for_unload_ack_ = false; 1857 is_waiting_for_unload_ack_ = false;
1855 } 1858 }
1856 1859
1857 void RenderViewHostImpl::ClearPowerSaveBlockers() { 1860 void RenderViewHostImpl::ClearPowerSaveBlockers() {
1858 STLDeleteValues(&power_save_blockers_); 1861 STLDeleteValues(&power_save_blockers_);
1859 } 1862 }
1860 1863
1861 } // namespace content 1864 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/intents/intent_injector.cc ('k') | content/common/intents_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698