Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Unified Diff: chrome/browser/chrome_browser_main.cc

Issue 8480032: Add ChromeBrowserMainExtraParts for non main parts. (take 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chrome_browser_main_extra_parts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_main.cc
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 8ba3c3ef15ed5e035dfa228c0819a9c022c7f834..f8a5d8bcd67a201f0b77766fe28dd2a1be08a453 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -32,6 +32,7 @@
#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"
@@ -558,13 +559,6 @@ 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)
@@ -685,6 +679,9 @@ 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
@@ -1166,23 +1163,38 @@ 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() {
@@ -1496,6 +1508,10 @@ 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)
@@ -1561,6 +1577,11 @@ 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)
@@ -1609,6 +1630,11 @@ 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
@@ -1834,20 +1860,6 @@ 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;
-
- // 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)
@@ -1917,18 +1929,13 @@ void ChromeBrowserMainParts::StartBrowserOrUITask() {
}
}
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.
@@ -2050,8 +2057,19 @@ 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);
« no previous file with comments | « chrome/browser/chrome_browser_main.h ('k') | chrome/browser/chrome_browser_main_extra_parts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698