Search in sources :

Example 26 with CalledByNative

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

the class ChromeMediaRouter method createRoute.

/**
     * Initiates route creation with the given parameters. Notifies the native client of success
     * and failure.
     * @param sourceId the id of the {@link MediaSource} to route to the sink.
     * @param sinkId the id of the {@link MediaSink} to route the source to.
     * @param presentationId the id of the presentation to be used by the page.
     * @param origin the origin of the frame requesting a new route.
     * @param tabId the id of the tab the requesting frame belongs to.
     * @param isIncognito whether the route is being requested from an Incognito profile.
     * @param requestId the id of the route creation request tracked by the native side.
     */
@CalledByNative
public void createRoute(String sourceId, String sinkId, String presentationId, String origin, int tabId, boolean isIncognito, int requestId) {
    MediaRouteProvider provider = getProviderForSource(sourceId);
    if (provider == null) {
        onRouteRequestError("No provider supports createRoute with source: " + sourceId + " and sink: " + sinkId, requestId);
        return;
    }
    provider.createRoute(sourceId, sinkId, presentationId, origin, tabId, isIncognito, requestId);
}
Also used : CastMediaRouteProvider(org.chromium.chrome.browser.media.router.cast.CastMediaRouteProvider) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 27 with CalledByNative

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

the class ChromeMediaRouterDialogController method openRouteChooserDialog.

/**
     * Shows the {@link MediaRouteChooserDialogFragment} if it's not shown yet.
     * @param sourceUrn the URN identifying the media source to filter the devices with.
     */
@CalledByNative
public void openRouteChooserDialog(String sourceUrn) {
    if (isShowingDialog())
        return;
    MediaSource source = MediaSource.from(sourceUrn);
    if (source == null)
        return;
    mDialogManager = new MediaRouteChooserDialogManager(source, mApplicationContext, this);
    mDialogManager.openDialog();
}
Also used : MediaSource(org.chromium.chrome.browser.media.router.cast.MediaSource) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 28 with CalledByNative

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

the class WebApkInstaller method installAsyncAndMonitorInstallationFromNative.

/**
     * Installs a WebAPK and monitors the installation process.
     * @param filePath File to install.
     * @param packageName Package name to install WebAPK at.
     * @return True if the install was started. A "true" return value does not guarantee that the
     *         install succeeds.
     */
@CalledByNative
private boolean installAsyncAndMonitorInstallationFromNative(String filePath, String packageName) {
    if (!installingFromUnknownSourcesAllowed()) {
        Log.e(TAG, "WebAPK install failed because installation from unknown sources is disabled.");
        return false;
    }
    mIsInstall = true;
    mWebApkPackageName = packageName;
    // Start monitoring the installation.
    PackageManager packageManager = ContextUtils.getApplicationContext().getPackageManager();
    mInstallTask = new InstallerDelegate(Looper.getMainLooper(), packageManager, createInstallerDelegateObserver(), mWebApkPackageName);
    mInstallTask.start();
    // Start monitoring the application state changes.
    mListener = createApplicationStateListener();
    ApplicationStatus.registerApplicationStateListener(mListener);
    return installDownloadedWebApk(filePath);
}
Also used : PackageManager(android.content.pm.PackageManager) InstallerDelegate(org.chromium.chrome.browser.banners.InstallerDelegate) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 29 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 30 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)

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