summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authortorne@chromium.org <torne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 10:55:04 +0000
committertorne@chromium.org <torne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-09 10:55:04 +0000
commit878aa82566661246ed8e5b07087342a48e3261ae (patch)
tree5d7abb882bb3dfd9d2905747e95cc6597e3d096b /android_webview
parent220ea593af400386fb65c45b1dbbaceb037c87a6 (diff)
downloadchromium_src-878aa82566661246ed8e5b07087342a48e3261ae.zip
chromium_src-878aa82566661246ed8e5b07087342a48e3261ae.tar.gz
chromium_src-878aa82566661246ed8e5b07087342a48e3261ae.tar.bz2
Build target for Android WebView.
This creates a "libwebview" build target for the JNI code to power the Android WebView. This is unfinished and can't run without additional code that has not yet been upstreamed, but it compiles and links successfully. In its present state the WebViewMainDelegate reuses Chrome implementations of other content client interfaces. This is a temporary state of affairs until necessary refactorings can be performed. Review URL: https://chromiumcodereview.appspot.com/10825155 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150780 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/DEPS10
-rw-r--r--android_webview/OWNERS5
-rw-r--r--android_webview/lib/DEPS19
-rw-r--r--android_webview/lib/android_webview.gyp47
-rw-r--r--android_webview/lib/main/webview_entry_point.cc22
-rw-r--r--android_webview/lib/main/webview_main_delegate.cc77
-rw-r--r--android_webview/lib/main/webview_main_delegate.h45
-rw-r--r--android_webview/lib/main/webview_stubs.cc27
8 files changed, 252 insertions, 0 deletions
diff --git a/android_webview/DEPS b/android_webview/DEPS
new file mode 100644
index 0000000..ea141dc
--- /dev/null
+++ b/android_webview/DEPS
@@ -0,0 +1,10 @@
+# Please add joi@ or erikwright@ as reviewers for any changes to DEPS files
+# under android_webview/ as they are keeping track of what needs to become a
+# Browser Component.
+
+# Do not add any includes under chrome/ to this DEPS file. Code that depends on
+# chrome/ should go into android_webview/lib/ or be refactored.
+
+include_rules = [
+ "+content/public",
+]
diff --git a/android_webview/OWNERS b/android_webview/OWNERS
new file mode 100644
index 0000000..8e668f0
--- /dev/null
+++ b/android_webview/OWNERS
@@ -0,0 +1,5 @@
+# The set noparent is temporary until src/OWNERS isn't *.
+set noparent
+joth@chromium.org
+steveblock@chromium.org
+torne@chromium.org
diff --git a/android_webview/lib/DEPS b/android_webview/lib/DEPS
new file mode 100644
index 0000000..2dc7f40
--- /dev/null
+++ b/android_webview/lib/DEPS
@@ -0,0 +1,19 @@
+# Please add joi@ or erikwright@ as reviewers for any changes to DEPS files
+# under android_webview/ as they are keeping track of what needs to become a
+# Browser Component.
+
+include_rules = [
+ # Temporary until we implement our own versions of the *Client classes.
+ "!chrome/common/chrome_content_client.h",
+ "!chrome/browser/chrome_content_browser_client.h",
+ "!chrome/renderer/chrome_content_renderer_client.h",
+
+ # Temporary until services we use no longer depend on Chrome's path service.
+ "!chrome/common/chrome_paths.h",
+
+ # Temporary until TabAndroid is in a more suitable place.
+ "!chrome/browser/android/tab_android.h",
+
+ # Temporary until autofill becomes a browser component.
+ "!chrome/browser/autofill/autofill_external_delegate.h"
+]
diff --git a/android_webview/lib/android_webview.gyp b/android_webview/lib/android_webview.gyp
new file mode 100644
index 0000000..ceeedce
--- /dev/null
+++ b/android_webview/lib/android_webview.gyp
@@ -0,0 +1,47 @@
+# 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': [
+ {
+ # TODO(torne): This is vaguely based on the downstream android target
+ # "chromeview_core" and once that target has been upstreamed we should
+ # just depend on it instead.
+ 'target_name': 'webview_core',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../../chrome/chrome.gyp:browser',
+ '../../chrome/chrome.gyp:renderer',
+ '../../content/content.gyp:content',
+ ],
+ 'include_dirs': [
+ '../..',
+ ],
+ },
+ {
+ 'target_name': 'libwebview',
+ 'type': 'shared_library',
+ 'dependencies': [
+ 'webview_core',
+ ],
+ 'include_dirs': [
+ '../..',
+ ],
+ 'sources': [
+ 'main/webview_entry_point.cc',
+ 'main/webview_main_delegate.cc',
+ 'main/webview_main_delegate.h',
+ 'main/webview_stubs.cc',
+ ],
+ },
+ ],
+}
+
+# Local Variables:
+# tab-width:2
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/android_webview/lib/main/webview_entry_point.cc b/android_webview/lib/main/webview_entry_point.cc
new file mode 100644
index 0000000..04a52df
--- /dev/null
+++ b/android_webview/lib/main/webview_entry_point.cc
@@ -0,0 +1,22 @@
+// 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/lib/main/webview_main_delegate.h"
+#include "base/android/jni_android.h"
+#include "content/public/app/android_library_loader_hooks.h"
+#include "content/public/app/content_main.h"
+
+// This is called by the VM when the shared library is first loaded.
+// Most of the initialization is done in LibraryLoadedOnMainThread(), not here.
+JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+ base::android::InitVM(vm);
+ JNIEnv* env = base::android::AttachCurrentThread();
+ if (!content::RegisterLibraryLoaderEntryHook(env)) {
+ return -1;
+ }
+
+ content::SetContentMainDelegate(new android_webview::WebViewMainDelegate());
+
+ return JNI_VERSION_1_4;
+}
diff --git a/android_webview/lib/main/webview_main_delegate.cc b/android_webview/lib/main/webview_main_delegate.cc
new file mode 100644
index 0000000..9ff742a
--- /dev/null
+++ b/android_webview/lib/main/webview_main_delegate.cc
@@ -0,0 +1,77 @@
+// 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/lib/main/webview_main_delegate.h"
+
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "chrome/browser/chrome_content_browser_client.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/renderer/chrome_content_renderer_client.h"
+#include "content/public/browser/browser_main_runner.h"
+#include "content/public/common/content_client.h"
+
+namespace android_webview {
+
+base::LazyInstance<chrome::ChromeContentBrowserClient>
+ g_webview_content_browser_client = LAZY_INSTANCE_INITIALIZER;
+base::LazyInstance<chrome::ChromeContentRendererClient>
+ g_webview_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
+
+WebViewMainDelegate::WebViewMainDelegate() {
+}
+
+WebViewMainDelegate::~WebViewMainDelegate() {
+}
+
+bool WebViewMainDelegate::BasicStartupComplete(int* exit_code) {
+ content::SetContentClient(&chrome_content_client_);
+
+ return false;
+}
+
+void WebViewMainDelegate::PreSandboxStartup() {
+ chrome::RegisterPathProvider();
+
+ // TODO(torne): When we have a separate renderer process, we need to handle
+ // being passed open FDs for the resource paks here.
+}
+
+void WebViewMainDelegate::SandboxInitialized(const std::string& process_type) {
+ // TODO(torne): Adjust linux OOM score here.
+}
+
+int WebViewMainDelegate::RunProcess(
+ const std::string& process_type,
+ const content::MainFunctionParams& main_function_params) {
+ if (process_type.empty()) {
+ browser_runner_.reset(content::BrowserMainRunner::Create());
+ int exit_code = browser_runner_->Initialize(main_function_params);
+ DCHECK(exit_code < 0);
+
+ // Return 0 so that we do NOT trigger the default behavior. On Android, the
+ // UI message loop is managed by the Java application.
+ return 0;
+ }
+
+ return -1;
+}
+
+void WebViewMainDelegate::ProcessExiting(const std::string& process_type) {
+ // TODO(torne): Clean up resources when we handle them.
+
+ logging::CloseLogFile();
+}
+
+content::ContentBrowserClient*
+ WebViewMainDelegate::CreateContentBrowserClient() {
+ return &g_webview_content_browser_client.Get();
+}
+
+content::ContentRendererClient*
+ WebViewMainDelegate::CreateContentRendererClient() {
+ return &g_webview_content_renderer_client.Get();
+}
+
+} // namespace android_webview
diff --git a/android_webview/lib/main/webview_main_delegate.h b/android_webview/lib/main/webview_main_delegate.h
new file mode 100644
index 0000000..572ff0f
--- /dev/null
+++ b/android_webview/lib/main/webview_main_delegate.h
@@ -0,0 +1,45 @@
+// 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_LIB_MAIN_WEBVIEW_MAIN_DELEGATE_H_
+#define ANDROID_WEBVIEW_LIB_MAIN_WEBVIEW_MAIN_DELEGATE_H_
+
+#include "base/memory/scoped_ptr.h"
+#include "chrome/common/chrome_content_client.h"
+#include "content/public/app/content_main_delegate.h"
+
+namespace content {
+class BrowserMainRunner;
+}
+
+namespace android_webview {
+
+// Android WebView implementation of ContentMainDelegate.
+class WebViewMainDelegate : public content::ContentMainDelegate {
+ public:
+ WebViewMainDelegate();
+ virtual ~WebViewMainDelegate();
+
+ private:
+ // content::ContentMainDelegate implementation:
+ virtual bool BasicStartupComplete(int* exit_code) OVERRIDE;
+ virtual void PreSandboxStartup() OVERRIDE;
+ virtual void SandboxInitialized(const std::string& process_type) OVERRIDE;
+ virtual int RunProcess(
+ const std::string& process_type,
+ const content::MainFunctionParams& main_function_params) OVERRIDE;
+ virtual void ProcessExiting(const std::string& process_type) OVERRIDE;
+ virtual content::ContentBrowserClient* CreateContentBrowserClient() OVERRIDE;
+ virtual content::ContentRendererClient*
+ CreateContentRendererClient() OVERRIDE;
+
+ scoped_ptr<content::BrowserMainRunner> browser_runner_;
+ chrome::ChromeContentClient chrome_content_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebViewMainDelegate);
+};
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_LIB_MAIN_WEBVIEW_MAIN_DELEGATE_H_
diff --git a/android_webview/lib/main/webview_stubs.cc b/android_webview/lib/main/webview_stubs.cc
new file mode 100644
index 0000000..abdd156
--- /dev/null
+++ b/android_webview/lib/main/webview_stubs.cc
@@ -0,0 +1,27 @@
+// 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 "chrome/browser/android/tab_android.h"
+#include "chrome/browser/autofill/autofill_external_delegate.h"
+
+// This file contains temporary stubs to allow the libwebview target to compile.
+// They will be removed once real implementations are written/upstreamed, or
+// once other code is refactored to eliminate the need for them.
+
+// static
+TabAndroid* TabAndroid::FromWebContents(content::WebContents* web_contents) {
+ // We don't need to return a real TabAndroid object yet.
+ // Eventually, WebView will need its own TabAndroid implementation.
+ return NULL;
+}
+
+// static
+AutofillExternalDelegate* AutofillExternalDelegate::Create(
+ TabContents* tab_contents,
+ AutofillManager* manager) {
+ // We don't need to return a real AutofillExternalDelegate yet.
+ // Eventually, WebView will need an implementation (probably shared with
+ // Chrome).
+ return NULL;
+}