Commit b5e25b58 authored by sky's avatar sky Committed by Commit bot

Gets packaging of html_viewer for android working

BUG=none
TEST=none
R=jamesr@chromium.org, qsr@chromium.org

Review URL: https://codereview.chromium.org/1002033004

Cr-Commit-Position: refs/heads/master@{#320726}
parent 0588281c
......@@ -110,13 +110,65 @@ source_set("lib") {
]
}
mojo_native_application("html_viewer") {
sources = [
"html_viewer.cc",
]
deps = [
":lib",
]
if (is_android) {
import("//build/config/android/rules.gni")
java_library_path = "$target_out_dir/java_library.dex.jar"
mojo_android_application("html_viewer") {
input_so = "$root_out_dir/lib.stripped/libhtml_viewer_lib.so"
input_dex_jar = java_library_path
}
shared_library("html_viewer_lib") {
sources = [
"android/android_hooks.cc",
"html_viewer.cc",
]
deps = [
":html_viewer_jni_headers",
":lib",
"//base",
"//ui/gfx:gfx_jni_headers",
]
}
generate_jni("html_viewer_jni_headers") {
sources = [
"android/java/org/chromium/html_viewer/Main.java",
]
jni_package = "mojo/services/html_viewer"
}
android_library("html_viewer_java_classes") {
java_files = [ "android/java/org/chromium/html_viewer/Main.java" ]
deps = [
"//base:base_java",
]
}
android_standalone_library("java_library") {
dex_path = java_library_path
deps = [
":html_viewer_java_classes",
# TODO(sky): this is WAY more than we need. We really only need
# DeviceDisplayInfo. Refactor to make this clearer.
"//ui/android:ui_java",
]
}
} else {
mojo_native_application("html_viewer") {
sources = [
"html_viewer.cc",
]
deps = [
":lib",
]
}
}
test("tests") {
......
// Copyright 2015 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 <vector>
#include "base/android/base_jni_onload.h"
#include "base/android/jni_android.h"
#include "base/android/library_loader/library_loader_hooks.h"
#include "base/bind.h"
#include "mojo/services/html_viewer/jni/Main_jni.h"
namespace {
bool RegisterJNI(JNIEnv* env) {
return true;
}
bool Init() {
Java_Main_init(base::android::AttachCurrentThread());
return true;
}
} // namespace
// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
std::vector<base::android::RegisterCallback> register_callbacks;
register_callbacks.push_back(base::Bind(&RegisterJNI));
register_callbacks.push_back(base::Bind(&RegisterNativesImpl));
std::vector<base::android::InitCallback> init_callbacks;
init_callbacks.push_back(base::Bind(&Init));
if (!base::android::OnJNIOnLoadRegisterJNI(vm, register_callbacks) ||
!base::android::OnJNIOnLoadInit(init_callbacks)) {
return -1;
}
// There cannot be two AtExitManagers at the same time. Remove the one from
// LibraryLoader as ApplicationRunnerChromium also uses one.
base::android::LibraryLoaderExitHook();
return JNI_VERSION_1_4;
}
extern "C" JNI_EXPORT void InitApplicationContext(
const base::android::JavaRef<jobject>& context) {
JNIEnv* env = base::android::AttachCurrentThread();
base::android::InitApplicationContext(env, context);
}
// Copyright 2015 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.html_viewer;
import org.chromium.base.CalledByNative;
import org.chromium.base.PathUtils;
/**
* This class does setup for html_viewer.
*/
public final class Main {
private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "html_viewer";
private Main() {}
@SuppressWarnings("unused")
@CalledByNative
private static void init() {
PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
}
}
......@@ -170,6 +170,7 @@ class HTMLViewer : public mojo::ApplicationDelegate,
void Initialize(mojo::ApplicationImpl* app) override {
blink_platform_.reset(new MojoBlinkPlatformImpl(app));
#if defined(V8_USE_EXTERNAL_STARTUP_DATA)
// Note: this requires file system access.
gin::IsolateHolder::LoadV8Snapshot();
#endif
blink::initialize(blink_platform_.get());
......@@ -199,6 +200,8 @@ class HTMLViewer : public mojo::ApplicationDelegate,
is_headless_ = command_line->HasSwitch(kIsHeadless);
if (!is_headless_) {
// TODO(sky): consider putting this into the .so so that we don't need
// file system access.
base::FilePath ui_test_pak_path;
CHECK(PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
......
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