use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class AndroidNetworkLibrary method storeCertificate.
/**
* Adds a cryptographic file (User certificate, a CA certificate or
* PKCS#12 keychain) through the system's CertInstaller activity.
*
* @param context: current application context.
* @param cert_type: cryptographic file type. E.g. CertificateMimeType.X509_USER_CERT
* @param data: certificate/keychain data bytes.
* @return true on success, false on failure.
*
* Note that failure only indicates that the function couldn't launch the
* CertInstaller activity, not that the certificate/keychain was properly
* installed to the keystore.
*/
@CalledByNative
public static boolean storeCertificate(Context context, int cert_type, byte[] data) {
try {
Intent intent = KeyChain.createInstallIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
switch(cert_type) {
case CertificateMimeType.X509_USER_CERT:
case CertificateMimeType.X509_CA_CERT:
intent.putExtra(KeyChain.EXTRA_CERTIFICATE, data);
break;
case CertificateMimeType.PKCS12_ARCHIVE:
intent.putExtra(KeyChain.EXTRA_PKCS12, data);
break;
default:
Log.w(TAG, "invalid certificate type: " + cert_type);
return false;
}
context.startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
Log.w(TAG, "could not store crypto file: " + e);
}
return false;
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class LocalizationUtils method getDefaultLocale.
/**
* @return the default locale, translating Android deprecated
* language codes into the modern ones used by Chromium.
*/
@CalledByNative
public static String getDefaultLocale() {
Locale locale = Locale.getDefault();
String language = locale.getLanguage();
String country = locale.getCountry();
// See http://developer.android.com/reference/java/util/Locale.html
if ("iw".equals(language)) {
language = "he";
} else if ("in".equals(language)) {
language = "id";
} else if ("tl".equals(language)) {
language = "fil";
}
return country.isEmpty() ? language : language + "-" + country;
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class JavaBrowserViewRendererHelper method recordBitmapIntoPicture.
/**
* Creates a new Picture that records drawing a provided bitmap.
* Will return an empty Picture if the Bitmap is null.
*/
@CalledByNative
private static Picture recordBitmapIntoPicture(Bitmap bitmap) {
Picture picture = new Picture();
if (bitmap != null) {
Canvas recordingCanvas = picture.beginRecording(bitmap.getWidth(), bitmap.getHeight());
drawBitmapIntoCanvas(bitmap, recordingCanvas);
picture.endRecording();
}
return picture;
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class ChildProcessService method establishSurfaceTexturePeer.
/**
* Called from native code to share a surface texture with another child process.
* Through using the callback object the browser is used as a proxy to route the
* call to the correct process.
*
* @param pid Process handle of the child process to share the SurfaceTexture with.
* @param surfaceObject The Surface or SurfaceTexture to share with the other child process.
* @param primaryID Used to route the call to the correct client instance.
* @param secondaryID Used to route the call to the correct client instance.
*/
@SuppressWarnings("unused")
@CalledByNative
private void establishSurfaceTexturePeer(int pid, Object surfaceObject, int primaryID, int secondaryID) {
if (mCallback == null) {
Log.e(TAG, "No callback interface has been provided.");
return;
}
Surface surface = null;
boolean needRelease = false;
if (surfaceObject instanceof Surface) {
surface = (Surface) surfaceObject;
} else if (surfaceObject instanceof SurfaceTexture) {
surface = new Surface((SurfaceTexture) surfaceObject);
needRelease = true;
} else {
Log.e(TAG, "Not a valid surfaceObject: " + surfaceObject);
return;
}
try {
mCallback.establishSurfacePeer(pid, surface, primaryID, secondaryID);
} catch (RemoteException e) {
Log.e(TAG, "Unable to call establishSurfaceTexturePeer: " + e);
return;
} finally {
if (needRelease) {
surface.release();
}
}
}
Aggregations