summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 17:44:55 +0000
committerjknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-24 17:44:55 +0000
commitd317a34aaf4c25b86bfa71c8581bc8c91fd82d46 (patch)
tree72b9c04fedbfcca7165c281c9f5900defc457692
parent7c3b7003d5f513a2608ec6586901d6367a21b0e6 (diff)
downloadchromium_src-d317a34aaf4c25b86bfa71c8581bc8c91fd82d46.zip
chromium_src-d317a34aaf4c25b86bfa71c8581bc8c91fd82d46.tar.gz
chromium_src-d317a34aaf4c25b86bfa71c8581bc8c91fd82d46.tar.bz2
Use the InterceptNavigationDelegate to implement URL overriding.
Install an InterceptNavigation throttle in ChromeResourceDispatcherHost so that top-level navigations may be intercepted. We now call the delegate directly from ExternalProtocolHandler:: RunExternalProtocolDialog, so we can remove TabAndroid:: RunExternalProtocolDialog. TBR=mkosiba,yfriedman,darin BUG=156044 Review URL: https://chromiumcodereview.appspot.com/11274010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@163861 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/android/chrome_jni_registrar.cc4
-rw-r--r--chrome/browser/android/tab_android.cc3
-rw-r--r--chrome/browser/android/tab_android.h4
-rw-r--r--chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc15
-rw-r--r--chrome/browser/ui/android/external_protocol_dialog_android.cc18
-rw-r--r--chrome/chrome.gyp1
6 files changed, 36 insertions, 9 deletions
diff --git a/chrome/browser/android/chrome_jni_registrar.cc b/chrome/browser/android/chrome_jni_registrar.cc
index d8c5e94..e02415d 100644
--- a/chrome/browser/android/chrome_jni_registrar.cc
+++ b/chrome/browser/android/chrome_jni_registrar.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/android/intent_helper.h"
#include "chrome/browser/android/process_utils.h"
#include "chrome/browser/android/provider/chrome_browser_provider.h"
+#include "chrome/browser/component/navigation_interception/component_jni_registrar.h"
#include "chrome/browser/component/web_contents_delegate_android/component_jni_registrar.h"
#include "chrome/browser/history/android/sqlite_cursor.h"
#include "chrome/browser/ui/android/autofill/autofill_external_delegate.h"
@@ -31,7 +32,8 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
{ "JavascriptAppModalDialog",
JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog },
{ "ProcessUtils", RegisterProcessUtils },
- { "SqliteCursor", SQLiteCursor::RegisterSqliteCursor},
+ { "SqliteCursor", SQLiteCursor::RegisterSqliteCursor },
+ { "navigation_interception", navigation_interception::RegisterJni },
};
bool RegisterJni(JNIEnv* env) {
diff --git a/chrome/browser/android/tab_android.cc b/chrome/browser/android/tab_android.cc
index 6f76bd4..a516e4b 100644
--- a/chrome/browser/android/tab_android.cc
+++ b/chrome/browser/android/tab_android.cc
@@ -82,3 +82,6 @@ TabAndroid::TabAndroid() : tab_id_(-1) {
TabAndroid::~TabAndroid() {
}
+
+void TabAndroid::RunExternalProtocolDialog(const GURL& url) {
+}
diff --git a/chrome/browser/android/tab_android.h b/chrome/browser/android/tab_android.h
index 764e537..0d10b30 100644
--- a/chrome/browser/android/tab_android.h
+++ b/chrome/browser/android/tab_android.h
@@ -68,7 +68,9 @@ class TabAndroid {
// Called when the common ExternalProtocolHandler wants to
// run the external protocol dialog.
- virtual void RunExternalProtocolDialog(const GURL& url) = 0;
+ // TODO(jknotten): Remove this method. Making it non-abstract, so that
+ // derived classes may remove their implementation first.
+ virtual void RunExternalProtocolDialog(const GURL& url);
protected:
virtual ~TabAndroid();
diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
index 0534172..4f4174d 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
@@ -45,6 +45,10 @@
#include "net/url_request/url_request.h"
#include "third_party/protobuf/src/google/protobuf/repeated_field.h"
+#if defined(OS_ANDROID)
+#include "chrome/browser/component/navigation_interception/intercept_navigation_delegate.h"
+#endif
+
// TODO(oshima): Enable this for other platforms.
#if defined(OS_CHROMEOS)
#include "chrome/browser/renderer_host/offline_resource_throttle.h"
@@ -130,11 +134,20 @@ void ChromeResourceDispatcherHostDelegate::RequestBeginning(
ChromeURLRequestUserData* user_data =
ChromeURLRequestUserData::Create(request);
- if (prerender_tracker_->IsPrerenderingOnIOThread(child_id, route_id)) {
+ bool is_prerendering = prerender_tracker_->IsPrerenderingOnIOThread(
+ child_id, route_id);
+ if (is_prerendering) {
user_data->set_is_prerender(true);
request->set_priority(net::IDLE);
}
+#if defined(OS_ANDROID)
+ if (!is_prerendering && resource_type == ResourceType::MAIN_FRAME) {
+ throttles->push_back(
+ navigation_interception::InterceptNavigationDelegate::CreateThrottleFor(
+ request));
+ }
+#endif
#if defined(OS_CHROMEOS)
if (resource_type == ResourceType::MAIN_FRAME) {
// We check offline first, then check safe browsing so that we still can
diff --git a/chrome/browser/ui/android/external_protocol_dialog_android.cc b/chrome/browser/ui/android/external_protocol_dialog_android.cc
index a39764e..6d5673f 100644
--- a/chrome/browser/ui/android/external_protocol_dialog_android.cc
+++ b/chrome/browser/ui/android/external_protocol_dialog_android.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "base/logging.h"
-#include "chrome/browser/android/tab_android.h"
+#include "chrome/browser/component/navigation_interception/intercept_navigation_delegate.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "content/public/browser/web_contents.h"
@@ -15,9 +15,15 @@ void ExternalProtocolHandler::RunExternalProtocolDialog(
const GURL& url, int render_process_host_id, int routing_id) {
WebContents* web_contents = tab_util::GetWebContentsByID(
render_process_host_id, routing_id);
- if (web_contents) {
- TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
- if (tab)
- return tab->RunExternalProtocolDialog(url);
- }
+ if (!web_contents)
+ return;
+ navigation_interception::InterceptNavigationDelegate* delegate =
+ navigation_interception::InterceptNavigationDelegate::Get(web_contents);
+ if (!delegate)
+ return;
+
+ // TODO(jknotten): The call to ShouldIgnoreNavigation returns false if there
+ // are no applications that can handle the given URL. In this case, an error
+ // page should be displayed to the user.
+ delegate->ShouldIgnoreNavigation(url, true /* has_user_gesture */ );
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index a38b4fb..801221f 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1050,6 +1050,7 @@
'type': 'none',
'dependencies': [
'../base/base.gyp:base',
+ '../chrome/browser/component/components.gyp:navigation_interception_java',
'../chrome/browser/component/components.gyp:web_contents_delegate_android_java',
'../content/content.gyp:content_java',
'../ui/ui.gyp:ui_java',