Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java

Issue 1888773004: 🙅 Bind a WebAPK to its "host" browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
diff --git a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
index 1aa246c58a56ddb9bcd7ba7b6656f71a7408cf70..753f3d200413e7500a4940d99830b65eb0661e45 100644
--- a/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
+++ b/base/android/java/src/org/chromium/base/library_loader/LibraryLoader.java
@@ -6,10 +6,8 @@ package org.chromium.base.library_loader;
import android.annotation.TargetApi;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.os.AsyncTask;
import android.os.Build;
import android.os.SystemClock;
@@ -21,7 +19,7 @@ import org.chromium.base.TraceEvent;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.metrics.RecordHistogram;
-import org.chromium.minting.lib.common.WebAPKConstants;
+import org.chromium.minting.lib.common.WebAPKUtils;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -272,29 +270,10 @@ public class LibraryLoader {
String zipFilePath = null;
String libFilePath = System.mapLibraryName(library);
if (Linker.isInZipFile()) {
- SharedPreferences prefs = context.getSharedPreferences(
- WebAPKConstants.MINT_PREFS, Context.MODE_PRIVATE);
- String packageString = prefs.getString(
- WebAPKConstants.HOST_PACKAGE_PREF,
- WebAPKConstants.DEFAULT_HOST_PACKAGE_NAME);
- Context remoteContext = context;
- if (mLibraryProcessType == LibraryProcessType.PROCESS_WEBAPK_CHILD) {
- try {
- // Construct the context of the WebAPK host, which has native
- // libraries that the WebAPK.
- Log.w(TAG, "package name from context: %s",
- context.getPackageName());
- remoteContext =
- context.getApplicationContext().createPackageContext(
- packageString,
- Context.CONTEXT_IGNORE_SECURITY
- | Context.CONTEXT_INCLUDE_CODE);
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- }
- }
+ Context contextForApk = (mLibraryProcessType == LibraryProcessType.PROCESS_WEBAPK_CHILD)
+ ? WebAPKUtils.getHostBrowserContext(context) : context;
// Load directly from the APK.
- zipFilePath = getLibraryApkPath(remoteContext);
+ zipFilePath = getLibraryApkPath(contextForApk);
Log.i(TAG, "Loading " + library + " from within " + zipFilePath);
} else {
// The library is in its own file.

Powered by Google App Engine
This is Rietveld 408576698