@VisibleForTesting @CalledByNative static void browserStartupComplete(int result) { if (sInstance != null) { sInstance.executeEnqueuedCallbacks(result, NOT_ALREADY_STARTED); } }
/** * Start the browser process asynchronously. This will set up a queue of UI thread tasks to * initialize the browser process. * * <p>Note that this can only be called on the UI thread. * * @param callback the callback to be called when browser startup is complete. * @throws ProcessInitException */ public void startChromeBrowserProcessesAsync(BrowserStartupController.StartupCallback callback) throws ProcessInitException { assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on the wrong thread"; Context applicationContext = getApplicationContext(); BrowserStartupController.get(applicationContext, LibraryProcessType.PROCESS_BROWSER) .startBrowserProcessesAsync(callback); }
/** * Loads native Libraries synchronously and starts Chrome browser processes. Must be called on the * main thread. Makes sure the process is initialized as a Browser process instead of a * ContentView process. * * @param initGoogleServicesManager when true the GoogleServicesManager is initialized. */ public void startBrowserProcessesAndLoadLibrariesSync(boolean initGoogleServicesManager) throws ProcessInitException { ThreadUtils.assertOnUiThread(); initCommandLine(); LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER).ensureInitialized(this, true); final Context context = getApplicationContext(); // Kick off checking for a child account with an empty callback. ChildAccountService.getInstance(context) .checkHasChildAccount( new ChildAccountService.HasChildAccountCallback() { @Override public void onChildAccountChecked(boolean hasChildAccount) {} }); BrowserStartupController.get(context, LibraryProcessType.PROCESS_BROWSER) .startBrowserProcessesSync(false); if (initGoogleServicesManager) initializeGoogleServicesManager(); }
private void initialize(Context context) { Log.i("Ludei", "***************************"); Log.i("Ludei", "Initializing Ludei WebView+"); Log.i("Ludei", "**************************"); if (!staticInitialization) { PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX); ResourceExtractor.setMandatoryPaksToExtract(MANDATORY_PAK_FILES); ResourceProvider.registerResources(); staticInitialization = true; } this.ctx = context; if (mProxyWebView == null) { mProxyWebView = new LudeiWebView(context, null, 0, this); } mBridge = new LudeiContentsClientBridge( mProxyWebView, new LudeiDefaultWebChromeClient(this.ctx, this)); mDelegate = new LudeiContentViewDelegate(this, mBridge); // Initializing the command line must occur before loading the library. if (!CommandLine.isInitialized()) { CommandLine.initFromFile(COMMAND_LINE_FILE); String[] commandLineParams = null; // getCommandLineParamsFromIntent(getIntent()); if (commandLineParams != null) { CommandLine.getInstance().appendSwitchesAndArguments(commandLineParams); } CommandLine.getInstance().appendSwitch("allow-file-access-from-files"); if (!LudeiContentView.REMOTE_DEBUGGING) { CommandLine.getInstance().appendSwitch("disable-remote-debugging"); } CommandLine.getInstance().appendSwitch("ignore-gpu-blacklist"); } waitForDebuggerIfNeeded(); DeviceUtils.addDeviceSpecificUserAgentSwitch(context); try { org.chromium.base.library_loader.LibraryLoader.ensureInitialized(); } catch (ProcessInitException e) { Log.e(TAG, "ContentView initialization failed.", e); // Since the library failed to initialize nothing in the application // can work, so kill the whole application not just the activity System.exit(-1); return; } mSettings = LudeiWebSettingsProxy.Create(context, (new LudeiWebSettings(context, true, false))); shellManager = new ShellManager(context, null, this, mDelegate); WindowAndroid mWindowAndroid = new ActivityWindowAndroid((Activity) ctx); // mWindowAndroid.restoreInstanceState(savedInstanceState); shellManager.setWindow( mWindowAndroid, new Runnable() { @Override public void run() { LudeiContentView.this.onReadyToRender(); } }); if (CommandLine.getInstance().hasSwitch(ContentSwitches.DUMP_RENDER_TREE)) { try { BrowserStartupController.get(context).startBrowserProcessesSync(true); } catch (ProcessInitException e) { Log.e(TAG, "Failed to load native library.", e); System.exit(-1); } } else { try { BrowserStartupController.get(context) .startBrowserProcessesAsync( new BrowserStartupController.StartupCallback() { @Override public void onSuccess(boolean alreadyStarted) { // finishInitialization(savedInstanceState); finishInitialization(null); } @Override public void onFailure() { initializationFailed(); } }); } catch (ProcessInitException e) { Log.e(TAG, "Unable to load native library.", e); System.exit(-1); } } }