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

Unified Diff: android_webview/renderer/aw_content_renderer_client.cc

Issue 24228003: Upstream ShouldOverrideUrlLoading changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: filter out about scheme Created 7 years, 3 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
Index: android_webview/renderer/aw_content_renderer_client.cc
diff --git a/android_webview/renderer/aw_content_renderer_client.cc b/android_webview/renderer/aw_content_renderer_client.cc
index 92e3625a906d38bf937b8f7eb36dfb47ae44ef9f..b0630910fddbd1d1dc6f9b86a156b9c6f7fc8f18 100644
--- a/android_webview/renderer/aw_content_renderer_client.cc
+++ b/android_webview/renderer/aw_content_renderer_client.cc
@@ -5,6 +5,7 @@
#include "android_webview/renderer/aw_content_renderer_client.h"
#include "android_webview/common/aw_resource.h"
+#include "android_webview/common/render_view_messages.h"
#include "android_webview/common/url_constants.h"
#include "android_webview/renderer/aw_render_view_ext.h"
#include "base/message_loop/message_loop.h"
@@ -12,12 +13,17 @@
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
#include "components/visitedlink/renderer/visitedlink_slave.h"
+#include "content/public/renderer/document_state.h"
+#include "content/public/renderer/navigation_state.h"
#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/render_view.h"
#include "net/base/net_errors.h"
#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebNavigationType.h"
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
#include "url/gurl.h"
@@ -43,6 +49,51 @@ void AwContentRendererClient::RenderThreadStarted() {
thread->AddObserver(visited_link_slave_.get());
}
+bool AwContentRendererClient::HandleNavigation(
+ content::RenderView* view,
+ content::DocumentState* document_state,
+ WebKit::WebFrame* frame,
+ const WebKit::WebURLRequest& request,
+ WebKit::WebNavigationType type,
+ WebKit::WebNavigationPolicy default_policy,
+ bool is_redirect) {
+
+ // Only GETs can be overridden.
+ if (!request.httpMethod().equals("GET"))
+ return false;
+
+ // Any navigation from loadUrl, and goBack/Forward are considered application-
+ // initiated and hence will not yield a shouldOverrideUrlLoading() callback.
+ // Webview classic does not consider reload application-initiated so we
+ // continue the same behavior.
+ bool application_initiated =
+ !document_state->navigation_state()->is_content_initiated()
mkosiba (inactive) 2013/09/25 22:23:26 is_content_initiated would normally be false for c
sgurun-gerrit only 2013/10/09 00:26:13 Done.
+ || type == WebKit::WebNavigationTypeBackForward;
+
+ // Don't offer application-initiated navigations unless it's a redirect.
+ if (application_initiated && !is_redirect)
+ return false;
+
+ const GURL& gurl = request.url();
+ // For HTTP schemes, only top-level navigations can be overridden.
+ // HandleNavigation receives about:blank navigations, (for example for
+ // empty iframes), however webview classic does not pass these to the
+ // app using shouldoverrideurlloading, so we filter them out here. Not
+ // adding a special test for this, since removing the filtering causes
+ // multiple shouldoverrideurlloading aw tests to fail, anyway.
+ if (frame->parent() && (gurl.SchemeIs("http") || gurl.SchemeIs("https") ||
+ gurl.SchemeIs("about")))
+ return false;
+
+ bool ignore_navigation = false;
+ int routing_id = view->GetRoutingID();
+ base::string16 url = request.url().string();
+ view->Send (new AwViewHostMsg_ShouldOverrideUrlLoading(routing_id,
+ url,
+ &ignore_navigation));
+ return ignore_navigation;
+}
+
void AwContentRendererClient::RenderViewCreated(
content::RenderView* render_view) {
AwRenderViewExt::RenderViewCreated(render_view);
« no previous file with comments | « android_webview/renderer/aw_content_renderer_client.h ('k') | content/browser/renderer_host/render_view_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698