| Index: chrome/browser/chrome_browser_main.cc
|
| diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
|
| index 712376df70db17431f3d22ba8598f3c713654b7e..ab2b807298bf7ffbff46d8103dc8639f3b0c8906 100644
|
| --- a/chrome/browser/chrome_browser_main.cc
|
| +++ b/chrome/browser/chrome_browser_main.cc
|
| @@ -32,7 +32,6 @@
|
| #include "chrome/browser/background/background_mode_manager.h"
|
| #include "chrome/browser/browser_process_impl.h"
|
| #include "chrome/browser/browser_shutdown.h"
|
| -#include "chrome/browser/chrome_browser_main_extra_parts.h"
|
| #include "chrome/browser/defaults.h"
|
| #include "chrome/browser/extensions/default_apps_trial.h"
|
| #include "chrome/browser/extensions/extension_protocols.h"
|
| @@ -559,6 +558,13 @@ void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line,
|
| }
|
| }
|
|
|
| +#else
|
| +
|
| +void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line,
|
| + Profile* profile) {
|
| + // Dummy empty function for non-ChromeOS builds to avoid extra ifdefs below.
|
| +}
|
| +
|
| #endif // defined(OS_CHROMEOS)
|
|
|
| #if defined(OS_MACOSX)
|
| @@ -679,9 +685,6 @@ ChromeBrowserMainParts::ChromeBrowserMainParts(
|
| }
|
|
|
| ChromeBrowserMainParts::~ChromeBrowserMainParts() {
|
| - for (int i = static_cast<int>(chrome_extra_parts_.size())-1; i >= 0; --i)
|
| - delete chrome_extra_parts_[i];
|
| - chrome_extra_parts_.clear();
|
| }
|
|
|
| // This will be called after the command-line has been mutated by about:flags
|
| @@ -1163,38 +1166,23 @@ DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
|
| }
|
| #endif
|
|
|
| -// content::BrowserMainParts implementation ------------------------------------
|
| -
|
| void ChromeBrowserMainParts::PreEarlyInitialization() {
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PreEarlyInitialization();
|
| }
|
|
|
| void ChromeBrowserMainParts::PostEarlyInitialization() {
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PostEarlyInitialization();
|
| }
|
|
|
| void ChromeBrowserMainParts::ToolkitInitialized() {
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->ToolkitInitialized();
|
| }
|
|
|
| void ChromeBrowserMainParts::PreMainMessageLoopStart() {
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PreMainMessageLoopStart();
|
| }
|
|
|
| void ChromeBrowserMainParts::PostMainMessageLoopStart() {
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PostMainMessageLoopStart();
|
| }
|
|
|
| void ChromeBrowserMainParts::PreMainMessageLoopRun() {
|
| result_code_ = PreMainMessageLoopRunImpl();
|
| -
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PreMainMessageLoopRun();
|
| }
|
|
|
| int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| @@ -1517,10 +1505,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| SetBrowserX11ErrorHandlers();
|
| #endif
|
|
|
| - // Desktop construction occurs here, (required before profile creation).
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PostBrowserProcessInit();
|
| -
|
| // Profile creation ----------------------------------------------------------
|
|
|
| #if defined(OS_CHROMEOS)
|
| @@ -1586,11 +1570,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| g_browser_process->browser_policy_connector()->SetUserPolicyTokenService(
|
| profile_->GetTokenService());
|
| }
|
| -
|
| - // Tests should be able to tune login manager before showing it.
|
| - // Thus only show login manager in normal (non-testing) mode.
|
| - if (!parameters().ui_task)
|
| - OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_);
|
| #endif
|
|
|
| #if !defined(OS_MACOSX)
|
| @@ -1639,11 +1618,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| }
|
| #endif
|
|
|
| - // TODO(stevenjb): Move ChromeOS login code into PostProfileInitialized().
|
| - // (Requires making ChromeBrowserMainPartsChromeos a non "main" Parts).
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PostProfileInitialized();
|
| -
|
| // Show the First Run UI if this is the first time Chrome has been run on
|
| // this computer, or we're being compelled to do so by a command line flag.
|
| // Note that this be done _after_ the PrefService is initialized and all
|
| @@ -1869,6 +1843,25 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| NaClProcessHost::EarlyStartup();
|
| #endif
|
|
|
| + run_message_loop_ = true;
|
| + return content::RESULT_CODE_NORMAL_EXIT;
|
| +}
|
| +
|
| +// Called from MainMessageLoopRun().
|
| +void ChromeBrowserMainParts::StartBrowserOrUITask() {
|
| + // Still initializing, so need to allow IO.
|
| + base::ThreadRestrictions::ScopedAllowIO allow_io;
|
| +
|
| + // Set the notification UI manager after any desktop initialization in
|
| + // PreMainMessageLoopRun() is complete, and before starting the browser.
|
| + DesktopNotificationServiceFactory::GetForProfile(profile_)->SetUIManager(
|
| + g_browser_process->notification_ui_manager());
|
| +
|
| + // Tests should be able to tune login manager before showing it.
|
| + // Thus only show login manager in normal (non-testing) mode.
|
| + if (!parameters().ui_task)
|
| + OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_);
|
| +
|
| if (parameters().ui_task) {
|
| // We are in test mode. Run one task and enter the main message loop.
|
| #if defined(OS_MACOSX)
|
| @@ -1938,13 +1931,18 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
|
| }
|
| }
|
| browser_init_.reset();
|
| - return result_code_;
|
| }
|
|
|
| bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) {
|
| // Set the result code set in PreMainMessageLoopRun or set above.
|
| *result_code = result_code_;
|
|
|
| + // TODO(stevenjb): Move this to another phase, and/or clean up
|
| + // PreMainMessageLoopRun() so that this can happen after desktop
|
| + // initilaization and before running the main loop.
|
| + if (run_message_loop_)
|
| + StartBrowserOrUITask();
|
| +
|
| if (!run_message_loop_)
|
| return true; // Don't run the default message loop.
|
|
|
| @@ -2066,19 +2064,8 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() {
|
| // to bypass this code. Perhaps we need a *final* hook that is called on all
|
| // paths from content/browser/browser_main.
|
| CHECK(MetricsService::UmaMetricsProperlyShutdown());
|
| -
|
| - for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
|
| - chrome_extra_parts_[i]->PostMainMessageLoopRun();
|
| }
|
|
|
| -// Public members:
|
| -
|
| -void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
|
| - chrome_extra_parts_.push_back(parts);
|
| -}
|
| -
|
| -// Misc ------------------------------------------------------------------------
|
| -
|
| // This code is specific to the Windows-only PreReadExperiment field-trial.
|
| void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) {
|
| DCHECK(name != NULL);
|
|
|