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

Side by Side Diff: content/browser/web_contents/render_view_host_manager.cc

Issue 11193051: To fix the cross-site post submission bug. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Comments Created 8 years, 1 month 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/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
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(irobert): Not sure whether we need to revoke
842 // this permission after the POST.
Charlie Reis 2012/11/20 05:46:03 I don't think we want to do this here. I need mor
843 if (entry.GetHasPostData() &&
844 // This check is not redundant.
845 // For example, user did a cross-process submission from A to B,
846 // and then GoBack to A, and GoForward to B.
847 // In this case, the navigation entry maintained by the browser has
848 // the has_post_data_ set to true but the browser_initiated_post_data
849 // is pointed to an invalid address.
Charlie Reis 2012/11/20 05:46:03 Valuable comment, but it should go before the if (
irobert 2012/11/22 01:37:00 Done.
850 entry.GetBrowserInitiatedPostData() != NULL) {
851 ChildProcessSecurityPolicyImpl* policy =
852 ChildProcessSecurityPolicyImpl::GetInstance();
853 int oldID = render_view_host_->GetSiteInstance()->GetProcess()->GetID();
854 int newID =
855 pending_render_view_host_->GetSiteInstance()->GetProcess()->GetID();
856 const std::vector<webkit_glue::ResourceRequestBody::Element>* uploads =
857 entry.GetBrowserInitiatedPostData()->elements();
858 std::vector<webkit_glue::ResourceRequestBody::Element>::const_iterator
859 iter;
860 for (iter = uploads->begin(); iter != uploads->end(); ++iter) {
861 if (iter->type() ==
862 webkit_glue::ResourceRequestBody::Element::TYPE_FILE) {
863 if (policy->CanReadFile(oldID, iter->path())) {
864 policy->GrantReadFile(newID, iter->path());
865 }
866 }
867 }
868 }
838 869
839 // Make sure the old render view stops, in case a load is in progress. 870 // Make sure the old render view stops, in case a load is in progress.
840 render_view_host_->Send( 871 render_view_host_->Send(
841 new ViewMsg_Stop(render_view_host_->GetRoutingID())); 872 new ViewMsg_Stop(render_view_host_->GetRoutingID()));
842 873
843 // Suspend the new render view (i.e., don't let it send the cross-site 874 // 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 875 // Navigate message) until we hear back from the old renderer's
845 // onbeforeunload handler. If the handler returns false, we'll have to 876 // onbeforeunload handler. If the handler returns false, we'll have to
846 // cancel the request. 877 // cancel the request.
847 DCHECK(!pending_render_view_host_->are_navigations_suspended()); 878 DCHECK(!pending_render_view_host_->are_navigations_suspended());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( 990 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost(
960 SiteInstance* instance) { 991 SiteInstance* instance) {
961 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 992 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
962 if (iter != swapped_out_hosts_.end()) 993 if (iter != swapped_out_hosts_.end())
963 return iter->second; 994 return iter->second;
964 995
965 return NULL; 996 return NULL;
966 } 997 }
967 998
968 } // namespace content 999 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698