org.chromium.base.PathUtils Java Examples

The following examples show how to use org.chromium.base.PathUtils. 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: ChromeBrowserInitializer.java    From delion with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX, mApplication);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)) {
        ChromeWebApkHost.init();
    }

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example #2
Source File: ChromeBrowserInitializer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    ChromeWebApkHost.init();

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example #3
Source File: ChromeBrowserInitializer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void preInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPreInflationStartupComplete) return;
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);

    // Ensure critical files are available, so they aren't blocked on the file-system
    // behind long-running accesses in next phase.
    // Don't do any large file access here!
    ContentApplication.initCommandLine(mApplication);
    waitForDebuggerIfNeeded();
    ChromeStrictMode.configureStrictMode();
    ChromeWebApkHost.init();

    warmUpSharedPrefs();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(mApplication);
    ApplicationStatus.registerStateListenerForAllActivities(
            createActivityStateListener());

    mPreInflationStartupComplete = true;
}
 
Example #4
Source File: ChromiumTestShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onCreate() {
    // We want to do this at the earliest possible point in startup.
    UmaUtils.recordMainEntryPointTime();
    super.onCreate();

    ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);

    mObservers = new ArrayList<ChromiumTestShellApplicationObserver>();
}
 
Example #5
Source File: AwBrowserProcess.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Loads the native library, and performs basic static construction of objects needed
 * to run webview in this process. Does not create threads; safe to call from zygote.
 * Note: it is up to the caller to ensure this is only called once.
 */
public static void loadLibrary() {
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    try {
        LibraryLoader.loadNow();
    } catch (ProcessInitException e) {
        throw new RuntimeException("Cannot load WebView", e);
    }
}
 
Example #6
Source File: ChromiumTestShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onCreate() {
    // We want to do this at the earliest possible point in startup.
    UmaUtils.recordMainEntryPointTime();
    super.onCreate();

    ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);

    mObservers = new ArrayList<ChromiumTestShellApplicationObserver>();
}
 
Example #7
Source File: ChromiumTestShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onCreate() {
    // We want to do this at the earliest possible point in startup.
    UmaUtils.recordMainEntryPointTime();
    super.onCreate();

    ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);

    mObservers = new ArrayList<ChromiumTestShellApplicationObserver>();
}
 
Example #8
Source File: AwBrowserProcess.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Loads the native library, and performs basic static construction of objects needed
 * to run webview in this process. Does not create threads; safe to call from zygote.
 * Note: it is up to the caller to ensure this is only called once.
 */
public static void loadLibrary() {
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    try {
        LibraryLoader.loadNow();
    } catch (ProcessInitException e) {
        throw new RuntimeException("Cannot load WebView", e);
    }
}
 
Example #9
Source File: ChromiumTestShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void onCreate() {
    // We want to do this at the earliest possible point in startup.
    UmaUtils.recordMainEntryPointTime();
    super.onCreate();

    ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);

    mObservers = new ArrayList<ChromiumTestShellApplicationObserver>();
}
 
Example #10
Source File: TabContentManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Remove on-disk thumbnails that are no longer needed.
 * @param modelSelector The selector that answers whether a tab is currently present.
 */
public void cleanUpPersistentData(final TabModelSelector modelSelector) {
    if (mNativeTabContentManager == 0) return;

    // BUG: We support multiple tab model selectors, and they all share the same thumbnail
    // directory. This cleanup code checks only the current model selector to see if the
    // thumbnails are no longer used. It should instead consult with *all* tab model selectors
    // (which may not even be in memory).
    new AsyncTask<Void, Void, String[]>() {
        @Override
        protected String[] doInBackground(Void... voids) {
            String thumbnailDirectory = PathUtils.getThumbnailCacheDirectory(mContext);
            return new File(thumbnailDirectory).list();
        }

        @Override
        protected void onPostExecute(String[] fileNames) {
            for (String fileName : fileNames) {
                try {
                    int id = Integer.parseInt(fileName);
                    if (TabModelUtils.getTabById(modelSelector.getModel(false), id) == null
                            && TabModelUtils.getTabById(modelSelector.getModel(true), id)
                                    == null) {
                        removeTabThumbnail(id);
                    }
                } catch (NumberFormatException expected) {
                    // This is an unknown file name, we'll leave it there.
                }
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #11
Source File: ExternalNavigationDelegateImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldRequestFileAccess(String url, Tab tab) {
    // If the tab is null, then do not attempt to prompt for access.
    if (tab == null) return false;

    // If the url points inside of Chromium's data directory, no permissions are necessary.
    // This is required to prevent permission prompt when uses wants to access offline pages.
    if (url.startsWith(UrlConstants.FILE_URL_PREFIX + PathUtils.getDataDirectory())) {
        return false;
    }

    return !tab.getWindowAndroid().hasPermission(permission.READ_EXTERNAL_STORAGE)
            && tab.getWindowAndroid().canRequestPermission(permission.READ_EXTERNAL_STORAGE);
}
 
Example #12
Source File: TabbedModeTabPersistencePolicy.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected Void doInBackground(Void... voids) {
    if (mDestroyed) return null;

    mTabFileNames = getOrCreateStateDirectory().list();
    String thumbnailDirectory = PathUtils.getThumbnailCacheDirectory();
    mThumbnailFileNames = new File(thumbnailDirectory).list();

    mOtherTabIds = new SparseBooleanArray();
    getTabsFromOtherStateFiles(mOtherTabIds);
    return null;
}
 
Example #13
Source File: ExternalNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldRequestFileAccess(String url, Tab tab) {
    // If the tab is null, then do not attempt to prompt for access.
    if (tab == null) return false;

    // If the url points inside of Chromium's data directory, no permissions are necessary.
    // This is required to prevent permission prompt when uses wants to access offline pages.
    if (url.startsWith("file://" + PathUtils.getDataDirectory())) {
        return false;
    }

    return !tab.getWindowAndroid().hasPermission(permission.WRITE_EXTERNAL_STORAGE)
            && tab.getWindowAndroid().canRequestPermission(permission.WRITE_EXTERNAL_STORAGE);
}
 
Example #14
Source File: TabbedModeTabPersistencePolicy.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected Void doInBackground(Void... voids) {
    if (mDestroyed) return null;

    mTabFileNames = getOrCreateStateDirectory().list();
    String thumbnailDirectory = PathUtils.getThumbnailCacheDirectory();
    mThumbnailFileNames = new File(thumbnailDirectory).list();

    mOtherTabIds = new SparseBooleanArray();
    getTabsFromOtherStateFiles(mOtherTabIds);
    return null;
}
 
Example #15
Source File: ExternalNavigationDelegateImpl.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public boolean shouldRequestFileAccess(String url, Tab tab) {
    // If the tab is null, then do not attempt to prompt for access.
    if (tab == null) return false;

    // If the url points inside of Chromium's data directory, no permissions are necessary.
    // This is required to prevent permission prompt when uses wants to access offline pages.
    if (url.startsWith("file://" + PathUtils.getDataDirectory(mApplicationContext))) {
        return false;
    }

    return !tab.getWindowAndroid().hasPermission(permission.WRITE_EXTERNAL_STORAGE)
            && tab.getWindowAndroid().canRequestPermission(permission.WRITE_EXTERNAL_STORAGE);
}
 
Example #16
Source File: MediaResourceGetter.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
String getExternalStorageDirectory() {
    return PathUtils.getExternalStorageDirectory();
}
 
Example #17
Source File: MinidumpDirectoryObserver.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
public MinidumpDirectoryObserver() {
    // The file observer detects MOVED_TO for child processes.
    super(new File(PathUtils.getCacheDirectory(),
            CrashFileManager.CRASH_DUMP_DIR).toString(), FileObserver.MOVED_TO);
}
 
Example #18
Source File: ContentShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void initializeApplicationParameters() {
    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
}
 
Example #19
Source File: ContentShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void initializeApplicationParameters() {
    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
}
 
Example #20
Source File: ResourceExtractor.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static File getOutputDirFromContext(Context context) {
    return new File(PathUtils.getDataDirectory(context.getApplicationContext()), "paks");
}
 
Example #21
Source File: MinidumpDirectoryObserver.java    From delion with Apache License 2.0 4 votes vote down vote up
public MinidumpDirectoryObserver() {
    // The file observer detects MOVED_TO for child processes.
    super(new File(PathUtils.getCacheDirectory(sContext),
            CrashFileManager.CRASH_DUMP_DIR).toString(), FileObserver.MOVED_TO);
}
 
Example #22
Source File: ContentShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void initializeApplicationParameters() {
    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
}
 
Example #23
Source File: ContentShellApplication.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void initializeApplicationParameters() {
    ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES);
    PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
    LibraryLoader.setLibraryToLoad(LIBRARIES);
}
 
Example #24
Source File: ResourceExtractor.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static File getOutputDirFromContext(Context context) {
    return new File(PathUtils.getDataDirectory(context.getApplicationContext()), "paks");
}