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

Side by Side Diff: mojo/runner/android/apk/src/org/chromium/mojo/shell/ShellMain.java

Issue 1407233017: Define a Java-side global application context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.mojo.shell; 5 package org.chromium.mojo.shell;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.pm.ApplicationInfo; 9 import android.content.pm.ApplicationInfo;
10 import android.content.pm.PackageManager; 10 import android.content.pm.PackageManager;
11 import android.os.Bundle; 11 import android.os.Bundle;
12 import android.util.Log; 12 import android.util.Log;
13 13
14 import org.chromium.base.ContextUtils;
14 import org.chromium.base.annotations.CalledByNative; 15 import org.chromium.base.annotations.CalledByNative;
15 import org.chromium.base.annotations.JNINamespace; 16 import org.chromium.base.annotations.JNINamespace;
16 17
17 import java.io.File; 18 import java.io.File;
18 import java.util.ArrayList; 19 import java.util.ArrayList;
19 import java.util.Arrays; 20 import java.util.Arrays;
20 import java.util.List; 21 import java.util.List;
21 22
22 /** 23 /**
23 * A placeholder class to call native functions. 24 * A placeholder class to call native functions.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 FileHelper.createTimestampIfNecessary(timestamp); 57 FileHelper.createTimestampIfNecessary(timestamp);
57 File mojoShell = 58 File mojoShell =
58 new File(applicationContext.getApplicationInfo().nativeLibra ryDir, mojo_lib); 59 new File(applicationContext.getApplicationInfo().nativeLibra ryDir, mojo_lib);
59 60
60 List<String> parametersList = new ArrayList<String>(); 61 List<String> parametersList = new ArrayList<String>();
61 // Program name. 62 // Program name.
62 if (parameters != null) { 63 if (parameters != null) {
63 parametersList.addAll(Arrays.asList(parameters)); 64 parametersList.addAll(Arrays.asList(parameters));
64 } 65 }
65 66
67 ContextUtils.initApplicationContext(applicationContext);
68 // THIS IS SKETCHY: nativeInit treats applicationContext as an Activ ity!
Torne 2015/11/06 16:43:19 Mojo folks: The variable on this side is called "a
qsr 2015/11/13 14:36:06 Yes, this code is wrong. This code has been forked
66 nativeInit(applicationContext, mojoShell.getAbsolutePath(), 69 nativeInit(applicationContext, mojoShell.getAbsolutePath(),
67 parametersList.toArray(new String[parametersList.size()]), 70 parametersList.toArray(new String[parametersList.size()]),
68 cachedAppsDir.getAbsolutePath(), 71 cachedAppsDir.getAbsolutePath(),
69 getTmpDir(applicationContext).getAbsolutePath()); 72 getTmpDir(applicationContext).getAbsolutePath());
70 sInitialized = true; 73 sInitialized = true;
71 } catch (Exception e) { 74 } catch (Exception e) {
72 Log.e(TAG, "ShellMain initialization failed.", e); 75 Log.e(TAG, "ShellMain initialization failed.", e);
73 throw new RuntimeException(e); 76 throw new RuntimeException(e);
74 } 77 }
75 } 78 }
(...skipping 28 matching lines...) Expand all
104 /** 107 /**
105 * Initializes the native system. This API should be called only once per pr ocess. 108 * Initializes the native system. This API should be called only once per pr ocess.
106 **/ 109 **/
107 private static native void nativeInit(Context context, String mojoShellPath, 110 private static native void nativeInit(Context context, String mojoShellPath,
108 String[] parameters, String cachedAppsDirectory, String tmpDir); 111 String[] parameters, String cachedAppsDirectory, String tmpDir);
109 112
110 private static native void nativeStart(); 113 private static native void nativeStart();
111 114
112 private static native void nativeAddApplicationURL(String url); 115 private static native void nativeAddApplicationURL(String url);
113 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698