org.chromium.chrome.browser.download.DownloadManagerService Java Examples

The following examples show how to use org.chromium.chrome.browser.download.DownloadManagerService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void finishNativeInitialization() {
    // The window background color is used as the resizing background color in Android N+
    // multi-window mode. See crbug.com/602366.
    if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        getWindow().setBackgroundDrawable(new ColorDrawable(
                ApiCompatibilityUtils.getColor(getResources(),
                        R.color.resizing_background_color)));
    } else {
        removeWindowBackground();
    }
    DownloadManagerService.getDownloadManagerService(
            getApplicationContext()).onActivityLaunched();

    super.finishNativeInitialization();
}
 
Example #2
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Pre-load shared prefs to avoid being blocked on the disk access async task in the future.
 * Running in an AsyncTask as pre-loading itself may cause I/O.
 */
private void warmUpSharedPrefs() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                ContextUtils.getAppSharedPreferences();
                DocumentTabModelImpl.warmUpSharedPrefs(mApplication);
                ActivityAssigner.warmUpSharedPrefs(mApplication);
                DownloadManagerService.warmUpSharedPrefs(mApplication);
                return null;
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        ContextUtils.getAppSharedPreferences();
        DocumentTabModelImpl.warmUpSharedPrefs(mApplication);
        ActivityAssigner.warmUpSharedPrefs(mApplication);
        DownloadManagerService.warmUpSharedPrefs(mApplication);
    }
}
 
Example #3
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void finishNativeInitialization() {
    // The window background color is used as the resizing background color in Android N+
    // multi-window mode. See crbug.com/602366.
    if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
        getWindow().setBackgroundDrawable(new ColorDrawable(
                ApiCompatibilityUtils.getColor(getResources(),
                        R.color.resizing_background_color)));
    } else {
        removeWindowBackground();
    }
    DownloadManagerService.getDownloadManagerService(
            getApplicationContext()).onActivityLaunched();
    super.finishNativeInitialization();
}
 
Example #4
Source File: OfflineContentAggregatorNotificationBridgeUiFactory.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return An {@link OfflineContentAggregatorNotificationBridgeUi} instance singleton.  If one
 *         is not available this will create a new one.
 */
public static OfflineContentAggregatorNotificationBridgeUi instance() {
    ThreadUtils.assertOnUiThread();
    if (sBridgeUi == null) {
        Profile profile = Profile.getLastUsedProfile();
        OfflineContentProvider provider = OfflineContentAggregatorFactory.forProfile(profile);
        DownloadNotifier ui =
                DownloadManagerService.getDownloadManagerService().getDownloadNotifier();

        sBridgeUi = new OfflineContentAggregatorNotificationBridgeUi(provider, ui);
    }

    return sBridgeUi;
}
 
Example #5
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void finishNativeInitialization() {
    mNativeInitialized = true;
    OfflineContentAggregatorNotificationBridgeUiFactory.instance();
    maybeRemoveWindowBackground();
    DownloadManagerService.getDownloadManagerService().onActivityLaunched();

    VrShellDelegate.onNativeLibraryAvailable();
    super.finishNativeInitialization();
}
 
Example #6
Source File: DuplicateDownloadInfoBar.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the infobar text for regular downloads.
 * @param context Context to be used.
 * @param template Template of the text to be displayed.
 */
private CharSequence getDownloadMessageText(final Context context, final String template) {
    final File file = new File(mFilePath);
    final Uri fileUri = Uri.fromFile(file);
    final String mimeType = getMimeTypeFromUri(fileUri);
    final String filename = file.getName();
    return getMessageText(template, filename, new ClickableSpan() {
        @Override
        public void onClick(View view) {
            new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected Boolean doInBackground(Void... params) {
                    return new File(mFilePath).exists();
                }

                @Override
                protected void onPostExecute(Boolean fileExists) {
                    if (fileExists) {
                        DownloadUtils.openFile(file, mimeType, null, mIsIncognito);
                    } else {
                        DownloadManagerService.openDownloadsPage(
                                ContextUtils.getApplicationContext());
                    }
                }
            }.execute();
        }
    });
}
 
Example #7
Source File: OfflinePageNotificationBridge.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private static DownloadNotifier getDownloadNotifier(Context context) {
    return DownloadManagerService.getDownloadManagerService(context).getDownloadNotifier();
}
 
Example #8
Source File: DownloadManagerUi.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public DownloadDelegate getDownloadDelegate() {
    return DownloadManagerService.getDownloadManagerService(
            ContextUtils.getApplicationContext());
}
 
Example #9
Source File: OfflinePageNotificationBridge.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private static DownloadNotifier getDownloadNotifier() {
    return DownloadManagerService.getDownloadManagerService().getDownloadNotifier();
}
 
Example #10
Source File: DownloadManagerUi.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public DownloadDelegate getDownloadDelegate() {
    return DownloadManagerService.getDownloadManagerService();
}