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

Unified Diff: android_webview/test/shell/src/org/chromium/android_webview/test/SecondBrowserProcess.java

Issue 1555513003: [Android WebView] Forbid launching of two browser processes in the app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments addressed Created 5 years 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
« no previous file with comments | « android_webview/test/shell/AndroidManifest.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/test/shell/src/org/chromium/android_webview/test/SecondBrowserProcess.java
diff --git a/android_webview/test/shell/src/org/chromium/android_webview/test/SecondBrowserProcess.java b/android_webview/test/shell/src/org/chromium/android_webview/test/SecondBrowserProcess.java
new file mode 100644
index 0000000000000000000000000000000000000000..14c19e521c3e286e3e73a07ddc0560358eca36fb
--- /dev/null
+++ b/android_webview/test/shell/src/org/chromium/android_webview/test/SecondBrowserProcess.java
@@ -0,0 +1,62 @@
+// 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.android_webview.test;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.Binder;
+import android.os.IBinder;
+import android.os.Parcel;
+import android.os.Process;
+
+import org.chromium.android_webview.AwBrowserProcess;
+import org.chromium.android_webview.AwResource;
+import org.chromium.android_webview.shell.R;
+import org.chromium.base.CommandLine;
+import org.chromium.base.annotations.SuppressFBWarnings;
+
+/**
+ * This is a service for imitating a second browser process in the application.
+ */
+public class SecondBrowserProcess extends Service {
+ public static final int CODE_START = IBinder.FIRST_CALL_TRANSACTION;
+
+ private IBinder mBinder = new Binder() {
+ @Override
+ protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) {
+ switch (code) {
+ case CODE_START:
+ reply.writeNoException();
+ try {
+ startBrowserProcess();
+ reply.writeInt(Process.myPid());
+ } catch (Exception e) {
+ reply.writeInt(0);
+ }
+ return true;
+ }
+ return false;
+ }
+ };
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ return START_STICKY;
+ }
+
+ @SuppressFBWarnings("DMI_HARDCODED_ABSOLUTE_FILENAME")
+ private void startBrowserProcess() throws Exception {
+ CommandLine.initFromFile("/data/local/tmp/android-webview-command-line");
+ AwResource.setResources(this.getResources());
+ AwResource.setConfigKeySystemUuidMapping(R.array.config_key_system_uuid_mapping);
+ AwBrowserProcess.loadLibrary(this);
+ AwBrowserProcess.start(this);
+ }
+}
« no previous file with comments | « android_webview/test/shell/AndroidManifest.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698