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 {
public final int pageTransitionType;
// Is the navigation a redirect (in which case url is the "target" address).
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,
int pageTransitionType, boolean isRedirect) {
int pageTransitionType, boolean isRedirect, boolean isExternalProtocol) {
this.url = url;
this.isPost = isPost;
this.hasUserGesture = hasUserGesture;
this.pageTransitionType = pageTransitionType;
this.isRedirect = isRedirect;
this.isExternalProtocol = isExternalProtocol;
}
@CalledByNative
public static NavigationParams create(String url, boolean isPost, boolean hasUserGesture,
int pageTransitionType, boolean isRedirect) {
return new NavigationParams(url, isPost, hasUserGesture, pageTransitionType,
isRedirect);
int pageTransitionType, boolean isRedirect, boolean isExternalProtocol) {
return new NavigationParams(
url, isPost, hasUserGesture, pageTransitionType, isRedirect, isExternalProtocol);
}
}
......@@ -9,11 +9,14 @@
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_frame_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_request_info.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/referrer.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 "ui/base/page_transition_types.h"
......@@ -110,13 +113,13 @@ bool InterceptNavigationResourceThrottle::CheckIfShouldIgnoreNavigation(
if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id))
return false;
NavigationParams navigation_params(url,
Referrer(GURL(request_->referrer()),
info->GetReferrerPolicy()),
info->HasUserGesture(),
method == "POST",
info->GetPageTransition(),
is_redirect);
bool is_external_protocol =
!info->GetContext()->GetRequestContext()->job_factory()->IsHandledURL(
url);
NavigationParams navigation_params(
url, Referrer(GURL(request_->referrer()), info->GetReferrerPolicy()),
info->HasUserGesture(), method == "POST", info->GetPageTransition(),
is_redirect, is_external_protocol);
BrowserThread::PostTask(
BrowserThread::UI,
......
......@@ -10,19 +10,20 @@ NavigationParams::NavigationParams(const NavigationParams& other) {
Assign(other);
}
NavigationParams::NavigationParams(
const GURL& url,
const content::Referrer& referrer,
bool has_user_gesture,
bool is_post,
ui::PageTransition transition_type,
bool is_redirect)
NavigationParams::NavigationParams(const GURL& url,
const content::Referrer& referrer,
bool has_user_gesture,
bool is_post,
ui::PageTransition transition_type,
bool is_redirect,
bool is_external_protocol)
: url_(url),
referrer_(referrer),
has_user_gesture_(has_user_gesture),
is_post_(is_post),
transition_type_(transition_type),
is_redirect_(is_redirect) {
is_redirect_(is_redirect),
is_external_protocol_(is_external_protocol) {
}
void NavigationParams::operator=(const NavigationParams& rhs) {
......@@ -36,6 +37,7 @@ void NavigationParams::Assign(const NavigationParams& other) {
is_post_ = other.is_post();
transition_type_ = other.transition_type();
is_redirect_ = other.is_redirect();
is_external_protocol_ = other.is_external_protocol();
}
} // namespace navigation_interception
......
......@@ -19,7 +19,8 @@ class NavigationParams {
bool has_user_gesture,
bool is_post,
ui::PageTransition page_transition_type,
bool is_redirect);
bool is_redirect,
bool is_external_protocol);
NavigationParams(const NavigationParams& other);
void operator=(const NavigationParams& rhs);
......@@ -30,6 +31,7 @@ class NavigationParams {
bool is_post() const { return is_post_; }
ui::PageTransition transition_type() const { return transition_type_; }
bool is_redirect() const { return is_redirect_; }
bool is_external_protocol() const { return is_external_protocol_; }
private:
void Assign(const NavigationParams& other);
......@@ -40,6 +42,7 @@ class NavigationParams {
bool is_post_;
ui::PageTransition transition_type_;
bool is_redirect_;
bool is_external_protocol_;
};
} // namespace navigation_interception
......
......@@ -17,12 +17,10 @@ base::android::ScopedJavaLocalRef<jobject> CreateJavaNavigationParams(
ScopedJavaLocalRef<jstring> jstring_url =
ConvertUTF8ToJavaString(env, params.url().spec());
return Java_NavigationParams_create(env,
jstring_url.obj(),
params.is_post(),
params.has_user_gesture(),
params.transition_type(),
params.is_redirect());
return Java_NavigationParams_create(
env, jstring_url.obj(), params.is_post(), params.has_user_gesture(),
params.transition_type(), params.is_redirect(),
params.is_external_protocol());
}
// 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