Search in sources :

Example 76 with CalledByNative

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

the class Profile method onNativeDestroyed.

@CalledByNative
private void onNativeDestroyed() {
    mNativeProfileAndroid = 0;
    if (mIsOffTheRecord) {
        Context context = ContextUtils.getApplicationContext();
        CookiesFetcher.deleteCookiesIfNecessary(context);
    }
}
Also used : Context(android.content.Context) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 77 with CalledByNative

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

the class DomDistillerUIUtils method openSettings.

/**
 * A static method for native code to call to open the distiller UI settings.
 * @param webContents The WebContents containing the distilled content.
 */
@CalledByNative
public static void openSettings(WebContents webContents) {
    Activity activity = getActivityFromWebContents(webContents);
    if (webContents != null && activity != null) {
        RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened");
        AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.AlertDialogTheme);
        builder.setView(DistilledPagePrefsView.create(activity));
        builder.show();
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Activity(android.app.Activity) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 78 with CalledByNative

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);
    }
}
Also used : DialogInterface(android.content.DialogInterface) ChromeActivity(org.chromium.chrome.browser.ChromeActivity) Activity(android.app.Activity) View(android.view.View) TextView(android.widget.TextView) PermissionCallback(org.chromium.ui.base.WindowAndroid.PermissionCallback) TextView(android.widget.TextView) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 79 with CalledByNative

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

the class PrefServiceBridge method addContentSettingExceptionToList.

@CalledByNative
private static void addContentSettingExceptionToList(ArrayList<ContentSettingException> list, int contentSettingsType, String pattern, int contentSetting, String source) {
    ContentSettingException exception = new ContentSettingException(contentSettingsType, pattern, ContentSetting.fromInt(contentSetting), source);
    list.add(exception);
}
Also used : ContentSettingException(org.chromium.chrome.browser.preferences.website.ContentSettingException) CalledByNative(org.chromium.base.annotations.CalledByNative)

Aggregations

CalledByNative (org.chromium.base.annotations.CalledByNative)79 Context (android.content.Context)13 Intent (android.content.Intent)12 Activity (android.app.Activity)11 CastMediaRouteProvider (org.chromium.chrome.browser.media.router.cast.CastMediaRouteProvider)8 DownloadNotifier (org.chromium.chrome.browser.download.DownloadNotifier)6 PackageManager (android.content.pm.PackageManager)5 Bitmap (android.graphics.Bitmap)5 View (android.view.View)5 TextView (android.widget.TextView)5 DownloadInfo (org.chromium.chrome.browser.download.DownloadInfo)5 SuppressLint (android.annotation.SuppressLint)4 Paint (android.graphics.Paint)4 ActivityManager (android.app.ActivityManager)3 Resources (android.content.res.Resources)3 ImageView (android.widget.ImageView)3 ScrollView (android.widget.ScrollView)3 File (java.io.File)3 VisibleForTesting (org.chromium.base.VisibleForTesting)3 Account (android.accounts.Account)2