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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 58cdf35d89b74a57b91cfe0ad80556ae4178ba2b..037051ccae222984b2e032fd313544598ce97746 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -2372,14 +2372,18 @@ WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation(
}
}
- // If the browser is interested, then give it a chance to look at top level
- // navigations.
+ // If the browser is interested, then give it a chance to look at the request.
if (is_content_initiated) {
- bool browser_handles_top_level_requests =
+ bool browser_handles_request =
renderer_preferences_.browser_handles_top_level_requests &&
IsNonLocalTopLevelNavigation(url, frame, type);
- if (browser_handles_top_level_requests ||
- renderer_preferences_.browser_handles_all_requests) {
+ if (!browser_handles_request) {
+ browser_handles_request = renderer_preferences_.
+ browser_handles_all_top_level_or_non_local_requests &&
+ IsRemoteOrTopLevelNavigation(url, frame);
+ }
+
+ if (browser_handles_request) {
// Reset these counters as the RenderView could be reused for the next
// navigation.
page_id_ = -1;
@@ -5304,8 +5308,23 @@ WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
return media_stream_impl_;
}
+bool RenderViewImpl::IsRemoteOrTopLevelNavigation(
abarth-chromium 2012/05/18 18:34:07 "remote" is sort of a funny term to use here. For
+ const GURL& url, WebKit::WebFrame* frame) const {
+ if (frame->parent() == NULL)
+ return true;
+
+ // blob: and data: URLs don't involve remote content either, thus are
+ // considered local.
+ if (url.SchemeIs(chrome::kBlobScheme) || url.SchemeIs(chrome::kDataScheme))
abarth-chromium 2012/05/18 18:34:07 Presumably filesystem is in this category too.
+ return false;
+
+ return url.GetOrigin() !=
+ GURL(frame->document().securityOrigin().toString().utf8());
+}
+
bool RenderViewImpl::IsNonLocalTopLevelNavigation(
- const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
+ const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type)
+ const {
// Must be a top level frame.
if (frame->parent() != NULL)
return false;
« 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