use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class VrShellDelegate method enterVRIfNecessary.
/**
* Enters VR Shell, displaying browser UI and tab contents in VR.
*
* This function performs native initialization, and so must only be called after native
* libraries are ready.
* @param inWebVR If true should begin displaying WebVR content rather than the VrShell UI.
* @return Whether or not we are in VR when this function returns.
*/
@CalledByNative
public boolean enterVRIfNecessary(boolean inWebVR) {
if (!mVrShellEnabled || mNativeVrShellDelegate == 0)
return false;
Tab tab = mActivity.getActivityTab();
// entered without any current tabs.
if (tab == null || tab.getContentViewCore() == null) {
return false;
}
if (mInVr)
return true;
// VrShell must be initialized in Landscape mode due to a bug in the GVR library.
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
if (!createVrShell()) {
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
return false;
}
addVrViews();
setupVrModeWindowFlags();
mVrShell.initializeNative(tab, this);
if (inWebVR)
mVrShell.setWebVrModeEnabled(true);
mVrShell.setVrModeEnabled(true);
mInVr = true;
tab.updateFullscreenEnabledState();
return true;
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class IntentHelper method openDateAndTimeSettings.
/**
* Opens date and time in Android settings.
*
* @param context The context for issuing the intent.
*/
@CalledByNative
static void openDateAndTimeSettings(Context context) {
Intent intent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS);
try {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
} catch (android.content.ActivityNotFoundException ex) {
// If it doesn't work, avoid crashing.
}
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class JavascriptAppModalDialog method showJavascriptAppModalDialog.
@CalledByNative
void showJavascriptAppModalDialog(WindowAndroid window, long nativeDialogPointer) {
assert window != null;
Context context = window.getActivity().get();
// If the activity has gone away, then just clean up the native pointer.
if (context == null) {
nativeDidCancelAppModalDialog(nativeDialogPointer, false);
return;
}
// Cache the native dialog pointer so that we can use it to return the response.
mNativeDialogPointer = nativeDialogPointer;
LayoutInflater inflater = LayoutInflater.from(context);
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.js_modal_dialog, null);
mSuppressCheckBox = (CheckBox) layout.findViewById(R.id.suppress_js_modal_dialogs);
mPromptTextView = (TextView) layout.findViewById(R.id.js_modal_dialog_prompt);
prepare(layout);
AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.AlertDialogTheme).setView(layout).setTitle(mTitle).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
cancel(false);
}
});
if (mPositiveButtonTextId != 0)
builder.setPositiveButton(mPositiveButtonTextId, this);
if (mNegativeButtonTextId != 0)
builder.setNegativeButton(mNegativeButtonTextId, this);
mDialog = builder.create();
mDialog.setCanceledOnTouchOutside(false);
mDialog.getDelegate().setHandleNativeActionModesEnabled(false);
mDialog.show();
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeApplication method openClearBrowsingData.
/**
* Opens the UI to clear browsing data.
* @param tab The tab that triggered the request.
*/
@CalledByNative
protected void openClearBrowsingData(Tab tab) {
Activity activity = tab.getWindowAndroid().getActivity().get();
if (activity == null) {
Log.e(TAG, "Attempting to open clear browsing data for a tab without a valid activity");
return;
}
Intent intent = PreferencesLauncher.createIntentForSettingsPage(activity, ClearBrowsingDataPreferences.class.getName());
activity.startActivity(intent);
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class SSLClientCertificateRequest method selectClientCertificate.
/**
* Create a new asynchronous request to select a client certificate.
*
* @param nativePtr The native object responsible for this request.
* @param window A WindowAndroid instance.
* @param keyTypes The list of supported key exchange types.
* @param encodedPrincipals The list of CA DistinguishedNames.
* @param hostName The server host name is available (empty otherwise).
* @param port The server port if available (0 otherwise).
* @return true on success.
* Note that nativeOnSystemRequestComplete will be called iff this method returns true.
*/
@CalledByNative
private static boolean selectClientCertificate(final long nativePtr, final WindowAndroid window, final String[] keyTypes, byte[][] encodedPrincipals, final String hostName, final int port) {
ThreadUtils.assertOnUiThread();
final Activity activity = window.getActivity().get();
if (activity == null) {
Log.w(TAG, "Certificate request on GC'd activity.");
return false;
}
// Build the list of principals from encoded versions.
Principal[] principals = null;
if (encodedPrincipals.length > 0) {
principals = new X500Principal[encodedPrincipals.length];
try {
for (int n = 0; n < encodedPrincipals.length; n++) {
principals[n] = new X500Principal(encodedPrincipals[n]);
}
} catch (Exception e) {
Log.w(TAG, "Exception while decoding issuers list: " + e);
return false;
}
}
KeyChainCertSelectionCallback callback = new KeyChainCertSelectionCallback(activity.getApplicationContext(), nativePtr);
KeyChainCertSelectionWrapper keyChain = new KeyChainCertSelectionWrapper(activity, callback, keyTypes, principals, hostName, port, null);
maybeShowCertSelection(keyChain, callback, new CertSelectionFailureDialog(activity));
// We've taken ownership of the native ssl request object.
return true;
}
Aggregations