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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 9706047: Allow targeted links to work on tabs that have swapped out processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to get 118664 fix. Created 8 years, 9 months 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
« no previous file with comments | « content/common/swapped_out_messages.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 suggested_name)); 2236 suggested_name));
2237 } else { 2237 } else {
2238 OpenURL(frame, request.url(), 2238 OpenURL(frame, request.url(),
2239 Referrer(referrer, GetReferrerPolicyFromRequest(request)), policy); 2239 Referrer(referrer, GetReferrerPolicyFromRequest(request)), policy);
2240 } 2240 }
2241 } 2241 }
2242 2242
2243 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( 2243 WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation(
2244 WebFrame* frame, const WebURLRequest& request, WebNavigationType type, 2244 WebFrame* frame, const WebURLRequest& request, WebNavigationType type,
2245 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { 2245 const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) {
2246 // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. 2246 Referrer referrer(
2247 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2248 GetReferrerPolicyFromRequest(request));
2249
2247 if (is_swapped_out_) { 2250 if (is_swapped_out_) {
2248 // It is possible for in-progress navigations to arrive here just after we 2251 if (request.url() != GURL(chrome::kSwappedOutURL)) {
2249 // are swapped out, including iframes. We should cancel them. 2252 // Targeted links may try to navigate a swapped out frame. Allow the
2250 if (request.url() != GURL(chrome::kSwappedOutURL)) 2253 // browser process to navigate the tab instead. Note that it is also
2254 // possible for non-targeted navigations (from this view) to arrive
2255 // here just after we are swapped out. It's ok to send them to the
2256 // browser, as long as they're for the top level frame.
2257 if (frame->parent() == NULL) {
2258 OpenURL(frame, request.url(), referrer, default_policy);
darin (slow to review) 2012/03/22 17:23:39 so if this is a POST request, then it will become
Charlie Reis 2012/03/22 18:04:06 That's a fair point. It seems better to convert t
2259 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2260 }
2261
2262 // We should otherwise ignore in-process iframe navigations, if they
2263 // arrive just after we are swapped out.
2251 return WebKit::WebNavigationPolicyIgnore; 2264 return WebKit::WebNavigationPolicyIgnore;
2265 }
2252 2266
2253 // Allow chrome::kSwappedOutURL to complete. 2267 // Allow chrome::kSwappedOutURL to complete.
2254 return default_policy; 2268 return default_policy;
2255 } 2269 }
2256 2270
2257 // Webkit is asking whether to navigate to a new URL. 2271 // Webkit is asking whether to navigate to a new URL.
2258 // This is fine normally, except if we're showing UI from one security 2272 // This is fine normally, except if we're showing UI from one security
2259 // context and they're trying to navigate to a different context. 2273 // context and they're trying to navigate to a different context.
2260 const GURL& url = request.url(); 2274 const GURL& url = request.url();
2261 2275
2262 // A content initiated navigation may have originated from a link-click, 2276 // A content initiated navigation may have originated from a link-click,
2263 // script, drag-n-drop operation, etc. 2277 // script, drag-n-drop operation, etc.
2264 bool is_content_initiated = 2278 bool is_content_initiated =
2265 DocumentState::FromDataSource(frame->provisionalDataSource())-> 2279 DocumentState::FromDataSource(frame->provisionalDataSource())->
2266 navigation_state()->is_content_initiated(); 2280 navigation_state()->is_content_initiated();
2267 2281
2268 // Experimental: 2282 // Experimental:
2269 // If --enable-strict-site-isolation is enabled, send all top-level 2283 // If --enable-strict-site-isolation is enabled, send all top-level
2270 // navigations to the browser to let it swap processes when crossing site 2284 // navigations to the browser to let it swap processes when crossing site
2271 // boundaries. This is currently expected to break some script calls and 2285 // boundaries. This is currently expected to break some script calls and
2272 // navigations, such as form submissions. 2286 // navigations, such as form submissions.
2273 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 2287 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
2274 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && 2288 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) &&
2275 !frame->parent() && (is_content_initiated || is_redirect)) { 2289 !frame->parent() && (is_content_initiated || is_redirect)) {
2276 WebString origin_str = frame->document().securityOrigin().toString(); 2290 WebString origin_str = frame->document().securityOrigin().toString();
2277 GURL frame_url(origin_str.utf8().data()); 2291 GURL frame_url(origin_str.utf8().data());
2278 // TODO(cevans): revisit whether this origin check is still necessary once 2292 // TODO(cevans): revisit whether this origin check is still necessary once
2279 // crbug.com/101395 is fixed. 2293 // crbug.com/101395 is fixed.
2280 if (frame_url.GetOrigin() != url.GetOrigin()) { 2294 if (frame_url.GetOrigin() != url.GetOrigin()) {
2281 Referrer referrer(
2282 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2283 GetReferrerPolicyFromRequest(request));
2284 OpenURL(frame, url, referrer, default_policy); 2295 OpenURL(frame, url, referrer, default_policy);
2285 return WebKit::WebNavigationPolicyIgnore; 2296 return WebKit::WebNavigationPolicyIgnore;
2286 } 2297 }
2287 } 2298 }
2288 2299
2289 // If the browser is interested, then give it a chance to look at top level 2300 // If the browser is interested, then give it a chance to look at top level
2290 // navigations. 2301 // navigations.
2291 if (is_content_initiated) { 2302 if (is_content_initiated) {
2292 bool browser_handles_top_level_requests = 2303 bool browser_handles_top_level_requests =
2293 renderer_preferences_.browser_handles_top_level_requests && 2304 renderer_preferences_.browser_handles_top_level_requests &&
2294 IsNonLocalTopLevelNavigation(url, frame, type); 2305 IsNonLocalTopLevelNavigation(url, frame, type);
2295 if (browser_handles_top_level_requests || 2306 if (browser_handles_top_level_requests ||
2296 renderer_preferences_.browser_handles_all_requests) { 2307 renderer_preferences_.browser_handles_all_requests) {
2297 Referrer referrer(
2298 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2299 GetReferrerPolicyFromRequest(request));
2300 // Reset these counters as the RenderView could be reused for the next 2308 // Reset these counters as the RenderView could be reused for the next
2301 // navigation. 2309 // navigation.
2302 page_id_ = -1; 2310 page_id_ = -1;
2303 last_page_id_sent_to_browser_ = -1; 2311 last_page_id_sent_to_browser_ = -1;
2304 OpenURL(frame, url, referrer, default_policy); 2312 OpenURL(frame, url, referrer, default_policy);
2305 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2313 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2306 } 2314 }
2307 } 2315 }
2308 2316
2309 // Detect when we're crossing a permission-based boundary (e.g. into or out of 2317 // Detect when we're crossing a permission-based boundary (e.g. into or out of
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 // with hosted apps and extensions than WebUI pages. We will remove this 2351 // with hosted apps and extensions than WebUI pages. We will remove this
2344 // check when cross-process POST submissions are supported. 2352 // check when cross-process POST submissions are supported.
2345 if (request.httpMethod() == "GET") { 2353 if (request.httpMethod() == "GET") {
2346 bool is_initial_navigation = page_id_ == -1; 2354 bool is_initial_navigation = page_id_ == -1;
2347 should_fork = content::GetContentClient()->renderer()->ShouldFork( 2355 should_fork = content::GetContentClient()->renderer()->ShouldFork(
2348 frame, url, is_initial_navigation, &send_referrer); 2356 frame, url, is_initial_navigation, &send_referrer);
2349 } 2357 }
2350 } 2358 }
2351 2359
2352 if (should_fork) { 2360 if (should_fork) {
2353 Referrer referrer(
2354 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2355 GetReferrerPolicyFromRequest(request));
2356 OpenURL( 2361 OpenURL(
2357 frame, url, send_referrer ? referrer : Referrer(), default_policy); 2362 frame, url, send_referrer ? referrer : Referrer(), default_policy);
2358 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2363 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2359 } 2364 }
2360 } 2365 }
2361 2366
2362 // Use the frame's original request's URL rather than the document's URL for 2367 // Use the frame's original request's URL rather than the document's URL for
2363 // this check. For a popup, the document's URL may become the opener window's 2368 // this check. For a popup, the document's URL may become the opener window's
2364 // URL if the opener has called document.write. See http://crbug.com/93517. 2369 // URL if the opener has called document.write. See http://crbug.com/93517.
2365 GURL old_url(frame->dataSource()->request().url()); 2370 GURL old_url(frame->dataSource()->request().url());
(...skipping 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5199 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5195 return !!RenderThreadImpl::current()->compositor_thread(); 5200 return !!RenderThreadImpl::current()->compositor_thread();
5196 } 5201 }
5197 5202
5198 void RenderViewImpl::OnJavaBridgeInit() { 5203 void RenderViewImpl::OnJavaBridgeInit() {
5199 DCHECK(!java_bridge_dispatcher_.get()); 5204 DCHECK(!java_bridge_dispatcher_.get());
5200 #if defined(ENABLE_JAVA_BRIDGE) 5205 #if defined(ENABLE_JAVA_BRIDGE)
5201 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5206 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5202 #endif 5207 #endif
5203 } 5208 }
OLDNEW
« no previous file with comments | « content/common/swapped_out_messages.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698