org.chromium.content.browser.DeviceUtils Java Examples

The following examples show how to use org.chromium.content.browser.DeviceUtils. 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: InfoBarContainer.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: InfoBarContainer.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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
Source File: TranslateInfoBar.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean needsAlwaysPanel() {
    return (getInfoBarType() == TranslateInfoBar.AFTER_TRANSLATE_INFOBAR
            && mOptions.alwaysTranslateLanguageState() && !DeviceUtils.isTablet(getContext()));
}
 
Example #9
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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
Source File: TranslateInfoBar.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private boolean needsAlwaysPanel() {
    return (getInfoBarType() == TranslateInfoBar.AFTER_TRANSLATE_INFOBAR
            && mOptions.alwaysTranslateLanguageState() && !DeviceUtils.isTablet(getContext()));
}
 
Example #11
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@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();
            }
        });
    }
}