 Chromium Code Reviews
 Chromium Code Reviews Issue 11193051:
  To fix the cross-site post submission bug. 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 11193051:
  To fix the cross-site post submission bug. 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| 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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 // handlers if the current RVH isn't live.) | 840 // handlers if the current RVH isn't live.) | 
| 840 CommitPending(); | 841 CommitPending(); | 
| 841 return render_view_host_; | 842 return render_view_host_; | 
| 842 } else { | 843 } else { | 
| 843 NOTREACHED(); | 844 NOTREACHED(); | 
| 844 return render_view_host_; | 845 return render_view_host_; | 
| 845 } | 846 } | 
| 846 } | 847 } | 
| 847 // Otherwise, it's safe to treat this as a pending cross-site transition. | 848 // Otherwise, it's safe to treat this as a pending cross-site transition. | 
| 848 | 849 | 
| 850 | |
| 851 if (entry.GetHasPostData()) { | |
| 852 ChildProcessSecurityPolicyImpl* policy = | |
| 
michaeln
2012/10/23 23:22:18
Is the 'policy' thread safe? Just checking because
 
irobert
2012/11/01 19:26:31
Not quite sure about it. But i do believe this cou
 
Charlie Reis
2012/11/05 16:21:40
From the header file:
"ChildProcessSecurityPolicy
 
irobert
2012/11/05 17:26:52
I have verified this with Darin. He mentioned: "It
 | |
| 853 ChildProcessSecurityPolicyImpl::GetInstance(); | |
| 854 int oldID = render_view_host_->GetSiteInstance()->GetProcess()->GetID(); | |
| 855 int newID = pending_render_view_host_->GetSiteInstance()->GetProcess()->GetI D(); | |
| 856 std::vector<content::WebHTTPPOSTBodyParams> post_data = entry.post_data; | |
| 857 for (std::vector<content::WebHTTPPOSTBodyParams>::iterator it=post_data.begi n(); | |
| 858 it < post_data.end(); it++) { | |
| 859 if ((*it).type == content::WebHTTPPOSTBodyParams::TypeFile) { | |
| 860 FilePath file = FilePath((*it).filePath); | |
| 861 if (policy->CanReadFile(oldID, file)) { | |
| 862 policy->GrantReadFile(newID, file); | |
| 863 } | |
| 864 } | |
| 865 } | |
| 866 } | |
| 867 | |
| 849 // Make sure the old render view stops, in case a load is in progress. | 868 // Make sure the old render view stops, in case a load is in progress. | 
| 850 render_view_host_->Send( | 869 render_view_host_->Send( | 
| 851 new ViewMsg_Stop(render_view_host_->GetRoutingID())); | 870 new ViewMsg_Stop(render_view_host_->GetRoutingID())); | 
| 852 | 871 | 
| 853 // Suspend the new render view (i.e., don't let it send the cross-site | 872 // Suspend the new render view (i.e., don't let it send the cross-site | 
| 854 // Navigate message) until we hear back from the old renderer's | 873 // Navigate message) until we hear back from the old renderer's | 
| 855 // onbeforeunload handler. If the handler returns false, we'll have to | 874 // onbeforeunload handler. If the handler returns false, we'll have to | 
| 856 // cancel the request. | 875 // cancel the request. | 
| 857 DCHECK(!pending_render_view_host_->are_navigations_suspended()); | 876 DCHECK(!pending_render_view_host_->are_navigations_suspended()); | 
| 858 pending_render_view_host_->SetNavigationsSuspended(true); | 877 pending_render_view_host_->SetNavigationsSuspended(true); | 
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 } | 986 } | 
| 968 | 987 | 
| 969 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 988 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 
| 970 SiteInstance* instance) { | 989 SiteInstance* instance) { | 
| 971 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 990 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 
| 972 if (iter != swapped_out_hosts_.end()) | 991 if (iter != swapped_out_hosts_.end()) | 
| 973 return iter->second; | 992 return iter->second; | 
| 974 | 993 | 
| 975 return NULL; | 994 return NULL; | 
| 976 } | 995 } | 
| OLD | NEW |