| 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/web_contents/render_view_host_manager.h" | 5 #include "content/browser/web_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/debugger/devtools_manager_impl.h" | 12 #include "content/browser/debugger/devtools_manager_impl.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 13 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_view_host_factory.h" | 14 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 14 #include "content/browser/renderer_host/render_view_host_impl.h" | 15 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 15 #include "content/browser/site_instance_impl.h" | 16 #include "content/browser/site_instance_impl.h" |
| 16 #include "content/browser/web_contents/navigation_controller_impl.h" | 17 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 17 #include "content/browser/web_contents/navigation_entry_impl.h" | 18 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 18 #include "content/browser/webui/web_ui_impl.h" | 19 #include "content/browser/webui/web_ui_impl.h" |
| 19 #include "content/common/view_messages.h" | 20 #include "content/common/view_messages.h" |
| 20 #include "content/port/browser/render_widget_host_view_port.h" | 21 #include "content/port/browser/render_widget_host_view_port.h" |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 // cross-navigating (Note that we don't care about on{before}unload | 829 // cross-navigating (Note that we don't care about on{before}unload |
| 829 // handlers if the current RVH isn't live.) | 830 // handlers if the current RVH isn't live.) |
| 830 CommitPending(); | 831 CommitPending(); |
| 831 return render_view_host_; | 832 return render_view_host_; |
| 832 } else { | 833 } else { |
| 833 NOTREACHED(); | 834 NOTREACHED(); |
| 834 return render_view_host_; | 835 return render_view_host_; |
| 835 } | 836 } |
| 836 } | 837 } |
| 837 // Otherwise, it's safe to treat this as a pending cross-site transition. | 838 // Otherwise, it's safe to treat this as a pending cross-site transition. |
| 839 // For the cross-process Post Submission request, we need to migrate the |
| 840 // permission to read the upload file from the old process to the |
| 841 // new process. TODO: Not sure whether we need to revoke |
| 842 // this permission after the POST. |
| 843 if (entry.GetHasPostData()) { |
| 844 ChildProcessSecurityPolicyImpl* policy = |
| 845 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 846 int oldID = render_view_host_->GetSiteInstance()->GetProcess()->GetID(); |
| 847 int newID = |
| 848 pending_render_view_host_->GetSiteInstance()->GetProcess()->GetID(); |
| 849 |
| 850 const std::vector<webkit_glue::ResourceRequestBody::Element>* uploads = |
| 851 entry.GetBrowserInitiatedPostData()->elements(); |
| 852 std::vector<webkit_glue::ResourceRequestBody::Element>::const_iterator |
| 853 iter; |
| 854 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
| 855 if (iter->type() == |
| 856 webkit_glue::ResourceRequestBody::Element::TYPE_FILE) { |
| 857 if (policy->CanReadFile(oldID, iter->path())) { |
| 858 policy->GrantReadFile(newID, iter->path()); |
| 859 } |
| 860 } |
| 861 } |
| 862 } |
| 838 | 863 |
| 839 // Make sure the old render view stops, in case a load is in progress. | 864 // Make sure the old render view stops, in case a load is in progress. |
| 840 render_view_host_->Send( | 865 render_view_host_->Send( |
| 841 new ViewMsg_Stop(render_view_host_->GetRoutingID())); | 866 new ViewMsg_Stop(render_view_host_->GetRoutingID())); |
| 842 | 867 |
| 843 // Suspend the new render view (i.e., don't let it send the cross-site | 868 // Suspend the new render view (i.e., don't let it send the cross-site |
| 844 // Navigate message) until we hear back from the old renderer's | 869 // Navigate message) until we hear back from the old renderer's |
| 845 // onbeforeunload handler. If the handler returns false, we'll have to | 870 // onbeforeunload handler. If the handler returns false, we'll have to |
| 846 // cancel the request. | 871 // cancel the request. |
| 847 DCHECK(!pending_render_view_host_->are_navigations_suspended()); | 872 DCHECK(!pending_render_view_host_->are_navigations_suspended()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 984 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
| 960 SiteInstance* instance) { | 985 SiteInstance* instance) { |
| 961 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 986 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
| 962 if (iter != swapped_out_hosts_.end()) | 987 if (iter != swapped_out_hosts_.end()) |
| 963 return iter->second; | 988 return iter->second; |
| 964 | 989 |
| 965 return NULL; | 990 return NULL; |
| 966 } | 991 } |
| 967 | 992 |
| 968 } // namespace content | 993 } // namespace content |
| OLD | NEW |