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

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: Add TODO 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 // TODO(creis): Ensure this supports targeted form submissions when
2258 // fixing http://crbug.com/101395.
2259 if (frame->parent() == NULL) {
2260 OpenURL(frame, request.url(), referrer, default_policy);
2261 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2262 }
2263
2264 // We should otherwise ignore in-process iframe navigations, if they
2265 // arrive just after we are swapped out.
2251 return WebKit::WebNavigationPolicyIgnore; 2266 return WebKit::WebNavigationPolicyIgnore;
2267 }
2252 2268
2253 // Allow chrome::kSwappedOutURL to complete. 2269 // Allow chrome::kSwappedOutURL to complete.
2254 return default_policy; 2270 return default_policy;
2255 } 2271 }
2256 2272
2257 // Webkit is asking whether to navigate to a new URL. 2273 // Webkit is asking whether to navigate to a new URL.
2258 // This is fine normally, except if we're showing UI from one security 2274 // 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. 2275 // context and they're trying to navigate to a different context.
2260 const GURL& url = request.url(); 2276 const GURL& url = request.url();
2261 2277
2262 // A content initiated navigation may have originated from a link-click, 2278 // A content initiated navigation may have originated from a link-click,
2263 // script, drag-n-drop operation, etc. 2279 // script, drag-n-drop operation, etc.
2264 bool is_content_initiated = 2280 bool is_content_initiated =
2265 DocumentState::FromDataSource(frame->provisionalDataSource())-> 2281 DocumentState::FromDataSource(frame->provisionalDataSource())->
2266 navigation_state()->is_content_initiated(); 2282 navigation_state()->is_content_initiated();
2267 2283
2268 // Experimental: 2284 // Experimental:
2269 // If --enable-strict-site-isolation is enabled, send all top-level 2285 // If --enable-strict-site-isolation is enabled, send all top-level
2270 // navigations to the browser to let it swap processes when crossing site 2286 // navigations to the browser to let it swap processes when crossing site
2271 // boundaries. This is currently expected to break some script calls and 2287 // boundaries. This is currently expected to break some script calls and
2272 // navigations, such as form submissions. 2288 // navigations, such as form submissions.
2273 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 2289 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
2274 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && 2290 if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) &&
2275 !frame->parent() && (is_content_initiated || is_redirect)) { 2291 !frame->parent() && (is_content_initiated || is_redirect)) {
2276 WebString origin_str = frame->document().securityOrigin().toString(); 2292 WebString origin_str = frame->document().securityOrigin().toString();
2277 GURL frame_url(origin_str.utf8().data()); 2293 GURL frame_url(origin_str.utf8().data());
2278 // TODO(cevans): revisit whether this origin check is still necessary once 2294 // TODO(cevans): revisit whether this origin check is still necessary once
2279 // crbug.com/101395 is fixed. 2295 // crbug.com/101395 is fixed.
2280 if (frame_url.GetOrigin() != url.GetOrigin()) { 2296 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); 2297 OpenURL(frame, url, referrer, default_policy);
2285 return WebKit::WebNavigationPolicyIgnore; 2298 return WebKit::WebNavigationPolicyIgnore;
2286 } 2299 }
2287 } 2300 }
2288 2301
2289 // If the browser is interested, then give it a chance to look at top level 2302 // If the browser is interested, then give it a chance to look at top level
2290 // navigations. 2303 // navigations.
2291 if (is_content_initiated) { 2304 if (is_content_initiated) {
2292 bool browser_handles_top_level_requests = 2305 bool browser_handles_top_level_requests =
2293 renderer_preferences_.browser_handles_top_level_requests && 2306 renderer_preferences_.browser_handles_top_level_requests &&
2294 IsNonLocalTopLevelNavigation(url, frame, type); 2307 IsNonLocalTopLevelNavigation(url, frame, type);
2295 if (browser_handles_top_level_requests || 2308 if (browser_handles_top_level_requests ||
2296 renderer_preferences_.browser_handles_all_requests) { 2309 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 2310 // Reset these counters as the RenderView could be reused for the next
2301 // navigation. 2311 // navigation.
2302 page_id_ = -1; 2312 page_id_ = -1;
2303 last_page_id_sent_to_browser_ = -1; 2313 last_page_id_sent_to_browser_ = -1;
2304 OpenURL(frame, url, referrer, default_policy); 2314 OpenURL(frame, url, referrer, default_policy);
2305 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2315 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2306 } 2316 }
2307 } 2317 }
2308 2318
2309 // Detect when we're crossing a permission-based boundary (e.g. into or out of 2319 // 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 2353 // with hosted apps and extensions than WebUI pages. We will remove this
2344 // check when cross-process POST submissions are supported. 2354 // check when cross-process POST submissions are supported.
2345 if (request.httpMethod() == "GET") { 2355 if (request.httpMethod() == "GET") {
2346 bool is_initial_navigation = page_id_ == -1; 2356 bool is_initial_navigation = page_id_ == -1;
2347 should_fork = content::GetContentClient()->renderer()->ShouldFork( 2357 should_fork = content::GetContentClient()->renderer()->ShouldFork(
2348 frame, url, is_initial_navigation, &send_referrer); 2358 frame, url, is_initial_navigation, &send_referrer);
2349 } 2359 }
2350 } 2360 }
2351 2361
2352 if (should_fork) { 2362 if (should_fork) {
2353 Referrer referrer(
2354 GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))),
2355 GetReferrerPolicyFromRequest(request));
2356 OpenURL( 2363 OpenURL(
2357 frame, url, send_referrer ? referrer : Referrer(), default_policy); 2364 frame, url, send_referrer ? referrer : Referrer(), default_policy);
2358 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2365 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2359 } 2366 }
2360 } 2367 }
2361 2368
2362 // Use the frame's original request's URL rather than the document's URL for 2369 // 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 2370 // 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. 2371 // URL if the opener has called document.write. See http://crbug.com/93517.
2365 GURL old_url(frame->dataSource()->request().url()); 2372 GURL old_url(frame->dataSource()->request().url());
(...skipping 2828 matching lines...) Expand 10 before | Expand all | Expand 10 after
5194 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5201 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5195 return !!RenderThreadImpl::current()->compositor_thread(); 5202 return !!RenderThreadImpl::current()->compositor_thread();
5196 } 5203 }
5197 5204
5198 void RenderViewImpl::OnJavaBridgeInit() { 5205 void RenderViewImpl::OnJavaBridgeInit() {
5199 DCHECK(!java_bridge_dispatcher_.get()); 5206 DCHECK(!java_bridge_dispatcher_.get());
5200 #if defined(ENABLE_JAVA_BRIDGE) 5207 #if defined(ENABLE_JAVA_BRIDGE)
5201 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5208 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5202 #endif 5209 #endif
5203 } 5210 }
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