Search in sources :

Example 71 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class OAuth2TokenService method getSystemAccountNames.

/**
     * Called by native to list the activite account names in the OS.
     */
@VisibleForTesting
@CalledByNative
public static String[] getSystemAccountNames(Context context) {
    AccountManagerHelper accountManagerHelper = AccountManagerHelper.get(context);
    java.util.List<String> accountNames = accountManagerHelper.getGoogleAccountNames();
    return accountNames.toArray(new String[accountNames.size()]);
}
Also used : AccountManagerHelper(org.chromium.components.signin.AccountManagerHelper) VisibleForTesting(org.chromium.base.VisibleForTesting) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 72 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class OAuth2TokenService method getOAuth2AuthToken.

/**
     * Called by native to retrieve OAuth2 tokens.
     *
     * @param username The native username (full address).
     * @param scope The scope to get an auth token for (without Android-style 'oauth2:' prefix).
     * @param nativeCallback The pointer to the native callback that should be run upon completion.
     */
@CalledByNative
public static void getOAuth2AuthToken(Context context, String username, String scope, final long nativeCallback) {
    Account account = getAccountOrNullFromUsername(context, username);
    if (account == null) {
        ThreadUtils.postOnUiThread(new Runnable() {

            @Override
            public void run() {
                nativeOAuth2TokenFetched(null, false, nativeCallback);
            }
        });
        return;
    }
    String oauth2Scope = OAUTH2_SCOPE_PREFIX + scope;
    AccountManagerHelper accountManagerHelper = AccountManagerHelper.get(context);
    accountManagerHelper.getAuthToken(account, oauth2Scope, new AccountManagerHelper.GetAuthTokenCallback() {

        @Override
        public void tokenAvailable(String token) {
            nativeOAuth2TokenFetched(token, false, nativeCallback);
        }

        @Override
        public void tokenUnavailable(boolean isTransientError) {
            nativeOAuth2TokenFetched(null, isTransientError, nativeCallback);
        }
    });
}
Also used : Account(android.accounts.Account) AccountManagerHelper(org.chromium.components.signin.AccountManagerHelper) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 73 with CalledByNative

use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.

the class PlatformUtil method launchExternalProtocol.

@CalledByNative
private static void launchExternalProtocol(String url) {
    Context context = ContextUtils.getApplicationContext();
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addCategory(Intent.CATEGORY_BROWSABLE);
    try {
        context.startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.e(TAG, "cannot find activity to launch %s", url, e);
    }
}
Also used : Context(android.content.Context) ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 74 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)

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