summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 20:50:34 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 20:50:34 +0000
commit34f73fbb389c0e4555b2ab0f03748f95ea1c02fe (patch)
treefbabfee1eccb58d2cf4cb7314c97709c5a752d20 /chrome
parent0209eacee2b017cf5bd3aa9cf01153bae7c5db3e (diff)
downloadchromium_src-34f73fbb389c0e4555b2ab0f03748f95ea1c02fe.zip
chromium_src-34f73fbb389c0e4555b2ab0f03748f95ea1c02fe.tar.gz
chromium_src-34f73fbb389c0e4555b2ab0f03748f95ea1c02fe.tar.bz2
Do some browser_main cleanup. This moves ChromeOS login manager and some first
run UI stuff to new helper functions. It renames CheckForWin2000 to a generic one that each platform can implement according to its needs. I removed the Platform namespace which was improperly named, and didn't seem to be helping anything anyway. TEST=none BUG=none Review URL: http://codereview.chromium.org/1139009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42528 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_main.cc93
-rw-r--r--chrome/browser/browser_main.h8
-rw-r--r--chrome/browser/browser_main_gtk.cc10
-rw-r--r--chrome/browser/browser_main_mac.mm12
-rw-r--r--chrome/browser/browser_main_win.cc13
-rw-r--r--chrome/browser/browser_main_win.h4
-rw-r--r--chrome/browser/browser_process_impl.cc2
7 files changed, 64 insertions, 78 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 4cc4d91..087ca63 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -363,6 +363,16 @@ void InitializeNetworkOptions(const CommandLine& parsed_command_line) {
}
}
+// Creates key child threads. We need to do this explicitly since
+// ChromeThread::PostTask silently deletes a posted task if the target message
+// loop isn't created.
+void CreateChildThreads(BrowserProcessImpl* process) {
+ process->db_thread();
+ process->file_thread();
+ process->process_launcher_thread();
+ process->io_thread();
+}
+
// Returns the new local state object, guaranteed non-NULL.
PrefService* InitializeLocalState(const CommandLine& parsed_command_line,
bool is_first_run) {
@@ -454,6 +464,32 @@ void InitializeToolkit() {
}
#endif
+#if defined(OS_CHROMEOS)
+void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line) {
+ if (parsed_command_line.HasSwitch(switches::kLoginManager)) {
+ std::string first_screen =
+ parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen);
+ std::string size_arg =
+ parsed_command_line.GetSwitchValueASCII(
+ switches::kLoginScreenSize);
+ gfx::Size size(0, 0);
+ // Allow the size of the login window to be set explicitly. If not set,
+ // default to the entire screen. This is mostly useful for testing.
+ if (size_arg.size()) {
+ std::vector<std::string> dimensions;
+ SplitString(size_arg, ',', &dimensions);
+ if (dimensions.size() == 2)
+ size.SetSize(StringToInt(dimensions[0]), StringToInt(dimensions[1]));
+ }
+ browser::ShowLoginWizard(first_screen, size);
+ }
+}
+#else
+void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line) {
+ // Dummy empty function for non-ChromeOS builds to avoid extra ifdefs below.
+}
+#endif
+
} // namespace
// Main routine for running as the Browser process.
@@ -533,7 +569,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
// Do platform-specific things (such as finishing initializing Cocoa)
// prior to instantiating the message loop. This could be turned into a
// broadcast notification.
- Platform::WillInitializeMainMessageLoop(parameters);
+ WillInitializeMainMessageLoop(parameters);
MessageLoop main_message_loop(MessageLoop::TYPE_UI);
@@ -656,7 +692,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
if (parameters.ui_task) {
g_browser_process->SetApplicationLocale("en-US");
} else {
- // Mac starts it earlier in Platform::WillInitializeMainMessageLoop (because
+ // Mac starts it earlier in WillInitializeMainMessageLoop (because
// it is needed when loading the MainMenu.nib and the language doesn't
// depend on anything since it comes from Cocoa.
#if defined(OS_MACOSX)
@@ -690,34 +726,27 @@ int BrowserMain(const MainFunctionParams& parameters) {
BrowserInit browser_init;
+ // On first run, we need to process the master preferences before the
+ // browser's profile_manager object is created, but after ResourceBundle
+ // is initialized.
FirstRun::MasterPrefs master_prefs = {0};
- bool first_run_ui_bypass = false;
+ bool first_run_ui_bypass = false; // True to skip first run UI.
if (is_first_run) {
- // On first run, we need to process the master preferences before the
- // browser's profile_manager object is created, but after ResourceBundle
- // is initialized.
first_run_ui_bypass =
!FirstRun::ProcessMasterPreferences(user_data_dir,
FilePath(), &master_prefs);
- // The master prefs might specify a set of urls to display.
- if (master_prefs.new_tabs.size())
- AddFirstRunNewTabs(&browser_init, master_prefs.new_tabs);
+ AddFirstRunNewTabs(&browser_init, master_prefs.new_tabs);
// If we are running in App mode, we do not want to show the importer
// (first run) UI.
if (!first_run_ui_bypass &&
(parsed_command_line.HasSwitch(switches::kApp) ||
- parsed_command_line.HasSwitch(switches::kNoFirstRun))) {
+ parsed_command_line.HasSwitch(switches::kNoFirstRun)))
first_run_ui_bypass = true;
- }
}
- if (!parsed_command_line.HasSwitch(switches::kNoErrorDialogs)) {
- // Display a warning if the user is running windows 2000.
- // TODO(port): We should probably change this to a "check for minimum
- // requirements" function, implemented by each platform.
- CheckForWin2000();
- }
+ if (!parsed_command_line.HasSwitch(switches::kNoErrorDialogs))
+ WarnAboutMinimumSystemRequirements();
InitializeNetworkOptions(parsed_command_line);
@@ -747,12 +776,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
base::Time::Now().ToTimeT());
}
- // Create the child threads. We need to do this since ChromeThread::PostTask
- // silently deletes a posted task if the target message loop isn't created.
- browser_process->db_thread();
- browser_process->file_thread();
- browser_process->process_launcher_thread();
- browser_process->io_thread();
+ CreateChildThreads(browser_process.get());
#if defined(OS_WIN)
// Record last shutdown time into a histogram.
@@ -827,26 +851,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
PrefService* user_prefs = profile->GetPrefs();
DCHECK(user_prefs);
-#if defined(OS_CHROMEOS)
- if (parsed_command_line.HasSwitch(switches::kLoginManager)) {
- std::string first_screen =
- parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen);
- std::string size_arg =
- parsed_command_line.GetSwitchValueASCII(
- switches::kLoginScreenSize);
- gfx::Size size(0, 0);
- // Allow the size of the login window to be set explicitly. If not set,
- // default to the entire screen. This is mostly useful for testing.
- if (size_arg.size()) {
- std::vector<std::string> dimensions;
- SplitString(size_arg, ',', &dimensions);
- if (dimensions.size() == 2) {
- size.SetSize(StringToInt(dimensions[0]), StringToInt(dimensions[1]));
- }
- }
- browser::ShowLoginWizard(first_screen, size);
- }
-#endif // OS_CHROMEOS
+ OptionallyRunChromeOSLoginManager(parsed_command_line);
// Importing other browser settings is done in a browser-like process
// that exits when this task has finished.
@@ -1046,7 +1051,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
#endif
HandleTestParameters(parsed_command_line);
- Platform::RecordBreakpadStatusUMA(metrics);
+ RecordBreakpadStatusUMA(metrics);
// Stat the directory with the inspector's files so that we can know if we
// should display the entry in the context menu or not.
diff --git a/chrome/browser/browser_main.h b/chrome/browser/browser_main.h
index 44bc6ab..a9a5561 100644
--- a/chrome/browser/browser_main.h
+++ b/chrome/browser/browser_main.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,8 +10,6 @@
struct MainFunctionParams;
class MetricsService;
-namespace Platform {
-
// Perform platform-specific work that needs to be done before the main
// message loop is created, initialized, and entered.
void WillInitializeMainMessageLoop(const MainFunctionParams& parameters);
@@ -26,6 +24,8 @@ void DidEndMainMessageLoop();
// are registered with the UMA metrics service.
void RecordBreakpadStatusUMA(MetricsService* metrics);
-} // namespace Platform
+// Displays a warning message if some minimum level of OS support is not
+// present on the current platform.
+void WarnAboutMinimumSystemRequirements();
#endif // CHROME_BROWSER_BROWSER_MAIN_H_
diff --git a/chrome/browser/browser_main_gtk.cc b/chrome/browser/browser_main_gtk.cc
index e27fe0b..1b7006a 100644
--- a/chrome/browser/browser_main_gtk.cc
+++ b/chrome/browser/browser_main_gtk.cc
@@ -14,8 +14,6 @@
#include "chrome/app/breakpad_linux.h"
#endif
-namespace Platform {
-
void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) {
}
@@ -31,7 +29,9 @@ void RecordBreakpadStatusUMA(MetricsService* metrics) {
metrics->RecordBreakpadHasDebugger(DebugUtil::BeingDebugged());
}
-} // namespace Platform
+void WarnAboutMinimumSystemRequirements() {
+ // Nothing to warn about on GTK right now.
+}
// From browser_main_win.h, stubs until we figure out the right thing...
@@ -43,10 +43,6 @@ bool DoUpgradeTasks(const CommandLine& command_line) {
return ResultCodes::NORMAL_EXIT;
}
-bool CheckForWin2000() {
- return false;
-}
-
int HandleIconsCommands(const CommandLine &parsed_command_line) {
return 0;
}
diff --git a/chrome/browser/browser_main_mac.mm b/chrome/browser/browser_main_mac.mm
index 7163618..38d3395 100644
--- a/chrome/browser/browser_main_mac.mm
+++ b/chrome/browser/browser_main_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -21,8 +21,6 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/result_codes.h"
-namespace Platform {
-
// Tell Cooca to finish its initalization, which we want to do manually
// instead of calling NSApplicationMain(). The primary reason is that NSAM()
// never returns, which would leave all the objects currently on the stack
@@ -71,7 +69,9 @@ void RecordBreakpadStatusUMA(MetricsService* metrics) {
metrics->RecordBreakpadHasDebugger(DebugUtil::BeingDebugged());
}
-} // namespace Platform
+void WarnAboutMinimumSystemRequirements() {
+ // Nothing to check for on Mac right now.
+}
// From browser_main_win.h, stubs until we figure out the right thing...
@@ -83,10 +83,6 @@ bool DoUpgradeTasks(const CommandLine& command_line) {
return false;
}
-bool CheckForWin2000() {
- return false;
-}
-
int HandleIconsCommands(const CommandLine& parsed_command_line) {
return 0;
}
diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc
index 833807a..8fba8c3 100644
--- a/chrome/browser/browser_main_win.cc
+++ b/chrome/browser/browser_main_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -29,8 +29,6 @@
#include "views/focus/accelerator_handler.h"
#include "views/window/window.h"
-namespace Platform {
-
void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) {
OleInitialize(NULL);
}
@@ -45,19 +43,14 @@ void RecordBreakpadStatusUMA(MetricsService* metrics) {
metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent());
}
-} // namespace Platform
-
-// Displays a warning message if the user is running chrome on windows 2000.
-// Returns true if the OS is win2000, false otherwise.
-bool CheckForWin2000() {
+void WarnAboutMinimumSystemRequirements() {
if (win_util::GetWinVersion() == win_util::WINVERSION_2000) {
+ // Display a warning message if the user is running chrome on Windows 2000.
const std::wstring text = l10n_util::GetString(IDS_UNSUPPORTED_OS_WIN2000);
const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME);
win_util::MessageBox(NULL, text, caption,
MB_OK | MB_ICONWARNING | MB_TOPMOST);
- return true;
}
- return false;
}
int AskForUninstallConfirmation() {
diff --git a/chrome/browser/browser_main_win.h b/chrome/browser/browser_main_win.h
index 4b8636a..45bfbf63 100644
--- a/chrome/browser/browser_main_win.h
+++ b/chrome/browser/browser_main_win.h
@@ -10,10 +10,6 @@
class CommandLine;
class MetricsService;
-// Displays a warning message if the user is running chrome on windows 2000.
-// Returns true if the OS is win2000, false otherwise.
-bool CheckForWin2000();
-
// Handle uninstallation when given the appropriate the command-line switch.
// If |chrome_still_running| is true a modal dialog will be shown asking the
// user to close the other chrome instance.
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index cf25fb6..30f0b24 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -202,7 +202,7 @@ unsigned int BrowserProcessImpl::ReleaseModule() {
module_ref_count_--;
if (0 == module_ref_count_) {
MessageLoop::current()->PostTask(
- FROM_HERE, NewRunnableFunction(Platform::DidEndMainMessageLoop));
+ FROM_HERE, NewRunnableFunction(DidEndMainMessageLoop));
MessageLoop::current()->Quit();
}
return module_ref_count_;