use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeDownloadDelegate method requestFileAccess.
@CalledByNative
private void requestFileAccess(final long callbackId) {
if (mTab == null || mTab.getWindowAndroid() == null) {
// TODO(tedchoc): Show toast (only when activity is alive).
DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
return;
}
final String storagePermission = android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
final Activity activity = mTab.getWindowAndroid().getActivity().get();
if (activity == null) {
DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
} else if (mTab.getWindowAndroid().canRequestPermission(storagePermission)) {
View view = activity.getLayoutInflater().inflate(R.layout.update_permissions_dialog, null);
TextView dialogText = (TextView) view.findViewById(R.id.text);
dialogText.setText(R.string.missing_storage_permission_download_education_text);
final PermissionCallback permissionCallback = new PermissionCallback() {
@Override
public void onRequestPermissionsResult(String[] permissions, int[] grantResults) {
DownloadController.getInstance().onRequestFileAccessResult(callbackId, grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED);
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.AlertDialogTheme).setView(view).setPositiveButton(R.string.infobar_update_permissions_button_text, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
if (mTab == null) {
dialog.cancel();
return;
}
mTab.getWindowAndroid().requestPermissions(new String[] { storagePermission }, permissionCallback);
}
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
}
});
builder.create().show();
} else if (!mTab.getWindowAndroid().isPermissionRevokedByPolicy(storagePermission)) {
nativeLaunchPermissionUpdateInfoBar(mTab, storagePermission, callbackId);
} else {
// TODO(tedchoc): Show toast.
DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
}
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeMediaRouter method detachRoute.
/**
* Notifies the specified route that it's not attached to the web page anymore.
* @param routeId the id of the route that was detached.
*/
@CalledByNative
public void detachRoute(String routeId) {
MediaRouteProvider provider = mRouteIdsToProviders.get(routeId);
if (provider == null)
return;
provider.detachRoute(routeId);
mRouteIdsToProviders.remove(routeId);
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeMediaRouter method stopObservingMediaSinks.
/**
* Stops background monitoring for available media sinks compatible with the given
* |sourceUrn|
* @param sourceId a URL passed to {@link #startObservingMediaSinks(String)} before.
*/
@CalledByNative
public void stopObservingMediaSinks(String sourceId) {
for (MediaRouteProvider provider : mRouteProviders) {
provider.stopObservingMediaSinks(sourceId);
}
mSinksPerSource.remove(sourceId);
mSinksPerSourcePerProvider.remove(sourceId);
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeMediaRouter method sendBinaryMessage.
/**
* Sends a binary message to the specified route.
* @param routeId The id of the route to send the message to.
* @param data The binary message to send.
* @param callbackId The id of the result callback tracked by the native side.
*/
@CalledByNative
public void sendBinaryMessage(String routeId, byte[] data, int callbackId) {
MediaRouteProvider provider = mRouteIdsToProviders.get(routeId);
if (provider == null) {
nativeOnMessageSentResult(mNativeMediaRouterAndroid, false, callbackId);
return;
}
provider.sendBinaryMessage(routeId, data, callbackId);
}
use of org.chromium.base.annotations.CalledByNative in project AndroidChromium by JackyAndroid.
the class ChromeMediaRouter method create.
/**
* Initializes the media router and its providers.
* @param nativeMediaRouterAndroid the handler for the native counterpart of this instance
* @param applicationContext the application context to use to obtain system APIs
* @return an initialized {@link ChromeMediaRouter} instance
*/
@CalledByNative
public static ChromeMediaRouter create(long nativeMediaRouterAndroid, Context applicationContext) {
ChromeMediaRouter router = new ChromeMediaRouter(nativeMediaRouterAndroid);
MediaRouteProvider provider = sRouteProviderBuilder.create(applicationContext, router);
if (provider != null)
router.addMediaRouteProvider(provider);
return router;
}
Aggregations