Java Code Examples for org.chromium.content.browser.DeviceUtils

The following examples show how to use org.chromium.content.browser.DeviceUtils. These examples are extracted from open source projects. 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 Project: delion   Source File: ChromeBrowserInitializer.java    License: 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 Project: AndroidChromium   Source File: ChromeBrowserInitializer.java    License: 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 Project: 365browser   Source File: ChromeBrowserInitializer.java    License: 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
public InfoBarContainer(Activity activity, AutoLoginProcessor autoLoginProcessor,
        int tabId, ViewGroup parentView, int nativeWebContents) {
    super(activity);
    setOrientation(LinearLayout.VERTICAL);
    mAnimationListener = null;
    mInfoBarTransitions = new ArrayDeque<InfoBarTransitionInfo>();

    mAutoLoginDelegate = new AutoLoginDelegate(autoLoginProcessor, activity);
    mActivity = activity;
    mTabId = tabId;
    mParentView = parentView;

    mAnimationSizer = new FrameLayout(activity);
    mAnimationSizer.setVisibility(INVISIBLE);

    // The tablet has the infobars below the location bar. On the phone they are at the bottom.
    mInfoBarsOnTop = DeviceUtils.isTablet(activity);
    setGravity(determineGravity());

    // Chromium's InfoBarContainer may add an InfoBar immediately during this initialization
    // call, so make sure everything in the InfoBarContainer is completely ready beforehand.
    mNativeInfoBarContainer = nativeInit(nativeWebContents, mAutoLoginDelegate);
}
 
Example 5
public InfoBarContainer(Activity activity, AutoLoginProcessor autoLoginProcessor,
        int tabId, ViewGroup parentView, int nativeWebContents) {
    super(activity);
    setOrientation(LinearLayout.VERTICAL);
    mAnimationListener = null;
    mInfoBarTransitions = new ArrayDeque<InfoBarTransitionInfo>();

    mAutoLoginDelegate = new AutoLoginDelegate(autoLoginProcessor, activity);
    mActivity = activity;
    mTabId = tabId;
    mParentView = parentView;

    mAnimationSizer = new FrameLayout(activity);
    mAnimationSizer.setVisibility(INVISIBLE);

    // The tablet has the infobars below the location bar. On the phone they are at the bottom.
    mInfoBarsOnTop = DeviceUtils.isTablet(activity);
    setGravity(determineGravity());

    // Chromium's InfoBarContainer may add an InfoBar immediately during this initialization
    // call, so make sure everything in the InfoBarContainer is completely ready beforehand.
    mNativeInfoBarContainer = nativeInit(nativeWebContents, mAutoLoginDelegate);
}
 
Example 6
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ChromiumTestShellApplication.initCommandLine();
    waitForDebuggerIfNeeded();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(this);

    BrowserStartupController.StartupCallback callback =
            new BrowserStartupController.StartupCallback() {
                @Override
                public void onSuccess(boolean alreadyStarted) {
                    finishInitialization(savedInstanceState);
                }

                @Override
                public void onFailure() {
                    Toast.makeText(ChromiumTestShellActivity.this,
                                   R.string.browser_process_initialization_failed,
                                   Toast.LENGTH_SHORT).show();
                    Log.e(TAG, "Chromium browser process initialization failed");
                    finish();
                }
            };
    BrowserStartupController.get(this).startBrowserProcessesAsync(callback);
}
 
Example 7
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ChromiumTestShellApplication.initCommandLine();
    waitForDebuggerIfNeeded();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(this);

    BrowserStartupController.StartupCallback callback =
            new BrowserStartupController.StartupCallback() {
                @Override
                public void onSuccess(boolean alreadyStarted) {
                    finishInitialization(savedInstanceState);
                }

                @Override
                public void onFailure() {
                    Toast.makeText(ChromiumTestShellActivity.this,
                                   R.string.browser_process_initialization_failed,
                                   Toast.LENGTH_SHORT).show();
                    Log.e(TAG, "Chromium browser process initialization failed");
                    finish();
                }
            };
    BrowserStartupController.get(this).startBrowserProcessesAsync(callback);
}
 
Example 8
private boolean needsAlwaysPanel() {
    return (getInfoBarType() == TranslateInfoBar.AFTER_TRANSLATE_INFOBAR
            && mOptions.alwaysTranslateLanguageState() && !DeviceUtils.isTablet(getContext()));
}
 
Example 9
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializing the command line must occur before loading the library.
    if (!CommandLine.isInitialized()) {
        CommandLine.initFromFile(COMMAND_LINE_FILE);
        String[] commandLineParams = getCommandLineParamsFromIntent(getIntent());
        if (commandLineParams != null) {
            CommandLine.getInstance().appendSwitchesAndArguments(commandLineParams);
        }
    }
    waitForDebuggerIfNeeded();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(this);
    try {
        LibraryLoader.ensureInitialized();
    } catch (ProcessInitException e) {
        Log.e(TAG, "ContentView initialization failed.", e);
        finish();
        return;
    }

    setContentView(R.layout.content_shell_activity);
    mShellManager = (ShellManager) findViewById(R.id.shell_container);
    mWindowAndroid = new ActivityWindowAndroid(this);
    mWindowAndroid.restoreInstanceState(savedInstanceState);
    mShellManager.setWindow(mWindowAndroid);

    String startupUrl = getUrlFromIntent(getIntent());
    if (!TextUtils.isEmpty(startupUrl)) {
        mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
    }

    if (CommandLine.getInstance().hasSwitch(CommandLine.DUMP_RENDER_TREE)) {
        if(BrowserStartupController.get(this).startBrowserProcessesSync(
               BrowserStartupController.MAX_RENDERERS_LIMIT)) {
            finishInitialization(savedInstanceState);
        } else {
            initializationFailed();
        }
    } else {
        BrowserStartupController.get(this).startBrowserProcessesAsync(
                new BrowserStartupController.StartupCallback() {
            @Override
            public void onSuccess(boolean alreadyStarted) {
                finishInitialization(savedInstanceState);
            }

            @Override
            public void onFailure() {
                initializationFailed();
            }
        });
    }
}
 
Example 10
private boolean needsAlwaysPanel() {
    return (getInfoBarType() == TranslateInfoBar.AFTER_TRANSLATE_INFOBAR
            && mOptions.alwaysTranslateLanguageState() && !DeviceUtils.isTablet(getContext()));
}
 
Example 11
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializing the command line must occur before loading the library.
    if (!CommandLine.isInitialized()) {
        CommandLine.initFromFile(COMMAND_LINE_FILE);
        String[] commandLineParams = getCommandLineParamsFromIntent(getIntent());
        if (commandLineParams != null) {
            CommandLine.getInstance().appendSwitchesAndArguments(commandLineParams);
        }
    }
    waitForDebuggerIfNeeded();

    DeviceUtils.addDeviceSpecificUserAgentSwitch(this);
    try {
        LibraryLoader.ensureInitialized();
    } catch (ProcessInitException e) {
        Log.e(TAG, "ContentView initialization failed.", e);
        finish();
        return;
    }

    setContentView(R.layout.content_shell_activity);
    mShellManager = (ShellManager) findViewById(R.id.shell_container);
    mWindowAndroid = new ActivityWindowAndroid(this);
    mWindowAndroid.restoreInstanceState(savedInstanceState);
    mShellManager.setWindow(mWindowAndroid);

    String startupUrl = getUrlFromIntent(getIntent());
    if (!TextUtils.isEmpty(startupUrl)) {
        mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
    }

    if (CommandLine.getInstance().hasSwitch(CommandLine.DUMP_RENDER_TREE)) {
        if(BrowserStartupController.get(this).startBrowserProcessesSync(
               BrowserStartupController.MAX_RENDERERS_LIMIT)) {
            finishInitialization(savedInstanceState);
        } else {
            initializationFailed();
        }
    } else {
        BrowserStartupController.get(this).startBrowserProcessesAsync(
                new BrowserStartupController.StartupCallback() {
            @Override
            public void onSuccess(boolean alreadyStarted) {
                finishInitialization(savedInstanceState);
            }

            @Override
            public void onFailure() {
                initializationFailed();
            }
        });
    }
}