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

Side by Side Diff: content/browser/loader/cross_site_resource_handler.cc

Issue 30323002: [DRAFT] Create RenderFrameHostManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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/loader/cross_site_resource_handler.h" 5 #include "content/browser/loader/cross_site_resource_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "content/browser/cross_site_request_manager.h" 12 #include "content/browser/cross_site_request_manager.h"
12 #include "content/browser/loader/resource_dispatcher_host_impl.h" 13 #include "content/browser/loader/resource_dispatcher_host_impl.h"
13 #include "content/browser/loader/resource_request_info_impl.h" 14 #include "content/browser/loader/resource_request_info_impl.h"
14 #include "content/browser/renderer_host/render_view_host_delegate.h" 15 #include "content/browser/renderer_host/render_view_host_delegate.h"
15 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/global_request_id.h" 19 #include "content/public/browser/global_request_id.h"
19 #include "content/public/browser/resource_controller.h" 20 #include "content/public/browser/resource_controller.h"
21 #include "content/public/common/content_switches.h"
20 #include "content/public/common/resource_response.h" 22 #include "content/public/common/resource_response.h"
23 #include "content/public/common/url_constants.h"
21 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
22 #include "net/url_request/url_request.h" 25 #include "net/url_request/url_request.h"
23 26
24 namespace content { 27 namespace content {
25 28
26 namespace { 29 namespace {
27 30
28 void OnCrossSiteResponseHelper(int render_view_id, 31 void OnCrossSiteResponseHelper(int render_view_id,
29 const GlobalRequestID& global_request_id, 32 const GlobalRequestID& global_request_id,
30 bool is_transfer, 33 bool is_transfer,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 87
85 ResourceRequestInfoImpl* info = GetRequestInfo(); 88 ResourceRequestInfoImpl* info = GetRequestInfo();
86 89
87 // We will need to swap processes if either (1) a redirect that requires a 90 // We will need to swap processes if either (1) a redirect that requires a
88 // transfer occurred before we got here, or (2) a pending cross-site request 91 // transfer occurred before we got here, or (2) a pending cross-site request
89 // was already in progress. Note that a swap may no longer be needed if we 92 // was already in progress. Note that a swap may no longer be needed if we
90 // transferred back into the original process due to a redirect. 93 // transferred back into the original process due to a redirect.
91 bool should_transfer = 94 bool should_transfer =
92 GetContentClient()->browser()->ShouldSwapProcessesForRedirect( 95 GetContentClient()->browser()->ShouldSwapProcessesForRedirect(
93 info->GetContext(), request()->original_url(), request()->url()); 96 info->GetContext(), request()->original_url(), request()->url());
97
98 // When the --site-per-process flag is passed, we transfer processes for
99 // cross-site subframe navigations.
100 // TODO(creis): Skip this for chrome: pages for now, since they host cross
101 // site iframes and don't have referrers.
102 // TODO(creis): This doesn't work for hosted apps, due to passing NULL to
103 // IsSameWebSite. It should be possible to always send the navigation to the
104 // UI thread to make a policy decision, which could let us eliminate the
105 // renderer-side check in RenderViewImpl::decidePolicyForNavigation as well.
106 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) {
107 GURL referrer(request()->referrer());
108 if (info->GetResourceType() == ResourceType::SUB_FRAME &&
109 !request()->url().SchemeIs(chrome::kChromeUIScheme) &&
110 !SiteInstance::IsSameWebSite(NULL, request()->url(), referrer)) {
111 LOG(INFO) << "CSRH: Transferring for a cross-process subframe: " <<
112 request()->url();
113 should_transfer = true;
114 }
115 }
116
94 bool swap_needed = should_transfer || 117 bool swap_needed = should_transfer ||
95 CrossSiteRequestManager::GetInstance()-> 118 CrossSiteRequestManager::GetInstance()->
96 HasPendingCrossSiteRequest(info->GetChildID(), info->GetRouteID()); 119 HasPendingCrossSiteRequest(info->GetChildID(), info->GetRouteID());
97 120
98 // If this is a download, just pass the response through without doing a 121 // If this is a download, just pass the response through without doing a
99 // cross-site check. The renderer will see it is a download and abort the 122 // cross-site check. The renderer will see it is a download and abort the
100 // request. 123 // request.
101 // 124 //
102 // Similarly, HTTP 204 (No Content) responses leave us showing the previous 125 // Similarly, HTTP 204 (No Content) responses leave us showing the previous
103 // page. We should allow the navigation to finish without running the unload 126 // page. We should allow the navigation to finish without running the unload
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 277 }
255 278
256 void CrossSiteResourceHandler::ResumeIfDeferred() { 279 void CrossSiteResourceHandler::ResumeIfDeferred() {
257 if (did_defer_) { 280 if (did_defer_) {
258 did_defer_ = false; 281 did_defer_ = false;
259 controller()->Resume(); 282 controller()->Resume();
260 } 283 }
261 } 284 }
262 285
263 } // namespace content 286 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698