diff options
author | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-21 18:28:30 +0000 |
---|---|---|
committer | leandrogracia@chromium.org <leandrogracia@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-21 18:28:30 +0000 |
commit | f1c3c7977af93d1421db66d39ea83b9aa97747e2 (patch) | |
tree | 80a97f67fc5aa7490705628333fe2f8088f36c56 /android_webview | |
parent | a9b4441d02e85aac508fc2707b9f2cbde142421b (diff) | |
download | chromium_src-f1c3c7977af93d1421db66d39ea83b9aa97747e2.zip chromium_src-f1c3c7977af93d1421db66d39ea83b9aa97747e2.tar.gz chromium_src-f1c3c7977af93d1421db66d39ea83b9aa97747e2.tar.bz2 |
Refactor the Android port to allow access to the chrome layer.
While in desktop chrome the main WebContentsDelegate is implemented in the
chrome layer by the Browser class, the Android port implements it in the
content layer in its ContentViewClient class. However, because of the content
layering limitations this renders the chrome layer out of reach.
This patch splits the WebContentsDelegate implementation in ContentViewClient
into a separate class named WebContentsDelegateAndroid in the first chrome browser component "web_contents_delegate_android".
Also, this patch introduces stubs for Chrome-specific and WebView-specific extensions of WebContentsDelegateAndroid in order to set the foundations for later patches.
BUG=137967
TEST=existing tests
Review URL: https://chromiumcodereview.appspot.com/10831060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152598 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/DEPS | 2 | ||||
-rwxr-xr-x | android_webview/build/install_binary | 23 | ||||
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegate.java | 18 | ||||
-rw-r--r-- | android_webview/lib/android_webview.gyp | 30 | ||||
-rw-r--r-- | android_webview/lib/main/webview_entry_point.cc | 7 | ||||
-rw-r--r-- | android_webview/native/android_webview_jni_registrar.cc | 17 | ||||
-rw-r--r-- | android_webview/native/android_webview_jni_registrar.h | 17 | ||||
-rw-r--r-- | android_webview/native/aw_web_contents_delegate.cc | 18 | ||||
-rw-r--r-- | android_webview/native/aw_web_contents_delegate.h | 26 | ||||
-rw-r--r-- | android_webview/native/webview_native.gyp | 40 |
10 files changed, 196 insertions, 2 deletions
diff --git a/android_webview/DEPS b/android_webview/DEPS index ea141dc..ed3891d 100644 --- a/android_webview/DEPS +++ b/android_webview/DEPS @@ -6,5 +6,7 @@ # chrome/ should go into android_webview/lib/ or be refactored. include_rules = [ + "+chrome/android/java/src/org/chromium/chrome/browser/component", + "+chrome/browser/component", "+content/public", ] diff --git a/android_webview/build/install_binary b/android_webview/build/install_binary new file mode 100755 index 0000000..24aaa83 --- /dev/null +++ b/android_webview/build/install_binary @@ -0,0 +1,23 @@ +#!/bin/bash -x +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Copies a possibly stripped binary and a symbol file to installation dirs. + +if [ "$3" = "" ] +then + echo "Usage: install_binary path/to/binary path/to/target1 path/to/target2 path/to/symbols" + exit 1 +fi + +SOURCE=$1 +TARGET=$2 +TARGET2=$3 +SYMBOLS=$4 + +mkdir -p $(dirname $SYMBOLS) + +cp $SOURCE $SYMBOLS +$STRIP --strip-unneeded $SOURCE -o $TARGET +cp $TARGET $TARGET2 diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegate.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegate.java new file mode 100644 index 0000000..207f396 --- /dev/null +++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegate.java @@ -0,0 +1,18 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.android_webview; + +import org.chromium.base.JNINamespace; +import org.chromium.chrome.browser.component.web_contents_delegate_android.WebContentsDelegateAndroid; + +/** + * WebView-specific WebContentsDelegate. + * This file is the Java version of the native class of the same name. + * It should contain empty WebContentsDelegate methods to be implemented by the embedder. + * These methods belong to WebView but are not shared with the Chromium Android port. + */ +@JNINamespace("android_webview") +public class AwWebContentsDelegate extends WebContentsDelegateAndroid { +} diff --git a/android_webview/lib/android_webview.gyp b/android_webview/lib/android_webview.gyp index 353e6bf..8cd34ee 100644 --- a/android_webview/lib/android_webview.gyp +++ b/android_webview/lib/android_webview.gyp @@ -13,9 +13,11 @@ '../../chrome/chrome.gyp:browser', '../../chrome/chrome.gyp:renderer', '../../content/content.gyp:content', + '../native/webview_native.gyp:webview_native', ], 'include_dirs': [ '../..', + '../../skia/config', ], 'sources': [ 'main/webview_entry_point.cc', @@ -24,6 +26,34 @@ 'main/webview_stubs.cc', ], }, + { + 'target_name': 'android_webview', + 'type' : 'none', + 'dependencies': [ + 'libwebview', + ], + 'variables': { + 'install_binary_script': '../build/install_binary', + }, + 'actions': [ + { + 'action_name': 'libwebview_strip_and_install_in_android', + 'inputs': [ + '<(SHARED_LIB_DIR)/libwebview.so', + ], + 'outputs': [ + '<(android_product_out)/obj/lib/libwebview.so', + '<(android_product_out)/system/lib/libwebview.so', + '<(android_product_out)/symbols/system/lib/libwebview.so', + ], + 'action': [ + '<(install_binary_script)', + '<@(_inputs)', + '<@(_outputs)', + ], + }, + ], + }, ], } diff --git a/android_webview/lib/main/webview_entry_point.cc b/android_webview/lib/main/webview_entry_point.cc index 04a52df..2053910 100644 --- a/android_webview/lib/main/webview_entry_point.cc +++ b/android_webview/lib/main/webview_entry_point.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "android_webview/lib/main/webview_main_delegate.h" +#include "android_webview/native/android_webview_jni_registrar.h" #include "base/android/jni_android.h" #include "content/public/app/android_library_loader_hooks.h" #include "content/public/app/content_main.h" @@ -12,9 +13,11 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { base::android::InitVM(vm); JNIEnv* env = base::android::AttachCurrentThread(); - if (!content::RegisterLibraryLoaderEntryHook(env)) { + if (!content::RegisterLibraryLoaderEntryHook(env)) + return -1; + + if (!android_webview::RegisterJni(env)) return -1; - } content::SetContentMainDelegate(new android_webview::WebViewMainDelegate()); diff --git a/android_webview/native/android_webview_jni_registrar.cc b/android_webview/native/android_webview_jni_registrar.cc new file mode 100644 index 0000000..eb13e11 --- /dev/null +++ b/android_webview/native/android_webview_jni_registrar.cc @@ -0,0 +1,17 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "android_webview/native/android_webview_jni_registrar.h" + +#include "base/android/jni_android.h" +#include "base/android/jni_registrar.h" +#include "chrome/browser/component/web_contents_delegate_android/component_jni_registrar.h" + +namespace android_webview { + +bool RegisterJni(JNIEnv* env) { + return web_contents_delegate_android::RegisterJni(env); +} + +} // namespace android_webview diff --git a/android_webview/native/android_webview_jni_registrar.h b/android_webview/native/android_webview_jni_registrar.h new file mode 100644 index 0000000..a1a3748 --- /dev/null +++ b/android_webview/native/android_webview_jni_registrar.h @@ -0,0 +1,17 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ANDROID_WEBVIEW_NATIVE_ANDROID_WEBVIEW_JNI_REGISTRAR_H_ +#define ANDROID_WEBVIEW_NATIVE_ANDROID_WEBVIEW_JNI_REGISTRAR_H_ + +#include <jni.h> + +namespace android_webview { + +// Register all JNI bindings necessary for chrome. +bool RegisterJni(JNIEnv* env); + +} // namespace android_webview + +#endif // ANDROID_WEBVIEW_NATIVE_ANDROID_WEBVIEW_JNI_REGISTRAR_H_ diff --git a/android_webview/native/aw_web_contents_delegate.cc b/android_webview/native/aw_web_contents_delegate.cc new file mode 100644 index 0000000..7302128 --- /dev/null +++ b/android_webview/native/aw_web_contents_delegate.cc @@ -0,0 +1,18 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "android_webview/native/aw_web_contents_delegate.h" + +namespace android_webview { + +AwWebContentsDelegate::AwWebContentsDelegate( + JNIEnv* env, + jobject obj) + : WebContentsDelegateAndroid(env, obj) { +} + +AwWebContentsDelegate::~AwWebContentsDelegate() { +} + +} // namespace android_webview diff --git a/android_webview/native/aw_web_contents_delegate.h b/android_webview/native/aw_web_contents_delegate.h new file mode 100644 index 0000000..add2052 --- /dev/null +++ b/android_webview/native/aw_web_contents_delegate.h @@ -0,0 +1,26 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ANDROID_WEBVIEW_NATIVE_AW_WEB_CONTENTS_DELEGATE_H_ +#define ANDROID_WEBVIEW_NATIVE_AW_WEB_CONTENTS_DELEGATE_H_ + +#include <jni.h> + +#include "chrome/browser/component/web_contents_delegate_android/web_contents_delegate_android.h" + +namespace android_webview { + +// WebView specific WebContentsDelegate. +// Should contain WebContentsDelegate code required by WebView that should not +// be part of the Chromium Android port. +class AwWebContentsDelegate + : public web_contents_delegate_android::WebContentsDelegateAndroid { + public: + AwWebContentsDelegate(JNIEnv* env, jobject obj); + virtual ~AwWebContentsDelegate(); +}; + +} // namespace android_webview + +#endif // ANDROID_WEBVIEW_NATIVE_AW_WEB_CONTENTS_DELEGATE_H_ diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp new file mode 100644 index 0000000..7b31a4a --- /dev/null +++ b/android_webview/native/webview_native.gyp @@ -0,0 +1,40 @@ +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +{ + 'variables': { + 'chromium_code': 1, + }, + 'targets': [ + { + 'target_name': 'webview_native', + 'type': 'static_library', + 'dependencies': [ + '../../base/base.gyp:base_static', + '../../chrome/browser/component/components.gyp:web_contents_delegate_android', + 'android_webview_native_jni', + ], + 'include_dirs': [ + '../..', + '../../skia/config', + '<(SHARED_INTERMEDIATE_DIR)/android_webview', + ], + 'sources': [ + 'android_webview_jni_registrar.cc', + 'android_webview_jni_registrar.h', + 'aw_web_contents_delegate.cc', + 'aw_web_contents_delegate.h', + ], + }, + { + 'target_name': 'android_webview_native_jni', + 'type': 'none', + 'sources': [ + ], + 'variables': { + 'jni_gen_dir': 'android_webview', + }, + 'includes': [ '../../build/jni_generator.gypi' ], + }, + ], +} |