Search in sources :

Example 16 with CalledByNative

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

the class LocationSettings method canSitesRequestLocationPermission.

@CalledByNative
private static boolean canSitesRequestLocationPermission(WebContents webContents) {
    ContentViewCore cvc = ContentViewCore.fromWebContents(webContents);
    if (cvc == null)
        return false;
    WindowAndroid windowAndroid = cvc.getWindowAndroid();
    if (windowAndroid == null)
        return false;
    LocationUtils locationUtils = LocationUtils.getInstance();
    if (!locationUtils.isSystemLocationSettingEnabled())
        return false;
    return locationUtils.hasAndroidLocationPermission() || windowAndroid.canRequestPermission(Manifest.permission.ACCESS_FINE_LOCATION);
}
Also used : LocationUtils(org.chromium.components.location.LocationUtils) ContentViewCore(org.chromium.content.browser.ContentViewCore) WindowAndroid(org.chromium.ui.base.WindowAndroid) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 17 with CalledByNative

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

the class DownloadManagerService method addDownloadItemToList.

@CalledByNative
private void addDownloadItemToList(List<DownloadItem> list, String guid, String displayName, String filepath, String url, String mimeType, long startTimestamp, long totalBytes, boolean hasBeenExternallyRemoved) {
    // Remap the MIME type first.
    File file = new File(filepath);
    String newMimeType = ChromeDownloadDelegate.remapGenericMimeType(mimeType, url, file.getName());
    list.add(createDownloadItem(guid, displayName, filepath, url, newMimeType, startTimestamp, totalBytes, hasBeenExternallyRemoved));
}
Also used : File(java.io.File) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 18 with CalledByNative

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

the class AppBannerInfoBarDelegateAndroid method installOrOpenNativeApp.

@CalledByNative
private boolean installOrOpenNativeApp(Tab tab, AppData appData, String referrer) {
    Context context = ContextUtils.getApplicationContext();
    String packageName = appData.packageName();
    PackageManager packageManager = getPackageManager(context);
    if (InstallerDelegate.isInstalled(packageManager, packageName)) {
        // Open the app.
        openApp(context, packageName);
        return true;
    } else {
        // Try installing the app.  If the installation was kicked off, return false to prevent
        // the infobar from disappearing.
        // The supplied referrer is the URL of the page requesting the native app banner. It
        // may be empty depending on that page's referrer policy. If it is non-empty, attach it
        // to the installation intent as Intent.EXTRA_REFERRER.
        Intent installIntent = appData.installIntent();
        if (referrer.length() > 0)
            installIntent.putExtra(Intent.EXTRA_REFERRER, referrer);
        return !tab.getWindowAndroid().showIntent(installIntent, createIntentCallback(appData), null);
    }
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 19 with CalledByNative

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

the class AppBannerInfoBarDelegateAndroid method openWebApk.

@CalledByNative
private void openWebApk(String packageName) {
    Context context = ContextUtils.getApplicationContext();
    PackageManager packageManager = getPackageManager(context);
    if (InstallerDelegate.isInstalled(packageManager, packageName)) {
        mWebApkPackage = null;
        openApp(context, packageName);
    }
}
Also used : Context(android.content.Context) PackageManager(android.content.pm.PackageManager) CalledByNative(org.chromium.base.annotations.CalledByNative)

Example 20 with CalledByNative

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

the class AutoSigninSnackbarController method showSnackbar.

/**
     * Displays Auto sign-in snackbar, which communicates to the users that they
     * were signed in to the web site.
     */
@CalledByNative
private static void showSnackbar(Tab tab, String text) {
    SnackbarManager snackbarManager = tab.getSnackbarManager();
    if (snackbarManager == null)
        return;
    AutoSigninSnackbarController snackbarController = new AutoSigninSnackbarController(snackbarManager, tab);
    Snackbar snackbar = Snackbar.make(text, snackbarController, Snackbar.TYPE_NOTIFICATION, Snackbar.UMA_AUTO_LOGIN);
    Resources resources = tab.getWindowAndroid().getActivity().get().getResources();
    int backgroundColor = ApiCompatibilityUtils.getColor(resources, R.color.light_active_color);
    Bitmap icon = BitmapFactory.decodeResource(resources, R.drawable.account_management_no_picture);
    snackbar.setSingleLine(false).setBackgroundColor(backgroundColor).setProfileImage(icon);
    snackbarManager.showSnackbar(snackbar);
}
Also used : Bitmap(android.graphics.Bitmap) SnackbarManager(org.chromium.chrome.browser.snackbar.SnackbarManager) Resources(android.content.res.Resources) Snackbar(org.chromium.chrome.browser.snackbar.Snackbar) 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