Search in sources :

Example 41 with CalledByNative

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;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 42 with CalledByNative

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.
    }
}
Also used : Intent(android.content.Intent) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 43 with CalledByNative

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();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 44 with CalledByNative

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);
}
Also used : ClearBrowsingDataPreferences(org.chromium.chrome.browser.preferences.privacy.ClearBrowsingDataPreferences) IncognitoDocumentActivity(org.chromium.chrome.browser.document.IncognitoDocumentActivity) DocumentActivity(org.chromium.chrome.browser.document.DocumentActivity) Activity(android.app.Activity) Intent(android.content.Intent) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 45 with CalledByNative

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;
}
Also used : Activity(android.app.Activity) X500Principal(javax.security.auth.x500.X500Principal) X500Principal(javax.security.auth.x500.X500Principal) Principal(java.security.Principal) ActivityNotFoundException(android.content.ActivityNotFoundException) KeyChainException(android.security.KeyChainException) CertificateEncodingException(java.security.cert.CertificateEncodingException) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

CalledByNative (org.chromium.base.annotations.CalledByNative)74 Activity (android.app.Activity)11 Context (android.content.Context)11 Intent (android.content.Intent)10 CastMediaRouteProvider (org.chromium.chrome.browser.media.router.cast.CastMediaRouteProvider)8 DownloadNotifier (org.chromium.chrome.browser.download.DownloadNotifier)6 View (android.view.View)5 TextView (android.widget.TextView)5 DownloadInfo (org.chromium.chrome.browser.download.DownloadInfo)5 SuppressLint (android.annotation.SuppressLint)4 PackageManager (android.content.pm.PackageManager)4 Bitmap (android.graphics.Bitmap)4 Paint (android.graphics.Paint)4 ScrollView (android.widget.ScrollView)4 ActivityManager (android.app.ActivityManager)3 ImageView (android.widget.ImageView)3 LinearLayout (android.widget.LinearLayout)3 VisibleForTesting (org.chromium.base.VisibleForTesting)3 Account (android.accounts.Account)2 ActivityNotFoundException (android.content.ActivityNotFoundException)2