| OLD | NEW |
| 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 | 8 |
| 9 import org.chromium.base.ContextUtils; | 9 import org.chromium.base.ContextUtils; |
| 10 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 sLoggerTokenConsumer = new OAuthTokenConsumer(context.getApplicationCont
ext(), TOKEN_SCOPE); | 38 sLoggerTokenConsumer = new OAuthTokenConsumer(context.getApplicationCont
ext(), TOKEN_SCOPE); |
| 39 System.loadLibrary("remoting_client_jni"); | 39 System.loadLibrary("remoting_client_jni"); |
| 40 ContextUtils.initApplicationContextForNative(); | 40 ContextUtils.initApplicationContextForNative(); |
| 41 nativeLoadNative(); | 41 nativeLoadNative(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 public static void setAccountForLogging(String account) { | 44 public static void setAccountForLogging(String account) { |
| 45 sAccount = account; | 45 sAccount = account; |
| 46 } | 46 } |
| 47 | 47 |
| 48 public static void useOpenGlRenderer(boolean useOpenGl) { |
| 49 nativeUseOpenGlRenderer(useOpenGl); |
| 50 } |
| 51 |
| 48 @CalledByNative | 52 @CalledByNative |
| 49 private static void fetchAuthToken() { | 53 private static void fetchAuthToken() { |
| 50 if (sAccount == null) { | 54 if (sAccount == null) { |
| 51 throw new IllegalStateException("Account is not set before fetching
the auth token."); | 55 throw new IllegalStateException("Account is not set before fetching
the auth token."); |
| 52 } | 56 } |
| 53 sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback()
{ | 57 sLoggerTokenConsumer.consume(sAccount, new OAuthTokenFetcher.Callback()
{ |
| 54 @Override | 58 @Override |
| 55 public void onTokenFetched(String token) { | 59 public void onTokenFetched(String token) { |
| 56 nativeOnAuthTokenFetched(token); | 60 nativeOnAuthTokenFetched(token); |
| 57 } | 61 } |
| 58 | 62 |
| 59 @Override | 63 @Override |
| 60 public void onError(OAuthTokenFetcher.Error error) { | 64 public void onError(OAuthTokenFetcher.Error error) { |
| 61 Log.e(TAG, "Failed to fetch auth token for native client."); | 65 Log.e(TAG, "Failed to fetch auth token for native client."); |
| 62 } | 66 } |
| 63 }); | 67 }); |
| 64 } | 68 } |
| 65 | 69 |
| 66 /** Performs the native portion of the initialization. */ | 70 /** Performs the native portion of the initialization. */ |
| 67 private static native void nativeLoadNative(); | 71 private static native void nativeLoadNative(); |
| 68 | 72 |
| 69 /** Notifies the native client with the new auth token */ | 73 /** Notifies the native client with the new auth token */ |
| 70 private static native void nativeOnAuthTokenFetched(String token); | 74 private static native void nativeOnAuthTokenFetched(String token); |
| 75 |
| 76 private static native void nativeUseOpenGlRenderer(boolean useOpenGl); |
| 71 } | 77 } |
| OLD | NEW |