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

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

Issue 10387074: Only disallow top-level navigations in platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add blob: URLs, use WebSecurityOrigin Created 8 years, 7 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/renderer/render_view_impl.h ('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 2354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 WebString origin_str = frame->document().securityOrigin().toString(); 2365 WebString origin_str = frame->document().securityOrigin().toString();
2366 GURL frame_url(origin_str.utf8().data()); 2366 GURL frame_url(origin_str.utf8().data());
2367 // TODO(cevans): revisit whether this origin check is still necessary once 2367 // TODO(cevans): revisit whether this origin check is still necessary once
2368 // crbug.com/101395 is fixed. 2368 // crbug.com/101395 is fixed.
2369 if (frame_url.GetOrigin() != url.GetOrigin()) { 2369 if (frame_url.GetOrigin() != url.GetOrigin()) {
2370 OpenURL(frame, url, referrer, default_policy); 2370 OpenURL(frame, url, referrer, default_policy);
2371 return WebKit::WebNavigationPolicyIgnore; 2371 return WebKit::WebNavigationPolicyIgnore;
2372 } 2372 }
2373 } 2373 }
2374 2374
2375 // If the browser is interested, then give it a chance to look at top level 2375 // If the browser is interested, then give it a chance to look at the request.
2376 // navigations.
2377 if (is_content_initiated) { 2376 if (is_content_initiated) {
2378 bool browser_handles_top_level_requests = 2377 bool browser_handles_request =
2379 renderer_preferences_.browser_handles_top_level_requests && 2378 renderer_preferences_.browser_handles_top_level_requests &&
2380 IsNonLocalTopLevelNavigation(url, frame, type); 2379 IsNonLocalTopLevelNavigation(url, frame, type);
2381 if (browser_handles_top_level_requests || 2380 if (!browser_handles_request) {
2382 renderer_preferences_.browser_handles_all_requests) { 2381 browser_handles_request = renderer_preferences_.
2382 browser_handles_all_top_level_or_non_local_requests &&
2383 IsRemoteOrTopLevelNavigation(url, frame);
2384 }
2385
2386 if (browser_handles_request) {
2383 // Reset these counters as the RenderView could be reused for the next 2387 // Reset these counters as the RenderView could be reused for the next
2384 // navigation. 2388 // navigation.
2385 page_id_ = -1; 2389 page_id_ = -1;
2386 last_page_id_sent_to_browser_ = -1; 2390 last_page_id_sent_to_browser_ = -1;
2387 OpenURL(frame, url, referrer, default_policy); 2391 OpenURL(frame, url, referrer, default_policy);
2388 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2392 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here.
2389 } 2393 }
2390 } 2394 }
2391 2395
2392 // Detect when we're crossing a permission-based boundary (e.g. into or out of 2396 // Detect when we're crossing a permission-based boundary (e.g. into or out of
(...skipping 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after
5297 &override_state)) 5301 &override_state))
5298 return override_state; 5302 return override_state;
5299 return current_state; 5303 return current_state;
5300 } 5304 }
5301 5305
5302 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { 5306 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
5303 EnsureMediaStreamImpl(); 5307 EnsureMediaStreamImpl();
5304 return media_stream_impl_; 5308 return media_stream_impl_;
5305 } 5309 }
5306 5310
5311 bool RenderViewImpl::IsRemoteOrTopLevelNavigation(
abarth-chromium 2012/05/18 18:34:07 "remote" is sort of a funny term to use here. For
5312 const GURL& url, WebKit::WebFrame* frame) const {
5313 if (frame->parent() == NULL)
5314 return true;
5315
5316 // blob: and data: URLs don't involve remote content either, thus are
5317 // considered local.
5318 if (url.SchemeIs(chrome::kBlobScheme) || url.SchemeIs(chrome::kDataScheme))
abarth-chromium 2012/05/18 18:34:07 Presumably filesystem is in this category too.
5319 return false;
5320
5321 return url.GetOrigin() !=
5322 GURL(frame->document().securityOrigin().toString().utf8());
5323 }
5324
5307 bool RenderViewImpl::IsNonLocalTopLevelNavigation( 5325 bool RenderViewImpl::IsNonLocalTopLevelNavigation(
5308 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { 5326 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type)
5327 const {
5309 // Must be a top level frame. 5328 // Must be a top level frame.
5310 if (frame->parent() != NULL) 5329 if (frame->parent() != NULL)
5311 return false; 5330 return false;
5312 5331
5313 // Navigations initiated within Webkit are not sent out to the external host 5332 // Navigations initiated within Webkit are not sent out to the external host
5314 // in the following cases. 5333 // in the following cases.
5315 // 1. The url scheme is not http/https 5334 // 1. The url scheme is not http/https
5316 // 2. The origin of the url and the opener is the same in which case the 5335 // 2. The origin of the url and the opener is the same in which case the
5317 // opener relationship is maintained. 5336 // opener relationship is maintained.
5318 // 3. Reloads/form submits/back forward navigations 5337 // 3. Reloads/form submits/back forward navigations
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
5391 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5410 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5392 return !!RenderThreadImpl::current()->compositor_thread(); 5411 return !!RenderThreadImpl::current()->compositor_thread();
5393 } 5412 }
5394 5413
5395 void RenderViewImpl::OnJavaBridgeInit() { 5414 void RenderViewImpl::OnJavaBridgeInit() {
5396 DCHECK(!java_bridge_dispatcher_); 5415 DCHECK(!java_bridge_dispatcher_);
5397 #if defined(ENABLE_JAVA_BRIDGE) 5416 #if defined(ENABLE_JAVA_BRIDGE)
5398 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); 5417 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this);
5399 #endif 5418 #endif
5400 } 5419 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698