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

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

Issue 9978015: Make browser_handles_top_level_requests synchronous. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build error Created 8 years, 8 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
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 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 // TODO(cevans): revisit whether this origin check is still necessary once 2318 // TODO(cevans): revisit whether this origin check is still necessary once
2319 // crbug.com/101395 is fixed. 2319 // crbug.com/101395 is fixed.
2320 if (frame_url.GetOrigin() != url.GetOrigin()) { 2320 if (frame_url.GetOrigin() != url.GetOrigin()) {
2321 OpenURL(frame, url, referrer, default_policy); 2321 OpenURL(frame, url, referrer, default_policy);
2322 return WebKit::WebNavigationPolicyIgnore; 2322 return WebKit::WebNavigationPolicyIgnore;
2323 } 2323 }
2324 } 2324 }
2325 2325
2326 // If the browser is interested, then give it a chance to look at top level 2326 // If the browser is interested, then give it a chance to look at top level
2327 // navigations. 2327 // navigations.
2328 if (is_content_initiated) { 2328 if (renderer_preferences_.browser_handles_top_level_requests) {
Charlie Reis 2012/04/05 17:06:53 I thought this was here so it didn't send browser-
mkosiba (inactive) 2012/04/10 17:58:37 The change is here so that Chrome on *Android* doe
2329 bool browser_handles_top_level_requests = 2329 if (IsNonLocalTopLevelNavigation(url, frame, type) ||
2330 renderer_preferences_.browser_handles_top_level_requests &&
2331 IsNonLocalTopLevelNavigation(url, frame, type);
2332 if (browser_handles_top_level_requests ||
2333 renderer_preferences_.browser_handles_all_requests) { 2330 renderer_preferences_.browser_handles_all_requests) {
2334 // Reset these counters as the RenderView could be reused for the next 2331 // Reset these counters as the RenderView could be reused for the next
2335 // navigation. 2332 // navigation.
2336 page_id_ = -1; 2333 page_id_ = -1;
2337 last_page_id_sent_to_browser_ = -1; 2334 last_page_id_sent_to_browser_ = -1;
2338 OpenURL(frame, url, referrer, default_policy); 2335 bool ignore_navigation = false;
2339 return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. 2336 Send(new ViewHostMsg_ShouldIgnoreNavigation(
2337 routing_id_,
2338 url,
2339 referrer,
2340 NavigationPolicyToDisposition(default_policy),
2341 frame->identifier(),
2342 is_content_initiated,
2343 &ignore_navigation));
2344 if (ignore_navigation)
2345 return WebKit::WebNavigationPolicyIgnore;
2340 } 2346 }
2341 } 2347 }
2342 2348
2343 // Detect when we're crossing a permission-based boundary (e.g. into or out of 2349 // Detect when we're crossing a permission-based boundary (e.g. into or out of
2344 // an extension or app origin, leaving a WebUI page, etc). We only care about 2350 // an extension or app origin, leaving a WebUI page, etc). We only care about
2345 // top-level navigations (not iframes). But we sometimes navigate to 2351 // top-level navigations (not iframes). But we sometimes navigate to
2346 // about:blank to clear a tab, and we want to still allow that. 2352 // about:blank to clear a tab, and we want to still allow that.
2347 // 2353 //
2348 // Note: this is known to break POST submissions when crossing process 2354 // Note: this is known to break POST submissions when crossing process
2349 // boundaries until http://crbug.com/101395 is fixed. This is better for 2355 // boundaries until http://crbug.com/101395 is fixed. This is better for
(...skipping 2799 matching lines...) Expand 10 before | Expand all | Expand 10 after
5149 // Must be a top level frame. 5155 // Must be a top level frame.
5150 if (frame->parent() != NULL) 5156 if (frame->parent() != NULL)
5151 return false; 5157 return false;
5152 5158
5153 // Navigations initiated within Webkit are not sent out to the external host 5159 // Navigations initiated within Webkit are not sent out to the external host
5154 // in the following cases. 5160 // in the following cases.
5155 // 1. The url scheme is not http/https 5161 // 1. The url scheme is not http/https
5156 // 2. The origin of the url and the opener is the same in which case the 5162 // 2. The origin of the url and the opener is the same in which case the
5157 // opener relationship is maintained. 5163 // opener relationship is maintained.
5158 // 3. Reloads/form submits/back forward navigations 5164 // 3. Reloads/form submits/back forward navigations
5165 #if defined(OS_ANDROID)
5166 // It is possible for applications to register handlers for URLs (like
5167 // http://maps.google.com/), so we do need to consider http:// and https://
5168 // URLs as well as anything else.
5169 #else
Charlie Reis 2012/04/05 17:06:53 This also makes me nervous. I'd rather have a wel
groby-ooo-7-16 2012/04/05 22:51:19 Specifically, unless I misread the intent - this d
mkosiba (inactive) 2012/04/10 17:58:37 Agreed. My bad for sticking this in to the CL - th
5159 if (!url.SchemeIs(chrome::kHttpScheme) && !url.SchemeIs(chrome::kHttpsScheme)) 5170 if (!url.SchemeIs(chrome::kHttpScheme) && !url.SchemeIs(chrome::kHttpsScheme))
5160 return false; 5171 return false;
5172 #endif
5161 5173
5162 // Not interested in reloads/form submits/resubmits/back forward navigations. 5174 // Not interested in reloads/form submits/resubmits/back forward navigations.
5163 if (type != WebKit::WebNavigationTypeReload && 5175 if (type != WebKit::WebNavigationTypeReload &&
5164 type != WebKit::WebNavigationTypeFormSubmitted && 5176 type != WebKit::WebNavigationTypeFormSubmitted &&
5165 type != WebKit::WebNavigationTypeFormResubmitted && 5177 type != WebKit::WebNavigationTypeFormResubmitted &&
5166 type != WebKit::WebNavigationTypeBackForward) { 5178 type != WebKit::WebNavigationTypeBackForward) {
5167 // The opener relationship between the new window and the parent allows the 5179 // The opener relationship between the new window and the parent allows the
5168 // new window to script the parent and vice versa. This is not allowed if 5180 // new window to script the parent and vice versa. This is not allowed if
5169 // the origins of the two domains are different. This can be treated as a 5181 // the origins of the two domains are different. This can be treated as a
5170 // top level navigation and routed back to the host. 5182 // top level navigation and routed back to the host.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5233 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5245 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5234 return !!RenderThreadImpl::current()->compositor_thread(); 5246 return !!RenderThreadImpl::current()->compositor_thread();
5235 } 5247 }
5236 5248
5237 void RenderViewImpl::OnJavaBridgeInit() { 5249 void RenderViewImpl::OnJavaBridgeInit() {
5238 DCHECK(!java_bridge_dispatcher_.get()); 5250 DCHECK(!java_bridge_dispatcher_.get());
5239 #if defined(ENABLE_JAVA_BRIDGE) 5251 #if defined(ENABLE_JAVA_BRIDGE)
5240 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 5252 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
5241 #endif 5253 #endif
5242 } 5254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698