Commit 83a14a3c authored by Robbie McElrath's avatar Robbie McElrath Committed by Commit Bot

[AW] Move //aw/apk java files to org.chromium.android_webview.app

This moves classes in //aw/apk from com.android.webview.chromium to
org.chromium.android_webview.app to match the rest of the chromium
webview implementation.

Test: Manually verified that licenses still show in Settings >
Test: System > About > Legal information > System WebView licenses
Bug: 934152
Change-Id: Idebcaf4ea9cd604d644f8cab1d957cf918a669e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1881320Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Commit-Queue: Robbie McElrath <rmcelrath@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713137}
parent c7710896
......@@ -8,7 +8,7 @@ import("//build/config/android/rules.gni")
generate_jni("apk_jni_headers") {
sources = [
"java/src/com/android/webview/chromium/WebViewApkApplication.java",
"java/src/org/chromium/android_webview/app/WebViewApkApplication.java",
]
}
......@@ -16,9 +16,10 @@ generate_jni("apk_jni_headers") {
# as a library.
android_library("apk_java") {
java_files = [
"java/src/com/android/webview/chromium/LicenseActivity.java",
"java/src/com/android/webview/chromium/LicenseContentProvider.java",
"java/src/com/android/webview/chromium/WebViewApkApplication.java",
"java/src/org/chromium/android_webview/app/LicenseActivity.java",
"java/src/org/chromium/android_webview/app/LicenseContentProvider.java",
"java/src/org/chromium/android_webview/app/WebViewApkApplication.java",
]
deps = [
":devui_java",
......
......@@ -20,7 +20,7 @@
<application android:label="{{ application_label|default('Android System WebView') }}"
android:icon="@{{manifest_package|default('com.android.webview')}}:drawable/icon_webview"
android:name="{{ application_name|default('com.android.webview.chromium.WebViewApkApplication') }}"
android:name="{{ application_name|default('org.chromium.android_webview.app.WebViewApkApplication') }}"
android:multiArch="true"
{{ use32bitAbi|default('android:use32bitAbi="true"') }}
android:extractNativeLibs="{{ trichrome_library is not defined }}">
......@@ -49,7 +49,7 @@
</activity>
<!-- End of WebView Developer UI Activties -->
<activity android:name="com.android.webview.chromium.LicenseActivity"
<activity android:name="org.chromium.android_webview.app.LicenseActivity"
android:label="@string/license_activity_title"
android:process=":webview_apk"> {# Explicit process required for monochrome compatibility. #}
<intent-filter>
......@@ -59,7 +59,7 @@
<meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
android:value="true" />
</activity>
<provider android:name="com.android.webview.chromium.LicenseContentProvider"
<provider android:name="org.chromium.android_webview.app.LicenseContentProvider"
android:exported="true"
android:authorities="{{ manifest_package }}.LicenseContentProvider"
android:process=":webview_apk" /> {# Explicit process required for monochrome compatibility. #}
......
......@@ -4,87 +4,5 @@
package com.android.webview.chromium;
import android.app.Application;
import android.content.Context;
import org.chromium.android_webview.AwLocaleConfig;
import org.chromium.android_webview.common.CommandLineUtil;
import org.chromium.base.ContextUtils;
import org.chromium.base.PathUtils;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.components.embedder_support.application.FontPreloadingWorkaround;
import org.chromium.ui.base.ResourceBundle;
/**
* Application subclass for SystemWebView and Trichrome.
*
* Application subclass is used by renderer processes, services, and content providers that run
* under the WebView APK's package.
*
* None of this code runs in an application which simply uses WebView.
*/
@JNINamespace("android_webview")
public class WebViewApkApplication extends Application {
// Called by the framework for ALL processes. Runs before ContentProviders are created.
// Quirk: context.getApplicationContext() returns null during this method.
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
ContextUtils.initApplicationContext(this);
maybeInitProcessGlobals();
// MonochromeApplication has its own locale configuration already, so call this here
// rather than in maybeInitProcessGlobals.
ResourceBundle.setAvailablePakLocales(
new String[] {}, AwLocaleConfig.getWebViewSupportedPakLocales());
}
@Override
public void onCreate() {
super.onCreate();
FontPreloadingWorkaround.maybeInstallWorkaround(this);
}
/**
* Initializes globals needed for components that run in the "webview_apk" or "webview_service"
* process.
*
* This is also called by MonochromeApplication, so the initialization here will run
* for those processes regardless of whether the WebView is standalone or Monochrome.
*/
public static void maybeInitProcessGlobals() {
// Either "webview_service", or "webview_apk".
// "webview_service" is meant to be very light-weight and never load the native library.
if (ContextUtils.getProcessName().contains(":webview_")) {
PathUtils.setPrivateDataDirectorySuffix("webview", "WebView");
CommandLineUtil.initCommandLine();
}
}
/**
* Performs minimal native library initialization required when running as a stand-alone APK.
* @return True if the library was loaded, false if running as webview stub.
*/
static synchronized boolean initializeNative() {
try {
if (LibraryLoader.getInstance().isInitialized()) {
return true;
}
LibraryLoader.getInstance().loadNow();
} catch (Throwable unused) {
// Happens for WebView Stub. Throws NoClassDefFoundError because of no
// NativeLibraries.java being generated.
return false;
}
LibraryLoader.getInstance().switchCommandLineForWebView();
WebViewApkApplicationJni.get().initializePakResources();
return true;
}
@NativeMethods
interface Natives {
void initializePakResources();
}
}
// TODO(crbug.com/934152): Delete this once Clank points to the new WebViewApkApplication package.
public class WebViewApkApplication extends org.chromium.android_webview.app.WebViewApkApplication {}
......@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package com.android.webview.chromium;
package org.chromium.android_webview.app;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import org.chromium.base.Log;
/**
* Activity for displaying WebView OSS licenses.
......@@ -17,6 +18,8 @@ import android.util.Log;
* other than LicenseContentProvider.
*/
public class LicenseActivity extends Activity {
private static final String TAG = "WebView";
private static final String LICENSES_URI_SUFFIX = "LicenseContentProvider/webview_licenses";
private static final String LICENSES_CONTENT_TYPE = "text/html";
......@@ -42,7 +45,7 @@ public class LicenseActivity extends Activity {
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e("WebView", "Failed to find viewer", e);
Log.e(TAG, "Failed to find viewer", e);
}
finish();
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package com.android.webview.chromium;
package org.chromium.android_webview.app;
import android.annotation.TargetApi;
import android.content.ContentProvider;
......
// Copyright 2018 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.app;
import android.app.Application;
import android.content.Context;
import org.chromium.android_webview.AwLocaleConfig;
import org.chromium.android_webview.common.CommandLineUtil;
import org.chromium.base.ContextUtils;
import org.chromium.base.PathUtils;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.components.embedder_support.application.FontPreloadingWorkaround;
import org.chromium.ui.base.ResourceBundle;
/**
* Application subclass for SystemWebView and Trichrome.
*
* Application subclass is used by renderer processes, services, and content providers that run
* under the WebView APK's package.
*
* None of this code runs in an application which simply uses WebView.
*/
@JNINamespace("android_webview")
public class WebViewApkApplication extends Application {
// Called by the framework for ALL processes. Runs before ContentProviders are created.
// Quirk: context.getApplicationContext() returns null during this method.
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(context);
ContextUtils.initApplicationContext(this);
maybeInitProcessGlobals();
// MonochromeApplication has its own locale configuration already, so call this here
// rather than in maybeInitProcessGlobals.
ResourceBundle.setAvailablePakLocales(
new String[] {}, AwLocaleConfig.getWebViewSupportedPakLocales());
}
@Override
public void onCreate() {
super.onCreate();
FontPreloadingWorkaround.maybeInstallWorkaround(this);
}
/**
* Initializes globals needed for components that run in the "webview_apk" or "webview_service"
* process.
*
* This is also called by MonochromeApplication, so the initialization here will run
* for those processes regardless of whether the WebView is standalone or Monochrome.
*/
public static void maybeInitProcessGlobals() {
// Either "webview_service", or "webview_apk".
// "webview_service" is meant to be very light-weight and never load the native library.
if (ContextUtils.getProcessName().contains(":webview_")) {
PathUtils.setPrivateDataDirectorySuffix("webview", "WebView");
CommandLineUtil.initCommandLine();
}
}
/**
* Performs minimal native library initialization required when running as a stand-alone APK.
* @return True if the library was loaded, false if running as webview stub.
*/
static synchronized boolean initializeNative() {
try {
if (LibraryLoader.getInstance().isInitialized()) {
return true;
}
LibraryLoader.getInstance().loadNow();
} catch (Throwable unused) {
// Happens for WebView Stub. Throws NoClassDefFoundError because of no
// NativeLibraries.java being generated.
return false;
}
LibraryLoader.getInstance().switchCommandLineForWebView();
WebViewApkApplicationJni.get().initializePakResources();
return true;
}
@NativeMethods
interface Natives {
void initializePakResources();
}
}
......@@ -40,7 +40,7 @@ include_rules = [
specific_include_rules = {
# Special-case where monochrome composes chrome+webview
"MonochromeApplication\.java": [
"+android_webview/apk/java/src/com/android/webview/chromium/WebViewApkApplication.java",
"+android_webview/apk/java/src/org/chromium/android_webview/app/WebViewApkApplication.java",
"+android_webview/glue/java/src/com/android/webview/chromium/MonochromeLibraryPreloader.java",
]
}
......@@ -996,7 +996,7 @@
</activity>
<activity
android:label="@string/license_activity_title"
android:name="com.android.webview.chromium.LicenseActivity"
android:name="org.chromium.android_webview.app.LicenseActivity"
android:process=":webview_apk">
<intent-filter>
<action android:name="android.settings.WEBVIEW_LICENSE"/>
......@@ -1318,7 +1318,7 @@
<provider
android:authorities="org.chromium.chrome.LicenseContentProvider"
android:exported="true"
android:name="com.android.webview.chromium.LicenseContentProvider"
android:name="org.chromium.android_webview.app.LicenseContentProvider"
android:process=":webview_apk"/>
<receiver
android:exported="false"
......
......@@ -7,8 +7,8 @@ package org.chromium.chrome.browser;
import android.content.Context;
import com.android.webview.chromium.MonochromeLibraryPreloader;
import com.android.webview.chromium.WebViewApkApplication;
import org.chromium.android_webview.app.WebViewApkApplication;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.LibraryProcessType;
import org.chromium.content_public.browser.ChildProcessCreationParams;
......
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