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()]);
}
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);
}
});
}
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);
}
}
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;
}
Aggregations