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

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 Android API, Helper Function and Include_rules Created 8 years 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.
843 //
844 // The second 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.
850 if (entry.GetHasPostData() &&
851 entry.GetBrowserInitiatedPostData()) {
852 ChildProcessSecurityPolicyImpl* policy =
853 ChildProcessSecurityPolicyImpl::GetInstance();
854 int oldID = render_view_host_->GetSiteInstance()->GetProcess()->GetID();
855 int newID =
856 pending_render_view_host_->GetSiteInstance()->GetProcess()->GetID();
857 const std::vector<webkit_glue::ResourceRequestBody::Element>* uploads =
858 entry.GetBrowserInitiatedPostData()->elements();
859 std::vector<webkit_glue::ResourceRequestBody::Element>::const_iterator
860 iter;
861 for (iter = uploads->begin(); iter != uploads->end(); ++iter) {
862 if (iter->type() ==
863 webkit_glue::ResourceRequestBody::Element::TYPE_FILE) {
864 if (policy->CanReadFile(oldID, iter->path())) {
865 policy->GrantReadFile(newID, iter->path());
866 }
867 }
868 }
869 }
838 870
839 // Make sure the old render view stops, in case a load is in progress. 871 // Make sure the old render view stops, in case a load is in progress.
840 render_view_host_->Send( 872 render_view_host_->Send(
841 new ViewMsg_Stop(render_view_host_->GetRoutingID())); 873 new ViewMsg_Stop(render_view_host_->GetRoutingID()));
842 874
843 // Suspend the new render view (i.e., don't let it send the cross-site 875 // 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 876 // Navigate message) until we hear back from the old renderer's
845 // onbeforeunload handler. If the handler returns false, we'll have to 877 // onbeforeunload handler. If the handler returns false, we'll have to
846 // cancel the request. 878 // cancel the request.
847 DCHECK(!pending_render_view_host_->are_navigations_suspended()); 879 DCHECK(!pending_render_view_host_->are_navigations_suspended());
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( 991 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost(
960 SiteInstance* instance) { 992 SiteInstance* instance) {
961 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); 993 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId());
962 if (iter != swapped_out_hosts_.end()) 994 if (iter != swapped_out_hosts_.end())
963 return iter->second; 995 return iter->second;
964 996
965 return NULL; 997 return NULL;
966 } 998 }
967 999
968 } // namespace content 1000 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/navigation_entry_impl_unittest.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698