| OLD | NEW |
| 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 void RenderViewHostImpl::RenderWidgetGotFocus() { | 770 void RenderViewHostImpl::RenderWidgetGotFocus() { |
| 771 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); | 771 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); |
| 772 if (view) | 772 if (view) |
| 773 view->GotFocus(); | 773 view->GotFocus(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 void RenderViewHostImpl::SetInitialFocus(bool reverse) { | 776 void RenderViewHostImpl::SetInitialFocus(bool reverse) { |
| 777 Send(new ViewMsg_SetInitialFocus(GetRoutingID(), reverse)); | 777 Send(new ViewMsg_SetInitialFocus(GetRoutingID(), reverse)); |
| 778 } | 778 } |
| 779 | 779 |
| 780 void RenderViewHostImpl::FilesSelectedInChooser( | |
| 781 const std::vector<content::FileChooserFileInfo>& files, | |
| 782 FileChooserParams::Mode permissions) { | |
| 783 storage::FileSystemContext* const file_system_context = | |
| 784 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), | |
| 785 GetSiteInstance()) | |
| 786 ->GetFileSystemContext(); | |
| 787 // Grant the security access requested to the given files. | |
| 788 for (size_t i = 0; i < files.size(); ++i) { | |
| 789 const content::FileChooserFileInfo& file = files[i]; | |
| 790 if (permissions == FileChooserParams::Save) { | |
| 791 ChildProcessSecurityPolicyImpl::GetInstance()->GrantCreateReadWriteFile( | |
| 792 GetProcess()->GetID(), file.file_path); | |
| 793 } else { | |
| 794 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | |
| 795 GetProcess()->GetID(), file.file_path); | |
| 796 } | |
| 797 if (file.file_system_url.is_valid()) { | |
| 798 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFileSystem( | |
| 799 GetProcess()->GetID(), | |
| 800 file_system_context->CrackURL(file.file_system_url) | |
| 801 .mount_filesystem_id()); | |
| 802 } | |
| 803 } | |
| 804 Send(new ViewMsg_RunFileChooserResponse(GetRoutingID(), files)); | |
| 805 } | |
| 806 | |
| 807 void RenderViewHostImpl::DirectoryEnumerationFinished( | 780 void RenderViewHostImpl::DirectoryEnumerationFinished( |
| 808 int request_id, | 781 int request_id, |
| 809 const std::vector<base::FilePath>& files) { | 782 const std::vector<base::FilePath>& files) { |
| 810 // Grant the security access requested to the given files. | 783 // Grant the security access requested to the given files. |
| 811 for (std::vector<base::FilePath>::const_iterator file = files.begin(); | 784 for (std::vector<base::FilePath>::const_iterator file = files.begin(); |
| 812 file != files.end(); ++file) { | 785 file != files.end(); ++file) { |
| 813 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( | 786 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( |
| 814 GetProcess()->GetID(), *file); | 787 GetProcess()->GetID(), *file); |
| 815 } | 788 } |
| 816 Send(new ViewMsg_EnumerateDirectoryResponse(GetRoutingID(), | 789 Send(new ViewMsg_EnumerateDirectoryResponse(GetRoutingID(), |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, | 857 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, |
| 885 OnDidContentsPreferredSizeChange) | 858 OnDidContentsPreferredSizeChange) |
| 886 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, | 859 IPC_MESSAGE_HANDLER(ViewHostMsg_RouteCloseEvent, |
| 887 OnRouteCloseEvent) | 860 OnRouteCloseEvent) |
| 888 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) | 861 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) |
| 889 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 862 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
| 890 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 863 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
| 891 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) | 864 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) |
| 892 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) | 865 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) |
| 893 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) | 866 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
| 894 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | |
| 895 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) | 867 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) |
| 896 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) | 868 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeTouched, OnFocusedNodeTouched) |
| 897 IPC_MESSAGE_UNHANDLED(handled = false) | 869 IPC_MESSAGE_UNHANDLED(handled = false) |
| 898 IPC_END_MESSAGE_MAP() | 870 IPC_END_MESSAGE_MAP() |
| 899 | 871 |
| 900 return handled; | 872 return handled; |
| 901 } | 873 } |
| 902 | 874 |
| 903 void RenderViewHostImpl::RenderWidgetDidInit() { | 875 void RenderViewHostImpl::RenderWidgetDidInit() { |
| 904 PostRenderViewReady(); | 876 PostRenderViewReady(); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 const GURL& url) { | 1218 const GURL& url) { |
| 1247 HostZoomMapImpl* host_zoom_map = | 1219 HostZoomMapImpl* host_zoom_map = |
| 1248 static_cast<HostZoomMapImpl*>(HostZoomMap::Get(GetSiteInstance())); | 1220 static_cast<HostZoomMapImpl*>(HostZoomMap::Get(GetSiteInstance())); |
| 1249 | 1221 |
| 1250 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), | 1222 host_zoom_map->SetZoomLevelForView(GetProcess()->GetID(), |
| 1251 GetRoutingID(), | 1223 GetRoutingID(), |
| 1252 zoom_level, | 1224 zoom_level, |
| 1253 net::GetHostOrSpecFromURL(url)); | 1225 net::GetHostOrSpecFromURL(url)); |
| 1254 } | 1226 } |
| 1255 | 1227 |
| 1256 void RenderViewHostImpl::OnRunFileChooser(const FileChooserParams& params) { | |
| 1257 // Do not allow messages with absolute paths in them as this can permit a | |
| 1258 // renderer to coerce the browser to perform I/O on a renderer controlled | |
| 1259 // path. | |
| 1260 if (params.default_file_name != params.default_file_name.BaseName()) { | |
| 1261 bad_message::ReceivedBadMessage(GetProcess(), | |
| 1262 bad_message::RVH_FILE_CHOOSER_PATH); | |
| 1263 return; | |
| 1264 } | |
| 1265 | |
| 1266 delegate_->RunFileChooser(this, params); | |
| 1267 } | |
| 1268 | |
| 1269 void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { | 1228 void RenderViewHostImpl::OnFocusedNodeTouched(bool editable) { |
| 1270 #if defined(OS_WIN) | 1229 #if defined(OS_WIN) |
| 1271 // We use the cursor position to determine where the touch occurred. | 1230 // We use the cursor position to determine where the touch occurred. |
| 1272 // TODO(ananta) | 1231 // TODO(ananta) |
| 1273 // Pass this information from blink. | 1232 // Pass this information from blink. |
| 1274 // In site isolation mode, we may not have a RenderViewHostImpl instance | 1233 // In site isolation mode, we may not have a RenderViewHostImpl instance |
| 1275 // which means that displaying the OSK is not going to work. We should | 1234 // which means that displaying the OSK is not going to work. We should |
| 1276 // probably move this to RenderWidgetHostImpl and call the view from there. | 1235 // probably move this to RenderWidgetHostImpl and call the view from there. |
| 1277 // https://bugs.chromium.org/p/chromium/issues/detail?id=613326 | 1236 // https://bugs.chromium.org/p/chromium/issues/detail?id=613326 |
| 1278 POINT cursor_pos = {}; | 1237 POINT cursor_pos = {}; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 } else { | 1282 } else { |
| 1324 render_view_ready_on_process_launch_ = true; | 1283 render_view_ready_on_process_launch_ = true; |
| 1325 } | 1284 } |
| 1326 } | 1285 } |
| 1327 | 1286 |
| 1328 void RenderViewHostImpl::RenderViewReady() { | 1287 void RenderViewHostImpl::RenderViewReady() { |
| 1329 delegate_->RenderViewReady(this); | 1288 delegate_->RenderViewReady(this); |
| 1330 } | 1289 } |
| 1331 | 1290 |
| 1332 } // namespace content | 1291 } // namespace content |
| OLD | NEW |