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.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.SharedPreferences; | 10 import android.content.SharedPreferences; |
(...skipping 15 matching lines...) Expand all Loading... |
26 import org.chromium.base.ApplicationStatus.ApplicationStateListener; | 26 import org.chromium.base.ApplicationStatus.ApplicationStateListener; |
27 import org.chromium.base.BuildInfo; | 27 import org.chromium.base.BuildInfo; |
28 import org.chromium.base.CommandLineInitUtil; | 28 import org.chromium.base.CommandLineInitUtil; |
29 import org.chromium.base.PathUtils; | 29 import org.chromium.base.PathUtils; |
30 import org.chromium.base.ResourceExtractor; | 30 import org.chromium.base.ResourceExtractor; |
31 import org.chromium.base.ThreadUtils; | 31 import org.chromium.base.ThreadUtils; |
32 import org.chromium.base.TraceEvent; | 32 import org.chromium.base.TraceEvent; |
33 import org.chromium.base.VisibleForTesting; | 33 import org.chromium.base.VisibleForTesting; |
34 import org.chromium.base.annotations.CalledByNative; | 34 import org.chromium.base.annotations.CalledByNative; |
35 import org.chromium.base.annotations.SuppressFBWarnings; | 35 import org.chromium.base.annotations.SuppressFBWarnings; |
36 import org.chromium.base.library_loader.LibraryLoader; | |
37 import org.chromium.base.library_loader.LibraryProcessType; | |
38 import org.chromium.base.library_loader.ProcessInitException; | 36 import org.chromium.base.library_loader.ProcessInitException; |
39 import org.chromium.base.metrics.RecordHistogram; | 37 import org.chromium.base.metrics.RecordHistogram; |
40 import org.chromium.chrome.R; | 38 import org.chromium.chrome.R; |
41 import org.chromium.chrome.browser.accessibility.FontSizePrefs; | 39 import org.chromium.chrome.browser.accessibility.FontSizePrefs; |
42 import org.chromium.chrome.browser.banners.AppBannerManager; | 40 import org.chromium.chrome.browser.banners.AppBannerManager; |
43 import org.chromium.chrome.browser.banners.AppDetailsDelegate; | 41 import org.chromium.chrome.browser.banners.AppDetailsDelegate; |
44 import org.chromium.chrome.browser.customtabs.CustomTabsConnection; | 42 import org.chromium.chrome.browser.customtabs.CustomTabsConnection; |
45 import org.chromium.chrome.browser.datausage.ExternalDataUseObserver; | 43 import org.chromium.chrome.browser.datausage.ExternalDataUseObserver; |
46 import org.chromium.chrome.browser.document.DocumentActivity; | 44 import org.chromium.chrome.browser.document.DocumentActivity; |
47 import org.chromium.chrome.browser.document.IncognitoDocumentActivity; | 45 import org.chromium.chrome.browser.document.IncognitoDocumentActivity; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 import org.chromium.chrome.browser.sync.SyncController; | 84 import org.chromium.chrome.browser.sync.SyncController; |
87 import org.chromium.chrome.browser.tab.AuthenticatorNavigationInterceptor; | 85 import org.chromium.chrome.browser.tab.AuthenticatorNavigationInterceptor; |
88 import org.chromium.chrome.browser.tab.Tab; | 86 import org.chromium.chrome.browser.tab.Tab; |
89 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 87 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
90 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl; | 88 import org.chromium.chrome.browser.tabmodel.document.ActivityDelegateImpl; |
91 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector; | 89 import org.chromium.chrome.browser.tabmodel.document.DocumentTabModelSelector; |
92 import org.chromium.chrome.browser.tabmodel.document.StorageDelegate; | 90 import org.chromium.chrome.browser.tabmodel.document.StorageDelegate; |
93 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; | 91 import org.chromium.chrome.browser.tabmodel.document.TabDelegate; |
94 import org.chromium.chrome.browser.util.FeatureUtilities; | 92 import org.chromium.chrome.browser.util.FeatureUtilities; |
95 import org.chromium.content.app.ContentApplication; | 93 import org.chromium.content.app.ContentApplication; |
96 import org.chromium.content.browser.BrowserStartupController; | |
97 import org.chromium.content.browser.ChildProcessLauncher; | 94 import org.chromium.content.browser.ChildProcessLauncher; |
98 import org.chromium.content.browser.ContentViewStatics; | 95 import org.chromium.content.browser.ContentViewStatics; |
99 import org.chromium.content.browser.DownloadController; | 96 import org.chromium.content.browser.DownloadController; |
100 import org.chromium.policy.AppRestrictionsProvider; | 97 import org.chromium.policy.AppRestrictionsProvider; |
101 import org.chromium.policy.CombinedPolicyProvider; | 98 import org.chromium.policy.CombinedPolicyProvider; |
102 import org.chromium.policy.CombinedPolicyProvider.PolicyChangeListener; | 99 import org.chromium.policy.CombinedPolicyProvider.PolicyChangeListener; |
103 import org.chromium.printing.PrintingController; | 100 import org.chromium.printing.PrintingController; |
104 import org.chromium.sync.signin.AccountManagerDelegate; | 101 import org.chromium.sync.signin.AccountManagerDelegate; |
105 import org.chromium.sync.signin.AccountManagerHelper; | 102 import org.chromium.sync.signin.AccountManagerHelper; |
106 import org.chromium.sync.signin.SystemAccountManagerDelegate; | 103 import org.chromium.sync.signin.SystemAccountManagerDelegate; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 480 |
484 PrefServiceBridge.getInstance().migratePreferences(this); | 481 PrefServiceBridge.getInstance().migratePreferences(this); |
485 } | 482 } |
486 | 483 |
487 @Override | 484 @Override |
488 public void initCommandLine() { | 485 public void initCommandLine() { |
489 CommandLineInitUtil.initCommandLine(this, COMMAND_LINE_FILE); | 486 CommandLineInitUtil.initCommandLine(this, COMMAND_LINE_FILE); |
490 } | 487 } |
491 | 488 |
492 /** | 489 /** |
493 * Start the browser process asynchronously. This will set up a queue of UI | |
494 * thread tasks to initialize the browser process. | |
495 * | |
496 * Note that this can only be called on the UI thread. | |
497 * | |
498 * @param callback the callback to be called when browser startup is complet
e. | |
499 * @throws ProcessInitException | |
500 */ | |
501 public void startChromeBrowserProcessesAsync(BrowserStartupController.Startu
pCallback callback) | |
502 throws ProcessInitException { | |
503 assert ThreadUtils.runningOnUiThread() : "Tried to start the browser on
the wrong thread"; | |
504 // The policies are used by browser startup, so we need to register the
policy providers | |
505 // before starting the browser process. | |
506 registerPolicyProviders(CombinedPolicyProvider.get()); | |
507 Context applicationContext = getApplicationContext(); | |
508 BrowserStartupController.get(applicationContext, LibraryProcessType.PROC
ESS_BROWSER) | |
509 .startBrowserProcessesAsync(callback); | |
510 } | |
511 | |
512 /** | |
513 * Loads native Libraries synchronously and starts Chrome browser processes. | |
514 * Must be called on the main thread. Makes sure the process is initialized
as a | |
515 * Browser process instead of a ContentView process. | |
516 * | |
517 * @param initGoogleServicesManager when true the GoogleServicesManager is i
nitialized. | |
518 */ | |
519 public void startBrowserProcessesAndLoadLibrariesSync(boolean initGoogleServ
icesManager) | |
520 throws ProcessInitException { | |
521 ThreadUtils.assertOnUiThread(); | |
522 initCommandLine(); | |
523 Context context = getApplicationContext(); | |
524 LibraryLoader libraryLoader = LibraryLoader.get(LibraryProcessType.PROCE
SS_BROWSER); | |
525 libraryLoader.ensureInitialized(context); | |
526 libraryLoader.asyncPrefetchLibrariesToMemory(); | |
527 // The policies are used by browser startup, so we need to register the
policy providers | |
528 // before starting the browser process. | |
529 registerPolicyProviders(CombinedPolicyProvider.get()); | |
530 BrowserStartupController.get(context, LibraryProcessType.PROCESS_BROWSER
) | |
531 .startBrowserProcessesSync(false); | |
532 if (initGoogleServicesManager) { | |
533 GoogleServicesManager.get(getApplicationContext()); | |
534 } | |
535 } | |
536 | |
537 /** | |
538 * Shows an error dialog following a startup error, and then exits the appli
cation. | 490 * Shows an error dialog following a startup error, and then exits the appli
cation. |
539 * @param e The exception reported by Chrome initialization. | 491 * @param e The exception reported by Chrome initialization. |
540 */ | 492 */ |
541 public static void reportStartupErrorAndExit(final ProcessInitException e) { | 493 public static void reportStartupErrorAndExit(final ProcessInitException e) { |
542 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); | 494 Activity activity = ApplicationStatus.getLastTrackedFocusedActivity(); |
543 if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DES
TROYED) { | 495 if (ApplicationStatus.getStateForActivity(activity) == ActivityState.DES
TROYED) { |
544 return; | 496 return; |
545 } | 497 } |
546 InvalidStartupDialog.show(activity, e.getErrorCode()); | 498 InvalidStartupDialog.show(activity, e.getErrorCode()); |
547 } | 499 } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 public GSAHelper createGsaHelper() { | 682 public GSAHelper createGsaHelper() { |
731 return new GSAHelper(); | 683 return new GSAHelper(); |
732 } | 684 } |
733 | 685 |
734 /** | 686 /** |
735 * Registers various policy providers with the policy manager. | 687 * Registers various policy providers with the policy manager. |
736 * Providers are registered in increasing order of precedence so overrides s
hould call this | 688 * Providers are registered in increasing order of precedence so overrides s
hould call this |
737 * method in the end for this method to maintain the highest precedence. | 689 * method in the end for this method to maintain the highest precedence. |
738 * @param combinedProvider The {@link CombinedPolicyProvider} to register th
e providers with. | 690 * @param combinedProvider The {@link CombinedPolicyProvider} to register th
e providers with. |
739 */ | 691 */ |
740 protected void registerPolicyProviders(CombinedPolicyProvider combinedProvid
er) { | 692 public void registerPolicyProviders(CombinedPolicyProvider combinedProvider)
{ |
741 combinedProvider.registerProvider(new AppRestrictionsProvider(getApplica
tionContext())); | 693 combinedProvider.registerProvider(new AppRestrictionsProvider(getApplica
tionContext())); |
742 } | 694 } |
743 | 695 |
744 /** | 696 /** |
745 * Add a listener to be notified upon policy changes. | 697 * Add a listener to be notified upon policy changes. |
746 */ | 698 */ |
747 public void addPolicyChangeListener(PolicyChangeListener listener) { | 699 public void addPolicyChangeListener(PolicyChangeListener listener) { |
748 CombinedPolicyProvider.get().addPolicyChangeListener(listener); | 700 CombinedPolicyProvider.get().addPolicyChangeListener(listener); |
749 } | 701 } |
750 | 702 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 */ | 862 */ |
911 private void updatePasswordEchoState() { | 863 private void updatePasswordEchoState() { |
912 boolean systemEnabled = Settings.System.getInt( | 864 boolean systemEnabled = Settings.System.getInt( |
913 getApplicationContext().getContentResolver(), | 865 getApplicationContext().getContentResolver(), |
914 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; | 866 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; |
915 if (PrefServiceBridge.getInstance().getPasswordEchoEnabled() == systemEn
abled) return; | 867 if (PrefServiceBridge.getInstance().getPasswordEchoEnabled() == systemEn
abled) return; |
916 | 868 |
917 PrefServiceBridge.getInstance().setPasswordEchoEnabled(systemEnabled); | 869 PrefServiceBridge.getInstance().setPasswordEchoEnabled(systemEnabled); |
918 } | 870 } |
919 } | 871 } |
OLD | NEW |