Search in sources :

Example 21 with CalledByNative

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

the class Tab method swapWebContents.

/** This is currently called when committing a pre-rendered page. */
@VisibleForTesting
@CalledByNative
public void swapWebContents(WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
    ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext, PRODUCT_VERSION);
    ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
    cv.setContentDescription(mThemedApplicationContext.getResources().getString(R.string.accessibility_content_view));
    cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents, getWindowAndroid());
    swapContentViewCore(cvc, false, didStartLoad, didFinishLoad);
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) ContentView(org.chromium.content.browser.ContentView) VisibleForTesting(org.chromium.base.VisibleForTesting) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 22 with CalledByNative

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

the class Tab method setPendingPrint.

@CalledByNative
public void setPendingPrint() {
    PrintingController printingController = PrintingControllerImpl.getInstance();
    if (printingController == null)
        return;
    printingController.setPendingPrint(new TabPrinter(this), new PrintManagerDelegateImpl(getActivity()));
}
Also used : PrintManagerDelegateImpl(org.chromium.printing.PrintManagerDelegateImpl) TabPrinter(org.chromium.chrome.browser.printing.TabPrinter) PrintingController(org.chromium.printing.PrintingController) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 23 with CalledByNative

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

the class PermissionUpdateInfoBarDelegate method requestPermissions.

@CalledByNative
private void requestPermissions() {
    WindowAndroid windowAndroid = mContentViewCore.getWindowAndroid();
    if (windowAndroid == null) {
        nativeOnPermissionResult(mNativePtr, false);
        return;
    }
    boolean canRequestAllPermissions = true;
    for (int i = 0; i < mAndroidPermisisons.length; i++) {
        canRequestAllPermissions &= (windowAndroid.hasPermission(mAndroidPermisisons[i]) || windowAndroid.canRequestPermission(mAndroidPermisisons[i]));
    }
    if (canRequestAllPermissions) {
        windowAndroid.requestPermissions(mAndroidPermisisons, this);
    } else {
        Activity activity = windowAndroid.getActivity().get();
        if (activity == null) {
            nativeOnPermissionResult(mNativePtr, false);
            return;
        }
        mActivityStateListener = new ActivityStateListener() {

            @Override
            public void onActivityStateChange(Activity activity, int newState) {
                if (newState == ActivityState.DESTROYED) {
                    ApplicationStatus.unregisterActivityStateListener(this);
                    mActivityStateListener = null;
                    nativeOnPermissionResult(mNativePtr, false);
                } else if (newState == ActivityState.RESUMED) {
                    ApplicationStatus.unregisterActivityStateListener(this);
                    mActivityStateListener = null;
                    notifyPermissionResult();
                }
            }
        };
        ApplicationStatus.registerStateListenerForActivity(mActivityStateListener, activity);
        Intent settingsIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        settingsIntent.setData(Uri.parse("package:" + windowAndroid.getApplicationContext().getPackageName()));
        settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(settingsIntent);
    }
}
Also used : ActivityStateListener(org.chromium.base.ApplicationStatus.ActivityStateListener) Activity(android.app.Activity) Intent(android.content.Intent) WindowAndroid(org.chromium.ui.base.WindowAndroid) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 24 with CalledByNative

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

the class ChromeMediaRouter method joinRoute.

/**
     * Initiates route joining with the given parameters. Notifies the native client of success
     * or 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 requestId the id of the route creation request tracked by the native side.
     */
@CalledByNative
public void joinRoute(String sourceId, String presentationId, String origin, int tabId, int requestId) {
    MediaRouteProvider provider = getProviderForSource(sourceId);
    if (provider == null) {
        onRouteRequestError("Route not found.", requestId);
        return;
    }
    provider.joinRoute(sourceId, presentationId, origin, tabId, requestId);
}
Also used : CastMediaRouteProvider(org.chromium.chrome.browser.media.router.cast.CastMediaRouteProvider) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 25 with CalledByNative

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

the class ChromeMediaRouter method closeRoute.

/**
     * Closes the route specified by the id.
     * @param routeId the id of the route to close.
     */
@CalledByNative
public void closeRoute(String routeId) {
    MediaRouteProvider provider = mRouteIdsToProviders.get(routeId);
    if (provider == null)
        return;
    provider.closeRoute(routeId);
}
Also used : CastMediaRouteProvider(org.chromium.chrome.browser.media.router.cast.CastMediaRouteProvider) 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