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

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

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 fileapi::IsolatedContext::FileInfoSet files; 892 fileapi::IsolatedContext::FileInfoSet files;
893 for (std::vector<DropData::FileInfo>::iterator iter( 893 for (std::vector<DropData::FileInfo>::iterator iter(
894 filtered_data.filenames.begin()); 894 filtered_data.filenames.begin());
895 iter != filtered_data.filenames.end(); ++iter) { 895 iter != filtered_data.filenames.end(); ++iter) {
896 // A dragged file may wind up as the value of an input element, or it 896 // A dragged file may wind up as the value of an input element, or it
897 // may be used as the target of a navigation instead. We don't know 897 // may be used as the target of a navigation instead. We don't know
898 // which will happen at this point, so generously grant both access 898 // which will happen at this point, so generously grant both access
899 // and request permissions to the specific file to cover both cases. 899 // and request permissions to the specific file to cover both cases.
900 // We do not give it the permission to request all file:// URLs. 900 // We do not give it the permission to request all file:// URLs.
901 base::FilePath path = 901 base::FilePath path =
902 base::FilePath::FromUTF8Unsafe(UTF16ToUTF8(iter->path)); 902 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(iter->path));
903 903
904 // Make sure we have the same display_name as the one we register. 904 // Make sure we have the same display_name as the one we register.
905 if (iter->display_name.empty()) { 905 if (iter->display_name.empty()) {
906 std::string name; 906 std::string name;
907 files.AddPath(path, &name); 907 files.AddPath(path, &name);
908 iter->display_name = UTF8ToUTF16(name); 908 iter->display_name = base::UTF8ToUTF16(name);
909 } else { 909 } else {
910 files.AddPathWithName(path, UTF16ToUTF8(iter->display_name)); 910 files.AddPathWithName(path, base::UTF16ToUTF8(iter->display_name));
911 } 911 }
912 912
913 policy->GrantRequestSpecificFileURL(renderer_id, 913 policy->GrantRequestSpecificFileURL(renderer_id,
914 net::FilePathToFileURL(path)); 914 net::FilePathToFileURL(path));
915 915
916 // If the renderer already has permission to read these paths, we don't need 916 // If the renderer already has permission to read these paths, we don't need
917 // to re-grant them. This prevents problems with DnD for files in the CrOS 917 // to re-grant them. This prevents problems with DnD for files in the CrOS
918 // file manager--the file manager already had read/write access to those 918 // file manager--the file manager already had read/write access to those
919 // directories, but dragging a file would cause the read/write access to be 919 // directories, but dragging a file would cause the read/write access to be
920 // overwritten with read-only access, making them impossible to delete or 920 // overwritten with read-only access, making them impossible to delete or
921 // rename until the renderer was killed. 921 // rename until the renderer was killed.
922 if (!policy->CanReadFile(renderer_id, path)) 922 if (!policy->CanReadFile(renderer_id, path))
923 policy->GrantReadFile(renderer_id, path); 923 policy->GrantReadFile(renderer_id, path);
924 } 924 }
925 925
926 fileapi::IsolatedContext* isolated_context = 926 fileapi::IsolatedContext* isolated_context =
927 fileapi::IsolatedContext::GetInstance(); 927 fileapi::IsolatedContext::GetInstance();
928 DCHECK(isolated_context); 928 DCHECK(isolated_context);
929 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem( 929 std::string filesystem_id = isolated_context->RegisterDraggedFileSystem(
930 files); 930 files);
931 if (!filesystem_id.empty()) { 931 if (!filesystem_id.empty()) {
932 // Grant the permission iff the ID is valid. 932 // Grant the permission iff the ID is valid.
933 policy->GrantReadFileSystem(renderer_id, filesystem_id); 933 policy->GrantReadFileSystem(renderer_id, filesystem_id);
934 } 934 }
935 filtered_data.filesystem_id = UTF8ToUTF16(filesystem_id); 935 filtered_data.filesystem_id = base::UTF8ToUTF16(filesystem_id);
936 936
937 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt, 937 Send(new DragMsg_TargetDragEnter(GetRoutingID(), filtered_data, client_pt,
938 screen_pt, operations_allowed, 938 screen_pt, operations_allowed,
939 key_modifiers)); 939 key_modifiers));
940 } 940 }
941 941
942 void RenderViewHostImpl::DragTargetDragOver( 942 void RenderViewHostImpl::DragTargetDragOver(
943 const gfx::Point& client_pt, 943 const gfx::Point& client_pt,
944 const gfx::Point& screen_pt, 944 const gfx::Point& screen_pt,
945 WebDragOperationsMask operations_allowed, 945 WebDragOperationsMask operations_allowed,
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
1764 // 1. StartDragging IPC sent with renderer-specified filesystem paths that it 1764 // 1. StartDragging IPC sent with renderer-specified filesystem paths that it
1765 // doesn't have read permissions for. 1765 // doesn't have read permissions for.
1766 // 2. We initiate a native DnD operation. 1766 // 2. We initiate a native DnD operation.
1767 // 3. DnD operation immediately ends since mouse is not held down. DnD events 1767 // 3. DnD operation immediately ends since mouse is not held down. DnD events
1768 // still fire though, which causes read permissions to be granted to the 1768 // still fire though, which causes read permissions to be granted to the
1769 // renderer for any file paths in the drop. 1769 // renderer for any file paths in the drop.
1770 filtered_data.filenames.clear(); 1770 filtered_data.filenames.clear();
1771 for (std::vector<DropData::FileInfo>::const_iterator it = 1771 for (std::vector<DropData::FileInfo>::const_iterator it =
1772 drop_data.filenames.begin(); 1772 drop_data.filenames.begin();
1773 it != drop_data.filenames.end(); ++it) { 1773 it != drop_data.filenames.end(); ++it) {
1774 base::FilePath path(base::FilePath::FromUTF8Unsafe(UTF16ToUTF8(it->path))); 1774 base::FilePath path(
1775 base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(it->path)));
1775 if (policy->CanReadFile(GetProcess()->GetID(), path)) 1776 if (policy->CanReadFile(GetProcess()->GetID(), path))
1776 filtered_data.filenames.push_back(*it); 1777 filtered_data.filenames.push_back(*it);
1777 } 1778 }
1778 float scale = ui::GetImageScale(GetScaleFactorForView(GetView())); 1779 float scale = ui::GetImageScale(GetScaleFactorForView(GetView()));
1779 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); 1780 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale));
1780 view->StartDragging(filtered_data, drag_operations_mask, image, 1781 view->StartDragging(filtered_data, drag_operations_mask, image,
1781 bitmap_offset_in_dip, event_info); 1782 bitmap_offset_in_dip, event_info);
1782 } 1783 }
1783 1784
1784 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) { 1785 void RenderViewHostImpl::OnUpdateDragCursor(WebDragOperation current_op) {
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 void RenderViewHostImpl::AttachToFrameTree() { 2322 void RenderViewHostImpl::AttachToFrameTree() {
2322 FrameTree* frame_tree = delegate_->GetFrameTree(); 2323 FrameTree* frame_tree = delegate_->GetFrameTree();
2323 2324
2324 frame_tree->ResetForMainFrameSwap(); 2325 frame_tree->ResetForMainFrameSwap();
2325 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { 2326 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) {
2326 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); 2327 frame_tree->OnFirstNavigationAfterSwap(main_frame_id());
2327 } 2328 }
2328 } 2329 }
2329 2330
2330 } // namespace content 2331 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698