| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.os.Handler; | 8 import android.os.Handler; |
| 9 | 9 |
| 10 import org.chromium.base.ContextUtils; |
| 10 import org.chromium.base.Log; | 11 import org.chromium.base.Log; |
| 11 import org.chromium.base.ResourceExtractor; | 12 import org.chromium.base.ResourceExtractor; |
| 12 import org.chromium.base.ThreadUtils; | 13 import org.chromium.base.ThreadUtils; |
| 13 import org.chromium.base.VisibleForTesting; | 14 import org.chromium.base.VisibleForTesting; |
| 14 import org.chromium.base.annotations.CalledByNative; | 15 import org.chromium.base.annotations.CalledByNative; |
| 15 import org.chromium.base.annotations.JNINamespace; | 16 import org.chromium.base.annotations.JNINamespace; |
| 16 import org.chromium.base.library_loader.LibraryLoader; | 17 import org.chromium.base.library_loader.LibraryLoader; |
| 17 import org.chromium.base.library_loader.LibraryProcessType; | 18 import org.chromium.base.library_loader.LibraryProcessType; |
| 18 import org.chromium.base.library_loader.LoaderErrors; | 19 import org.chromium.base.library_loader.LoaderErrors; |
| 19 import org.chromium.base.library_loader.ProcessInitException; | 20 import org.chromium.base.library_loader.ProcessInitException; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // to load it here if we arrived via another flow, e.g. bookmark access
& sync setup. | 285 // to load it here if we arrived via another flow, e.g. bookmark access
& sync setup. |
| 285 LibraryLoader.get(mLibraryProcessType).ensureInitialized(mContext); | 286 LibraryLoader.get(mLibraryProcessType).ensureInitialized(mContext); |
| 286 | 287 |
| 287 Runnable postResourceExtraction = new Runnable() { | 288 Runnable postResourceExtraction = new Runnable() { |
| 288 @Override | 289 @Override |
| 289 public void run() { | 290 public void run() { |
| 290 if (!mPostResourceExtractionTasksCompleted) { | 291 if (!mPostResourceExtractionTasksCompleted) { |
| 291 // TODO(yfriedman): Remove dependency on a command line flag
for this. | 292 // TODO(yfriedman): Remove dependency on a command line flag
for this. |
| 292 DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext); | 293 DeviceUtils.addDeviceSpecificUserAgentSwitch(mContext); |
| 293 | 294 |
| 295 ContextUtils.initApplicationContext(mContext); |
| 294 nativeSetCommandLineFlags( | 296 nativeSetCommandLineFlags( |
| 295 singleProcess, nativeIsPluginEnabled() ? getPlugins(
) : null); | 297 singleProcess, nativeIsPluginEnabled() ? getPlugins(
) : null); |
| 296 mPostResourceExtractionTasksCompleted = true; | 298 mPostResourceExtractionTasksCompleted = true; |
| 297 } | 299 } |
| 298 | 300 |
| 299 if (completionCallback != null) completionCallback.run(); | 301 if (completionCallback != null) completionCallback.run(); |
| 300 } | 302 } |
| 301 }; | 303 }; |
| 302 | 304 |
| 303 if (completionCallback == null) { | 305 if (completionCallback == null) { |
| 304 // If no continuation callback is specified, then force the resource
extraction | 306 // If no continuation callback is specified, then force the resource
extraction |
| 305 // to complete. | 307 // to complete. |
| 306 resourceExtractor.waitForCompletion(); | 308 resourceExtractor.waitForCompletion(); |
| 307 postResourceExtraction.run(); | 309 postResourceExtraction.run(); |
| 308 } else { | 310 } else { |
| 309 resourceExtractor.addCompletionCallback(postResourceExtraction); | 311 resourceExtractor.addCompletionCallback(postResourceExtraction); |
| 310 } | 312 } |
| 311 } | 313 } |
| 312 | 314 |
| 313 /** | 315 /** |
| 314 * Initialization needed for tests. Mainly used by content browsertests. | 316 * Initialization needed for tests. Mainly used by content browsertests. |
| 315 */ | 317 */ |
| 316 public void initChromiumBrowserProcessForTests() { | 318 public void initChromiumBrowserProcessForTests() { |
| 317 ResourceExtractor resourceExtractor = ResourceExtractor.get(mContext); | 319 ResourceExtractor resourceExtractor = ResourceExtractor.get(mContext); |
| 318 resourceExtractor.startExtractingResources(); | 320 resourceExtractor.startExtractingResources(); |
| 319 resourceExtractor.waitForCompletion(); | 321 resourceExtractor.waitForCompletion(); |
| 322 |
| 323 ContextUtils.initApplicationContext(mContext.getApplicationContext()); |
| 320 nativeSetCommandLineFlags(false, null); | 324 nativeSetCommandLineFlags(false, null); |
| 321 } | 325 } |
| 322 | 326 |
| 323 private String getPlugins() { | 327 private String getPlugins() { |
| 324 return PepperPluginManager.getPlugins(mContext); | 328 return PepperPluginManager.getPlugins(mContext); |
| 325 } | 329 } |
| 326 | 330 |
| 327 private static native void nativeSetCommandLineFlags( | 331 private static native void nativeSetCommandLineFlags( |
| 328 boolean singleProcess, String pluginDescriptor); | 332 boolean singleProcess, String pluginDescriptor); |
| 329 | 333 |
| 330 // Is this an official build of Chrome? Only native code knows for sure. Off
icial build | 334 // Is this an official build of Chrome? Only native code knows for sure. Off
icial build |
| 331 // knowledge is needed very early in process startup. | 335 // knowledge is needed very early in process startup. |
| 332 private static native boolean nativeIsOfficialBuild(); | 336 private static native boolean nativeIsOfficialBuild(); |
| 333 | 337 |
| 334 private static native boolean nativeIsPluginEnabled(); | 338 private static native boolean nativeIsPluginEnabled(); |
| 335 } | 339 } |
| OLD | NEW |