Commit 03486023 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

[WebLayer] Refactor WebLayer native init

This pulls out some changes from http://crrev.com/c/1783727 that are
needed to make the WebLayer lib work when used with monochrome.

Change-Id: Ia749d0b9c7efdfd5906a684346cce30ad9b2c7b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1788236Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694369}
parent 9e78690d
......@@ -135,6 +135,8 @@ jumbo_static_library("weblayer_lib") {
"//weblayer/browser/java:jni",
]
sources += [
"app/jni_onload.cc",
"app/jni_onload.h",
"browser/browser_observer_proxy.cc",
"browser/browser_observer_proxy.h",
]
......@@ -160,7 +162,7 @@ jumbo_static_library("weblayer_lib") {
if (is_android) {
shared_library("libweblayer") {
sources = [
"app/jni_onload.cc",
"app/entry_point.cc",
]
deps = [
":weblayer_lib",
......
include_rules = [
"+components/version_info",
"+content/public",
"+sandbox",
"+ui/base",
......
// Copyright 2019 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 "base/android/jni_android.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "weblayer/app/jni_onload.h"
namespace {
bool NativeInit(base::android::LibraryProcessType) {
return weblayer::OnJNIOnLoadInit();
}
} // namespace
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
base::android::InitVM(vm);
base::android::SetNativeInitializationHook(&NativeInit);
return JNI_VERSION_1_4;
}
......@@ -2,31 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/android/jni_android.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/logging.h"
#include "components/version_info/version_info_values.h"
#include "content/public/app/content_jni_onload.h"
#include "content/public/app/content_main.h"
#include "weblayer/app/content_main_delegate_impl.h"
namespace weblayer {
class MainDelegateImpl : public MainDelegate {
public:
void PreMainMessageLoopRun() override {}
void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) override {}
};
} // namespace weblayer
// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
base::android::InitVM(vm);
bool OnJNIOnLoadInit() {
if (!content::android::OnJNIOnLoadInit())
return -1;
return false;
weblayer::MainParams params;
params.delegate = new weblayer::MainDelegateImpl;
params.pak_name = "weblayer_support.pak";
params.brand = "WebLayer";
base::android::SetVersionNumber(PRODUCT_VERSION);
content::SetContentMainDelegate(
new weblayer::ContentMainDelegateImpl(params));
return JNI_VERSION_1_4;
return true;
}
} // namespace weblayer
// Copyright 2019 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 WEBLAYER_APP_JNI_ONLOAD_H_
#define WEBLAYER_APP_JNI_ONLOAD_H_
namespace weblayer {
bool OnJNIOnLoadInit();
} // namespace weblayer
#endif // WEBLAYER_APP_JNI_ONLOAD_H_
......@@ -108,6 +108,12 @@ android_apk("weblayer_support_apk") {
min_sdk_version = 21
target_sdk_version = 28
android_manifest_dep = ":weblayer_support_manifest"
native_lib_version_rule = "//build/util:chrome_version_json"
_native_lib_file =
rebase_path("$root_gen_dir/CHROME_VERSION.json", root_build_dir)
native_lib_version_arg = "@FileArg($_native_lib_file:full-quoted)"
shared_libraries = [ "//weblayer:libweblayer" ]
}
......
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