Commit 2b5e3a6a authored by jaekyun's avatar jaekyun Committed by Commit bot

Add is_external_protocol to NavigationParams

Java layer needs an exact way to determine whether a URL uses an external
protocol or not.
is_external_protocol will be true if a URL can't be handled by Chrome's
internal protocol handlers.

BUG=426751

Review URL: https://codereview.chromium.org/884473004

Cr-Commit-Position: refs/heads/master@{#313606}
parent db9f2761
...@@ -17,20 +17,23 @@ public class NavigationParams { ...@@ -17,20 +17,23 @@ public class NavigationParams {
public final int pageTransitionType; public final int pageTransitionType;
// Is the navigation a redirect (in which case url is the "target" address). // Is the navigation a redirect (in which case url is the "target" address).
public final boolean isRedirect; public final boolean isRedirect;
// True if the target url can't be handled by Chrome's internal protocol handlers.
public final boolean isExternalProtocol;
public NavigationParams(String url, boolean isPost, boolean hasUserGesture, public NavigationParams(String url, boolean isPost, boolean hasUserGesture,
int pageTransitionType, boolean isRedirect) { int pageTransitionType, boolean isRedirect, boolean isExternalProtocol) {
this.url = url; this.url = url;
this.isPost = isPost; this.isPost = isPost;
this.hasUserGesture = hasUserGesture; this.hasUserGesture = hasUserGesture;
this.pageTransitionType = pageTransitionType; this.pageTransitionType = pageTransitionType;
this.isRedirect = isRedirect; this.isRedirect = isRedirect;
this.isExternalProtocol = isExternalProtocol;
} }
@CalledByNative @CalledByNative
public static NavigationParams create(String url, boolean isPost, boolean hasUserGesture, public static NavigationParams create(String url, boolean isPost, boolean hasUserGesture,
int pageTransitionType, boolean isRedirect) { int pageTransitionType, boolean isRedirect, boolean isExternalProtocol) {
return new NavigationParams(url, isPost, hasUserGesture, pageTransitionType, return new NavigationParams(
isRedirect); url, isPost, hasUserGesture, pageTransitionType, isRedirect, isExternalProtocol);
} }
} }
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/resource_controller.h" #include "content/public/browser/resource_controller.h"
#include "content/public/browser/resource_request_info.h" #include "content/public/browser/resource_request_info.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/referrer.h" #include "content/public/common/referrer.h"
#include "net/http/http_response_headers.h" #include "net/http/http_response_headers.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_job_factory.h"
#include "net/url_request/url_request.h" #include "net/url_request/url_request.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
...@@ -110,13 +113,13 @@ bool InterceptNavigationResourceThrottle::CheckIfShouldIgnoreNavigation( ...@@ -110,13 +113,13 @@ bool InterceptNavigationResourceThrottle::CheckIfShouldIgnoreNavigation(
if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id))
return false; return false;
NavigationParams navigation_params(url, bool is_external_protocol =
Referrer(GURL(request_->referrer()), !info->GetContext()->GetRequestContext()->job_factory()->IsHandledURL(
info->GetReferrerPolicy()), url);
info->HasUserGesture(), NavigationParams navigation_params(
method == "POST", url, Referrer(GURL(request_->referrer()), info->GetReferrerPolicy()),
info->GetPageTransition(), info->HasUserGesture(), method == "POST", info->GetPageTransition(),
is_redirect); is_redirect, is_external_protocol);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, BrowserThread::UI,
......
...@@ -10,19 +10,20 @@ NavigationParams::NavigationParams(const NavigationParams& other) { ...@@ -10,19 +10,20 @@ NavigationParams::NavigationParams(const NavigationParams& other) {
Assign(other); Assign(other);
} }
NavigationParams::NavigationParams( NavigationParams::NavigationParams(const GURL& url,
const GURL& url,
const content::Referrer& referrer, const content::Referrer& referrer,
bool has_user_gesture, bool has_user_gesture,
bool is_post, bool is_post,
ui::PageTransition transition_type, ui::PageTransition transition_type,
bool is_redirect) bool is_redirect,
bool is_external_protocol)
: url_(url), : url_(url),
referrer_(referrer), referrer_(referrer),
has_user_gesture_(has_user_gesture), has_user_gesture_(has_user_gesture),
is_post_(is_post), is_post_(is_post),
transition_type_(transition_type), transition_type_(transition_type),
is_redirect_(is_redirect) { is_redirect_(is_redirect),
is_external_protocol_(is_external_protocol) {
} }
void NavigationParams::operator=(const NavigationParams& rhs) { void NavigationParams::operator=(const NavigationParams& rhs) {
...@@ -36,6 +37,7 @@ void NavigationParams::Assign(const NavigationParams& other) { ...@@ -36,6 +37,7 @@ void NavigationParams::Assign(const NavigationParams& other) {
is_post_ = other.is_post(); is_post_ = other.is_post();
transition_type_ = other.transition_type(); transition_type_ = other.transition_type();
is_redirect_ = other.is_redirect(); is_redirect_ = other.is_redirect();
is_external_protocol_ = other.is_external_protocol();
} }
} // namespace navigation_interception } // namespace navigation_interception
......
...@@ -19,7 +19,8 @@ class NavigationParams { ...@@ -19,7 +19,8 @@ class NavigationParams {
bool has_user_gesture, bool has_user_gesture,
bool is_post, bool is_post,
ui::PageTransition page_transition_type, ui::PageTransition page_transition_type,
bool is_redirect); bool is_redirect,
bool is_external_protocol);
NavigationParams(const NavigationParams& other); NavigationParams(const NavigationParams& other);
void operator=(const NavigationParams& rhs); void operator=(const NavigationParams& rhs);
...@@ -30,6 +31,7 @@ class NavigationParams { ...@@ -30,6 +31,7 @@ class NavigationParams {
bool is_post() const { return is_post_; } bool is_post() const { return is_post_; }
ui::PageTransition transition_type() const { return transition_type_; } ui::PageTransition transition_type() const { return transition_type_; }
bool is_redirect() const { return is_redirect_; } bool is_redirect() const { return is_redirect_; }
bool is_external_protocol() const { return is_external_protocol_; }
private: private:
void Assign(const NavigationParams& other); void Assign(const NavigationParams& other);
...@@ -40,6 +42,7 @@ class NavigationParams { ...@@ -40,6 +42,7 @@ class NavigationParams {
bool is_post_; bool is_post_;
ui::PageTransition transition_type_; ui::PageTransition transition_type_;
bool is_redirect_; bool is_redirect_;
bool is_external_protocol_;
}; };
} // namespace navigation_interception } // namespace navigation_interception
......
...@@ -17,12 +17,10 @@ base::android::ScopedJavaLocalRef<jobject> CreateJavaNavigationParams( ...@@ -17,12 +17,10 @@ base::android::ScopedJavaLocalRef<jobject> CreateJavaNavigationParams(
ScopedJavaLocalRef<jstring> jstring_url = ScopedJavaLocalRef<jstring> jstring_url =
ConvertUTF8ToJavaString(env, params.url().spec()); ConvertUTF8ToJavaString(env, params.url().spec());
return Java_NavigationParams_create(env, return Java_NavigationParams_create(
jstring_url.obj(), env, jstring_url.obj(), params.is_post(), params.has_user_gesture(),
params.is_post(), params.transition_type(), params.is_redirect(),
params.has_user_gesture(), params.is_external_protocol());
params.transition_type(),
params.is_redirect());
} }
// Register native methods. // Register native methods.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment