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

Side by Side Diff: remoting/android/java/src/org/chromium/chromoting/jni/JniInterface.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.chromoting.jni; 5 package org.chromium.chromoting.jni;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Point; 9 import android.graphics.Point;
10 import android.os.Looper; 10 import android.os.Looper;
11 11
12 import org.chromium.base.ContextUtils;
12 import org.chromium.base.Log; 13 import org.chromium.base.Log;
13 import org.chromium.base.annotations.CalledByNative; 14 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 15 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.chromoting.CapabilityManager; 16 import org.chromium.chromoting.CapabilityManager;
16 import org.chromium.chromoting.R; 17 import org.chromium.chromoting.R;
17 import org.chromium.chromoting.SessionAuthenticator; 18 import org.chromium.chromoting.SessionAuthenticator;
18 19
19 import java.nio.ByteBuffer; 20 import java.nio.ByteBuffer;
20 import java.nio.ByteOrder; 21 import java.nio.ByteOrder;
21 22
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 /** Bitmap holding the cursor shape. Accessed on the graphics thread. */ 138 /** Bitmap holding the cursor shape. Accessed on the graphics thread. */
138 private static Bitmap sCursorBitmap = null; 139 private static Bitmap sCursorBitmap = null;
139 140
140 /** Capability Manager through which capabilities and extensions are handled . */ 141 /** Capability Manager through which capabilities and extensions are handled . */
141 private static CapabilityManager sCapabilityManager = CapabilityManager.getI nstance(); 142 private static CapabilityManager sCapabilityManager = CapabilityManager.getI nstance();
142 143
143 /** 144 /**
144 * To be called once from the main Activity. Any subsequent calls will updat e the application 145 * To be called once from the main Activity. Any subsequent calls will updat e the application
145 * context, but not reload the library. This is useful e.g. when the activit y is closed and the 146 * context, but not reload the library. This is useful e.g. when the activit y is closed and the
146 * user later wants to return to the application. Called on the UI thread. 147 * user later wants to return to the application. Called on the UI thread.
148 * THIS IS SKETCHY: the code doesn't update the app context, and the comment doesn't make sense.
Torne 2015/11/06 16:51:34 remoting folks: the comment here isn't consistent
Lambros 2015/11/06 19:46:03 The comment seems to be outdated, probably all the
147 */ 149 */
148 public static void loadLibrary(Context context) { 150 public static void loadLibrary(Context context) {
149 if (sLoaded) return; 151 if (sLoaded) return;
150 152
151 System.loadLibrary("remoting_client_jni"); 153 System.loadLibrary("remoting_client_jni");
152 154
153 nativeLoadNative(context); 155 ContextUtils.initApplicationContext(context);
156 nativeLoadNative();
154 sLoaded = true; 157 sLoaded = true;
155 } 158 }
156 159
157 /** Performs the native portion of the initialization. */ 160 /** Performs the native portion of the initialization. */
158 private static native void nativeLoadNative(Context context); 161 private static native void nativeLoadNative();
159 162
160 /* 163 /*
161 * API/OAuth2 keys access. 164 * API/OAuth2 keys access.
162 */ 165 */
163 public static native String nativeGetApiKey(); 166 public static native String nativeGetApiKey();
164 public static native String nativeGetClientId(); 167 public static native String nativeGetClientId();
165 public static native String nativeGetClientSecret(); 168 public static native String nativeGetClientSecret();
166 169
167 /** Returns whether the client is connected. */ 170 /** Returns whether the client is connected. */
168 public static boolean isConnected() { 171 public static boolean isConnected() {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 public static void sendExtensionMessage(String type, String data) { 486 public static void sendExtensionMessage(String type, String data) {
484 if (!sConnected) { 487 if (!sConnected) {
485 return; 488 return;
486 } 489 }
487 490
488 nativeSendExtensionMessage(type, data); 491 nativeSendExtensionMessage(type, data);
489 } 492 }
490 493
491 private static native void nativeSendExtensionMessage(String type, String da ta); 494 private static native void nativeSendExtensionMessage(String type, String da ta);
492 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698