diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 18:00:51 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 18:00:51 +0000 |
commit | e8b6ca09daa38e93c9f613c99a90e295ed3511ae (patch) | |
tree | 928c23584998f720ce1639b822e3c5622b7e8c37 | |
parent | f5f534be197fb1cfa2fb0e719e38a8cdb18a6c41 (diff) | |
download | chromium_src-e8b6ca09daa38e93c9f613c99a90e295ed3511ae.zip chromium_src-e8b6ca09daa38e93c9f613c99a90e295ed3511ae.tar.gz chromium_src-e8b6ca09daa38e93c9f613c99a90e295ed3511ae.tar.bz2 |
Small cleanup for ChromeBrowserMain:
-add ChromeBrowserMainExtraPartsX11 to get rid of the x11 specific calls in ChromeBrowserMain that are right beside ChromeBrowserMainExtraParts calls
-move win specific stuff out of ChromeBrowserMain and into ChromeBrowserMainWin
-remove the static methods in chrome_browser_main.h in favor of private methods in chrome_browser_main.h
-remove the unnecessary toolkit_extra_parts.h header, it doesn't help much since each method was named differently anyways
R=thakis@chromium.org
Review URL: https://codereview.chromium.org/18967002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210884 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 210 insertions, 296 deletions
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS index 7e794a6..4fa3b42 100644 --- a/chrome/browser/DEPS +++ b/chrome/browser/DEPS @@ -70,6 +70,8 @@ include_rules = [ # DO NOT ADD ANY MORE ITEMS TO THE ABOVE LIST! "-chrome/browser/ui/views", + "+chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h", + "+chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h", # Other libraries. "+chrome/third_party/mozilla_security_manager", diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 7fd6c59..9595056 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -14,6 +14,7 @@ #include "base/at_exit.h" #include "base/bind.h" #include "base/command_line.h" +#include "base/debug/debugger.h" #include "base/debug/trace_event.h" #include "base/file_util.h" #include "base/files/file_path.h" @@ -89,10 +90,6 @@ #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/renderer_host/chrome_render_view_host_observer.h" #include "chrome/browser/search_engines/search_engine_type.h" -#include "chrome/browser/search_engines/template_url.h" -#include "chrome/browser/search_engines/template_url_prepopulate_data.h" -#include "chrome/browser/search_engines/template_url_service.h" -#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/service/service_process_control.h" #include "chrome/browser/shell_integration.h" #include "chrome/browser/three_d_api_observer.h" @@ -202,10 +199,6 @@ #include "ui/views/focus/accelerator_handler.h" #endif -#if defined(USE_X11) -#include "chrome/browser/chrome_browser_main_x11.h" -#endif - using content::BrowserThread; namespace { @@ -560,7 +553,6 @@ ChromeBrowserMainParts::ChromeBrowserMainParts( startup_timer_(new performance_monitor::StartupTimer()), browser_field_trials_(parameters.command_line), rvh_callback_(base::Bind(&RenderViewHostCreated)), - record_search_engine_(false), translate_manager_(NULL), profile_(NULL), run_message_loop_(true), @@ -696,6 +688,65 @@ bool ChromeBrowserMainParts::IsMetricsReportingEnabled() { return enabled; } +void ChromeBrowserMainParts::RecordBrowserStartupTime(bool is_first_run) { + // Don't record any metrics if UI was displayed before this point e.g. + // warning dialogs. + if (startup_metric_utils::WasNonBrowserUIDisplayed()) + return; + +// CurrentProcessInfo::CreationTime() is currently only implemented on Mac and +// Windows. +#if defined(OS_MACOSX) || defined(OS_WIN) + const base::Time* process_creation_time = + base::CurrentProcessInfo::CreationTime(); + + if (!is_first_run && process_creation_time) { + RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", + base::Time::Now() - *process_creation_time); + } +#endif // defined(OS_MACOSX) || defined(OS_WIN) + + // Record collected startup metrics. + startup_metric_utils::OnBrowserStartupComplete(is_first_run); + + // Deletes self. + new LoadCompleteListener(); +} + +// This code is specific to the Windows-only PreReadExperiment field-trial. +void ChromeBrowserMainParts::RecordPreReadExperimentTime(const char* name, + base::TimeDelta time) { + DCHECK(name != NULL); + + // This gets called with different histogram names, so we don't want to use + // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the + // first call wins. + AddPreReadHistogramTime(name, time); + +#if defined(OS_WIN) +#if defined(GOOGLE_CHROME_BUILD) + // The pre-read experiment is Windows and Google Chrome specific. + scoped_ptr<base::Environment> env(base::Environment::Create()); + + // Only record the sub-histogram result if the experiment is running + // (environment variable is set, and valid). + std::string pre_read_percentage; + if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { + std::string uma_name(name); + + // We want XP to record a separate histogram, as the loader on XP + // is very different from the Vista and Win7 loaders. + if (base::win::GetVersion() <= base::win::VERSION_XP) + uma_name += "_XP"; + + uma_name += "_PreRead_"; + uma_name += pre_read_percentage; + AddPreReadHistogramTime(uma_name.c_str(), time); + } +#endif +#endif +} + // ----------------------------------------------------------------------------- // TODO(viettrungluu): move more/rest of BrowserMain() into BrowserMainParts. @@ -719,9 +770,6 @@ DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { // content::BrowserMainParts implementation ------------------------------------ void ChromeBrowserMainParts::PreEarlyInitialization() { -#if defined(USE_X11) - SetBrowserX11ErrorHandlersPreEarlyInitialization(); -#endif TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreEarlyInitialization"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PreEarlyInitialization(); @@ -749,9 +797,6 @@ void ChromeBrowserMainParts::PostMainMessageLoopStart() { TRACE_EVENT0("startup", "ChromeBrowserMainParts::PostMainMessageLoopStart"); for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PostMainMessageLoopStart(); -#if defined(USE_X11) - SetBrowserX11ErrorHandlersPostMainMessageLoopStart(); -#endif } int ChromeBrowserMainParts::PreCreateThreads() { @@ -982,10 +1027,6 @@ int ChromeBrowserMainParts::PreCreateThreadsImpl() { } #endif - // TODO(viettrungluu): why don't we run this earlier? - if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) - WarnAboutMinimumSystemRequirements(); - #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) // Set the product channel for crash reports. child_process_logging::SetChannel( @@ -1430,7 +1471,9 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { #endif HandleTestParameters(parsed_command_line()); - RecordBreakpadStatusUMA(browser_process_->metrics_service()); + browser_process_->metrics_service()->RecordBreakpadHasDebugger( + base::debug::BeingDebugged()); + #if defined(ENABLE_LANGUAGE_DETECTION) LanguageUsageMetrics::RecordAcceptLanguages( profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); @@ -1462,12 +1505,6 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { MetricsService::LogNeedForCleanShutdown(); #endif -#if defined(OS_WIN) - // We check this here because if the profile is OTR (chromeos possibility) - // it won't still be accessible after browser is destroyed. - record_search_engine_ = do_first_run_tasks_ && !profile_->IsOffTheRecord(); -#endif - // Create the instance of the cloud print proxy service so that it can launch // the service process if needed. This is needed because the service process // might have shutdown because an update was available. @@ -1645,13 +1682,6 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() { NOTREACHED(); #else -#if defined(USE_X11) - // Unset the X11 error handlers. The X11 error handlers log the errors using a - // |PostTask()| on the message-loop. But since the message-loop is in the - // process of terminating, this can cause errors. - UnsetBrowserX11ErrorHandlers(); -#endif - // Start watching for jank during shutdown. It gets disarmed when // |shutdown_watcher_| object is destructed. shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300)); @@ -1662,25 +1692,6 @@ void ChromeBrowserMainParts::PostMainMessageLoopRun() { for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) chrome_extra_parts_[i]->PostMainMessageLoopRun(); -#if defined(OS_WIN) - // Log the search engine chosen on first run. Do this at shutdown, after any - // changes are made from the first run bubble link, etc. - if (record_search_engine_) { - TemplateURLService* url_service = - TemplateURLServiceFactory::GetForProfile(profile_); - const TemplateURL* default_search_engine = - url_service->GetDefaultSearchProvider(); - // The default engine can be NULL if the administrator has disabled - // default search. - SearchEngineType search_engine_type = - TemplateURLPrepopulateData::GetEngineType(default_search_engine ? - default_search_engine->url() : std::string()); - // Record the search engine chosen. - UMA_HISTOGRAM_ENUMERATION("Chrome.SearchSelectExempt", search_engine_type, - SEARCH_ENGINE_MAX); - } -#endif - // Some tests don't set parameters.ui_task, so they started translate // language fetch that was never completed so we need to cleanup here // otherwise it will be done by the destructor in a wrong thread. @@ -1732,63 +1743,3 @@ void ChromeBrowserMainParts::PostDestroyThreads() { void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { chrome_extra_parts_.push_back(parts); } - -// Misc ------------------------------------------------------------------------ - -void RecordBrowserStartupTime(bool is_first_run) { - // Don't record any metrics if UI was displayed before this point e.g. - // warning dialogs. - if (startup_metric_utils::WasNonBrowserUIDisplayed()) - return; - -// CurrentProcessInfo::CreationTime() is currently only implemented on Mac and -// Windows. -#if defined(OS_MACOSX) || defined(OS_WIN) - const base::Time* process_creation_time = - base::CurrentProcessInfo::CreationTime(); - - if (!is_first_run && process_creation_time) { - RecordPreReadExperimentTime("Startup.BrowserMessageLoopStartTime", - base::Time::Now() - *process_creation_time); - } -#endif // defined(OS_MACOSX) || defined(OS_WIN) - - // Record collected startup metrics. - startup_metric_utils::OnBrowserStartupComplete(is_first_run); - - // Deletes self. - new LoadCompleteListener(); -} - -// This code is specific to the Windows-only PreReadExperiment field-trial. -void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { - DCHECK(name != NULL); - - // This gets called with different histogram names, so we don't want to use - // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the - // first call wins. - AddPreReadHistogramTime(name, time); - -#if defined(OS_WIN) -#if defined(GOOGLE_CHROME_BUILD) - // The pre-read experiment is Windows and Google Chrome specific. - scoped_ptr<base::Environment> env(base::Environment::Create()); - - // Only record the sub-histogram result if the experiment is running - // (environment variable is set, and valid). - std::string pre_read_percentage; - if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read_percentage)) { - std::string uma_name(name); - - // We want XP to record a separate histogram, as the loader on XP - // is very different from the Vista and Win7 loaders. - if (base::win::GetVersion() <= base::win::VERSION_XP) - uma_name += "_XP"; - - uma_name += "_PreRead_"; - uma_name += pre_read_percentage; - AddPreReadHistogramTime(uma_name.c_str(), time); - } -#endif -#endif -} diff --git a/chrome/browser/chrome_browser_main.h b/chrome/browser/chrome_browser_main.h index 067a616..0e092e4 100644 --- a/chrome/browser/chrome_browser_main.h +++ b/chrome/browser/chrome_browser_main.h @@ -101,6 +101,7 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { } Profile* profile() { return profile_; } + bool do_first_run_tasks() const { return do_first_run_tasks_; } const PrefService* local_state() const { return local_state_; } @@ -119,6 +120,15 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { // Returns true if the user opted in to sending metric reports. bool IsMetricsReportingEnabled(); + // Record time from process startup to present time in an UMA histogram. + // |is_first_run| - is the current launch part of a first run. + void RecordBrowserStartupTime(bool is_first_run); + + // Records a time value to an UMA histogram in the context of the + // PreReadExperiment field-trial. This also reports to the appropriate + // sub-histogram (_PreRead(Enabled|Disabled)). + void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); + // Methods for Main Message Loop ------------------------------------------- int PreCreateThreadsImpl(); @@ -174,7 +184,6 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { scoped_ptr<ChromeProcessSingleton> process_singleton_; #endif scoped_ptr<first_run::MasterPrefs> master_prefs_; - bool record_search_engine_; TranslateManager* translate_manager_; Profile* profile_; bool run_message_loop_; @@ -204,23 +213,4 @@ class ChromeBrowserMainParts : public content::BrowserMainParts { DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainParts); }; -// Records the conditions that can prevent Breakpad from generating and -// sending crash reports. The presence of a Breakpad handler (after -// attempting to initialize crash reporting) and the presence of a debugger -// are registered with the UMA metrics service. -void RecordBreakpadStatusUMA(MetricsService* metrics); - -// Displays a warning message if some minimum level of OS support is not -// present on the current platform. -void WarnAboutMinimumSystemRequirements(); - -// Record time from process startup to present time in an UMA histogram. -// |is_first_run| - is the current launch part of a first run. -void RecordBrowserStartupTime(bool is_first_run); - -// Records a time value to an UMA histogram in the context of the -// PreReadExperiment field-trial. This also reports to the appropriate -// sub-histogram (_PreRead(Enabled|Disabled)). -void RecordPreReadExperimentTime(const char* name, base::TimeDelta time); - #endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_H_ diff --git a/chrome/browser/chrome_browser_main_android.cc b/chrome/browser/chrome_browser_main_android.cc index b83a09e..3776811 100644 --- a/chrome/browser/chrome_browser_main_android.cc +++ b/chrome/browser/chrome_browser_main_android.cc @@ -87,11 +87,3 @@ void ChromeBrowserMainPartsAndroid::PreEarlyInitialization() { void ChromeBrowserMainPartsAndroid::ShowMissingLocaleMessageBox() { NOTREACHED(); } - -void RecordBreakpadStatusUMA(MetricsService* metrics) { - // TODO: crbug.com/139023 - NOTIMPLEMENTED(); -} - -void WarnAboutMinimumSystemRequirements() { -} diff --git a/chrome/browser/chrome_browser_main_x11.cc b/chrome/browser/chrome_browser_main_extra_parts_x11.cc index a88981b..9731c17 100644 --- a/chrome/browser/chrome_browser_main_x11.cc +++ b/chrome/browser/chrome_browser_main_extra_parts_x11.cc @@ -2,23 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chrome_browser_main.h" +#include "chrome/browser/chrome_browser_main_extra_parts_x11.h" #include "base/bind.h" #include "base/debug/debugger.h" #include "base/message_loop.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/lifetime/application_lifetime.h" -#include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/chrome_result_codes.h" #include "content/public/browser/browser_thread.h" #include "ui/base/x/x11_util.h" #include "ui/base/x/x11_util_internal.h" -#if defined(USE_LINUX_BREAKPAD) -#include "chrome/app/breakpad_linux.h" -#endif - using content::BrowserThread; namespace { @@ -77,36 +72,29 @@ int X11EmptyIOErrorHandler(Display* d) { } // namespace -void RecordBreakpadStatusUMA(MetricsService* metrics) { -#if defined(USE_LINUX_BREAKPAD) - metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); -#else - metrics->RecordBreakpadRegistration(false); -#endif - metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged()); -} - -void WarnAboutMinimumSystemRequirements() { - // Nothing to warn about on X11 right now. +ChromeBrowserMainExtraPartsX11::ChromeBrowserMainExtraPartsX11() { } -// From browser_main_win.h, stubs until we figure out the right thing... - -int DoUninstallTasks(bool chrome_still_running) { - return content::RESULT_CODE_NORMAL_EXIT; +ChromeBrowserMainExtraPartsX11::~ChromeBrowserMainExtraPartsX11() { } -void SetBrowserX11ErrorHandlersPreEarlyInitialization() { - // Use default error handlers during startup. +void ChromeBrowserMainExtraPartsX11::PreEarlyInitialization() { + // Installs the X11 error handlers for the browser process used during + // startup. They simply print error messages and exit because + // we can't shutdown properly while creating and initializing services. ui::SetX11ErrorHandlers(NULL, NULL); } -void SetBrowserX11ErrorHandlersPostMainMessageLoopStart() { - // Set up error handlers to make sure profile gets written if X server - // goes away. +void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopStart() { + // Installs the X11 error handlers for the browser process after the + // main message loop has started. This will allow us to exit cleanly + // if X exits before us. ui::SetX11ErrorHandlers(BrowserX11ErrorHandler, BrowserX11IOErrorHandler); } -void UnsetBrowserX11ErrorHandlers() { +void ChromeBrowserMainExtraPartsX11::PostMainMessageLoopRun() { + // Unset the X11 error handlers. The X11 error handlers log the errors using a + // |PostTask()| on the message-loop. But since the message-loop is in the + // process of terminating, this can cause errors. ui::SetX11ErrorHandlers(X11EmptyErrorHandler, X11EmptyIOErrorHandler); } diff --git a/chrome/browser/chrome_browser_main_extra_parts_x11.h b/chrome/browser/chrome_browser_main_extra_parts_x11.h new file mode 100644 index 0000000..b3007bc --- /dev/null +++ b/chrome/browser/chrome_browser_main_extra_parts_x11.h @@ -0,0 +1,28 @@ +// Copyright (c) 2011 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. + +// Contains functions used by BrowserMain() that are gtk-specific. + +#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_X11_H_ +#define CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_X11_H_ + +#include "base/basictypes.h" +#include "base/compiler_specific.h" +#include "chrome/browser/chrome_browser_main_extra_parts.h" + +class ChromeBrowserMainExtraPartsX11 : public ChromeBrowserMainExtraParts { + public: + ChromeBrowserMainExtraPartsX11(); + virtual ~ChromeBrowserMainExtraPartsX11(); + + private: + // ChromeBrowserMainExtraParts overrides. + virtual void PreEarlyInitialization() OVERRIDE; + virtual void PostMainMessageLoopStart() OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(ChromeBrowserMainExtraPartsX11); +}; + +#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_EXTRA_PARTS_X11_H_ diff --git a/chrome/browser/chrome_browser_main_linux.cc b/chrome/browser/chrome_browser_main_linux.cc index 3a3ea52..3e1afe7 100644 --- a/chrome/browser/chrome_browser_main_linux.cc +++ b/chrome/browser/chrome_browser_main_linux.cc @@ -16,6 +16,8 @@ #include "base/linux_util.h" #include "base/prefs/pref_service.h" #include "chrome/app/breakpad_linux.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/metrics/metrics_service.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" #include "chrome/common/pref_names.h" @@ -133,6 +135,17 @@ void ChromeBrowserMainPartsLinux::PreProfileInit() { ChromeBrowserMainPartsPosix::PreProfileInit(); } +void ChromeBrowserMainPartsLinux::PostProfileInit() { + ChromeBrowserMainPartsPosix::PostProfileInit(); + +#if defined(USE_LINUX_BREAKPAD) + g_browser_process->metrics_service()->RecordBreakpadRegistration( + IsCrashReporterEnabled()); +#else + g_browser_process->metrics_service()->RecordBreakpadRegistration(false); +#endif +} + void ChromeBrowserMainPartsLinux::PostMainMessageLoopRun() { ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); diff --git a/chrome/browser/chrome_browser_main_linux.h b/chrome/browser/chrome_browser_main_linux.h index cba0e1e..3cc5476 100644 --- a/chrome/browser/chrome_browser_main_linux.h +++ b/chrome/browser/chrome_browser_main_linux.h @@ -25,6 +25,7 @@ class ChromeBrowserMainPartsLinux : public ChromeBrowserMainPartsPosix { // ChromeBrowserMainParts overrides. virtual void PreProfileInit() OVERRIDE; + virtual void PostProfileInit() OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE; private: diff --git a/chrome/browser/chrome_browser_main_mac.h b/chrome/browser/chrome_browser_main_mac.h index bad7bd9..52f6cf1 100644 --- a/chrome/browser/chrome_browser_main_mac.h +++ b/chrome/browser/chrome_browser_main_mac.h @@ -22,6 +22,7 @@ class ChromeBrowserMainPartsMac : public ChromeBrowserMainPartsPosix { virtual void PreEarlyInitialization() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE; virtual void PreProfileInit() OVERRIDE; + virtual void PostProfileInit() OVERRIDE; // Perform platform-specific work that needs to be done after the main event // loop has ended. The embedder must be sure to call this. diff --git a/chrome/browser/chrome_browser_main_mac.mm b/chrome/browser/chrome_browser_main_mac.mm index 156146b..af5ee81 100644 --- a/chrome/browser/chrome_browser_main_mac.mm +++ b/chrome/browser/chrome_browser_main_mac.mm @@ -8,7 +8,6 @@ #include <sys/sysctl.h> #include "base/command_line.h" -#include "base/debug/debugger.h" #include "base/files/file_path.h" #include "base/mac/bundle_locations.h" #include "base/mac/mac_util.h" @@ -17,6 +16,7 @@ #include "base/path_service.h" #include "chrome/app/breakpad_mac.h" #import "chrome/browser/app_controller_mac.h" +#include "chrome/browser/browser_process.h" #import "chrome/browser/chrome_browser_application_mac.h" #include "chrome/browser/mac/install_from_dmg.h" #include "chrome/browser/mac/keychain_reauthorize.h" @@ -150,21 +150,6 @@ void RecordCatSixtyFour() { } // namespace -void RecordBreakpadStatusUMA(MetricsService* metrics) { - metrics->RecordBreakpadRegistration(IsCrashReporterEnabled()); - metrics->RecordBreakpadHasDebugger(base::debug::BeingDebugged()); -} - -void WarnAboutMinimumSystemRequirements() { - // Nothing to check for on Mac right now. -} - -// From browser_main_win.h, stubs until we figure out the right thing... - -int DoUninstallTasks(bool chrome_still_running) { - return content::RESULT_CODE_NORMAL_EXIT; -} - // ChromeBrowserMainPartsMac --------------------------------------------------- ChromeBrowserMainPartsMac::ChromeBrowserMainPartsMac( @@ -286,6 +271,12 @@ void ChromeBrowserMainPartsMac::PreProfileInit() { ChromeBrowserMainPartsPosix::PreProfileInit(); } +void ChromeBrowserMainPartsMac::PostProfileInit() { + ChromeBrowserMainPartsPosix::PostProfileInit(); + g_browser_process->metrics_service()->RecordBreakpadRegistration( + IsCrashReporterEnabled()); +} + void ChromeBrowserMainPartsMac::DidEndMainMessageLoop() { AppController* appController = [NSApp delegate]; [appController didEndMainMessageLoop]; diff --git a/chrome/browser/chrome_browser_main_win.cc b/chrome/browser/chrome_browser_main_win.cc index 6149cf9..07862a5 100644 --- a/chrome/browser/chrome_browser_main_win.cc +++ b/chrome/browser/chrome_browser_main_win.cc @@ -28,6 +28,10 @@ #include "chrome/browser/profiles/profile_shortcut_manager.h" #include "chrome/browser/shell_integration.h" #include "chrome/browser/storage_monitor/storage_monitor_win.h" +#include "chrome/browser/search_engines/template_url.h" +#include "chrome/browser/search_engines/template_url_prepopulate_data.h" +#include "chrome/browser/search_engines/template_url_service.h" +#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/ui/simple_message_box.h" #include "chrome/browser/ui/uninstall_browser_prompt.h" #include "chrome/common/chrome_constants.h" @@ -88,19 +92,6 @@ class TranslationDelegate : public installer::TranslationDelegate { } // namespace -void RecordBreakpadStatusUMA(MetricsService* metrics) { - metrics->RecordBreakpadHasDebugger(TRUE == ::IsDebuggerPresent()); -} - -void WarnAboutMinimumSystemRequirements() { - if (base::win::GetVersion() < base::win::VERSION_XP) { - chrome::ShowMessageBox(NULL, - l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), - l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP), - chrome::MESSAGE_BOX_TYPE_WARNING); - } -} - void ShowCloseBrowserFirstMessageBox() { int message_id = IDS_UNINSTALL_CLOSE_APP; if (base::win::GetVersion() >= base::win::VERSION_WIN8 && @@ -203,6 +194,40 @@ void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() { } } +int ChromeBrowserMainPartsWin::PreCreateThreads() { + // TODO(viettrungluu): why don't we run this earlier? + if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs) && + base::win::GetVersion() < base::win::VERSION_XP) { + chrome::ShowMessageBox(NULL, + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), + l10n_util::GetStringUTF16(IDS_UNSUPPORTED_OS_PRE_WIN_XP), + chrome::MESSAGE_BOX_TYPE_WARNING); + } + + return ChromeBrowserMainParts::PreCreateThreads(); +} + +void ChromeBrowserMainPartsWin::PostMainMessageLoopRun() { + // Log the search engine chosen on first run. Do this at shutdown, after any + // changes are made from the first run bubble link, etc. + if (do_first_run_tasks() && !profile()->IsOffTheRecord()) { + TemplateURLService* url_service = + TemplateURLServiceFactory::GetForProfile(profile()); + const TemplateURL* default_search_engine = + url_service->GetDefaultSearchProvider(); + // The default engine can be NULL if the administrator has disabled + // default search. + SearchEngineType search_engine_type = + TemplateURLPrepopulateData::GetEngineType(default_search_engine ? + default_search_engine->url() : std::string()); + // Record the search engine chosen. + UMA_HISTOGRAM_ENUMERATION("Chrome.SearchSelectExempt", search_engine_type, + SEARCH_ENGINE_MAX); + } + + ChromeBrowserMainParts::PostMainMessageLoopRun(); +} + void ChromeBrowserMainPartsWin::PreProfileInit() { storage_monitor_.reset(chrome::StorageMonitorWin::Create()); diff --git a/chrome/browser/chrome_browser_main_win.h b/chrome/browser/chrome_browser_main_win.h index e3dabae..6da509e 100644 --- a/chrome/browser/chrome_browser_main_win.h +++ b/chrome/browser/chrome_browser_main_win.h @@ -32,6 +32,8 @@ class ChromeBrowserMainPartsWin : public ChromeBrowserMainParts { // BrowserParts overrides. virtual void ToolkitInitialized() OVERRIDE; virtual void PreMainMessageLoopStart() OVERRIDE; + virtual int PreCreateThreads() OVERRIDE; + virtual void PostMainMessageLoopRun() OVERRIDE; virtual void PreProfileInit() OVERRIDE; // ChromeBrowserMainParts overrides. diff --git a/chrome/browser/chrome_browser_main_x11.h b/chrome/browser/chrome_browser_main_x11.h deleted file mode 100644 index 5255cd1..0000000 --- a/chrome/browser/chrome_browser_main_x11.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2011 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. - -// Contains functions used by BrowserMain() that are gtk-specific. - -#ifndef CHROME_BROWSER_CHROME_BROWSER_MAIN_X11_H_ -#define CHROME_BROWSER_CHROME_BROWSER_MAIN_X11_H_ - -// Installs the X11 error handlers for the browser process used during -// startup. They simply print error messages and exit because -// we can't shutdown properly while creating and initializing services. -void SetBrowserX11ErrorHandlersPreEarlyInitialization(); - -// Installs the X11 error handlers for the browser process after the -// main message loop has started. This will allow us to exit cleanly -// if X exits before us. -void SetBrowserX11ErrorHandlersPostMainMessageLoopStart(); - -// Installs empty X11 error handlers. This avoids calling into the message-loop -// in case an X11 erro happens while the message-loop is being destroyed. -void UnsetBrowserX11ErrorHandlers(); - -#endif // CHROME_BROWSER_CHROME_BROWSER_MAIN_X11_H_ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 5c2c6d0..5778dd9 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -80,7 +80,6 @@ #include "chrome/browser/ssl/ssl_blocking_page.h" #include "chrome/browser/ssl/ssl_tab_helper.h" #include "chrome/browser/tab_contents/tab_util.h" -#include "chrome/browser/toolkit_extra_parts.h" #include "chrome/browser/ui/chrome_select_file_policy.h" #include "chrome/browser/ui/sync/sync_promo_ui.h" #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" @@ -203,6 +202,26 @@ #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" #endif +#if defined(TOOLKIT_GTK) +#include "chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.h" +#endif + +#if defined(TOOLKIT_VIEWS) +#include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" +#endif + +#if defined(USE_ASH) +#include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h" +#endif + +#if defined(USE_AURA) +#include "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h" +#endif + +#if defined(USE_X11) +#include "chrome/browser/chrome_browser_main_extra_parts_x11.h" +#endif + using base::FileDescriptor; using content::AccessTokenStore; using content::BrowserChildProcessHostIterator; @@ -574,19 +593,23 @@ content::BrowserMainParts* ChromeContentBrowserClient::CreateBrowserMainParts( // Construct additional browser parts. Stages are called in the order in // which they are added. #if defined(TOOLKIT_GTK) - chrome::AddGtkToolkitExtraParts(main_parts); + main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk()); #endif #if defined(TOOLKIT_VIEWS) - chrome::AddViewsToolkitExtraParts(main_parts); + main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); #endif #if defined(USE_ASH) - chrome::AddAshToolkitExtraParts(main_parts); + main_parts->AddParts(new ChromeBrowserMainExtraPartsAsh()); #endif #if defined(USE_AURA) - chrome::AddAuraToolkitExtraParts(main_parts); + main_parts->AddParts(new ChromeBrowserMainExtraPartsAura()); +#endif + +#if defined(USE_X11) + main_parts->AddParts(new ChromeBrowserMainExtraPartsX11()); #endif chrome::AddMetricsExtraParts(main_parts); diff --git a/chrome/browser/toolkit_extra_parts.h b/chrome/browser/toolkit_extra_parts.h deleted file mode 100644 index 802c080..0000000 --- a/chrome/browser/toolkit_extra_parts.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef CHROME_BROWSER_TOOLKIT_EXTRA_PARTS_H_ -#define CHROME_BROWSER_TOOLKIT_EXTRA_PARTS_H_ - -#include "build/build_config.h" - -class ChromeBrowserMainParts; - -namespace chrome { - -#if defined(TOOLKIT_GTK) -void AddGtkToolkitExtraParts(ChromeBrowserMainParts* main_parts); -#endif - -#if defined(TOOLKIT_VIEWS) -void AddViewsToolkitExtraParts(ChromeBrowserMainParts* main_parts); -#endif - -#if defined(USE_ASH) -void AddAshToolkitExtraParts(ChromeBrowserMainParts* main_parts); -#endif - -#if defined(USE_AURA) -void AddAuraToolkitExtraParts(ChromeBrowserMainParts* main_parts); -#endif - -} // namespace chrome - -#endif // CHROME_BROWSER_TOOLKIT_EXTRA_PARTS_H_ diff --git a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc index eb922f9..ad1ec3f 100644 --- a/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc +++ b/chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.cc @@ -5,7 +5,6 @@ #include "chrome/browser/ui/aura/chrome_browser_main_extra_parts_aura.h" #include "chrome/browser/chrome_browser_main.h" -#include "chrome/browser/toolkit_extra_parts.h" #include "chrome/browser/ui/aura/active_desktop_monitor.h" #include "chrome/browser/ui/host_desktop.h" #include "ui/aura/env.h" @@ -73,11 +72,3 @@ void ChromeBrowserMainExtraPartsAura::PostMainMessageLoopRun() { // aura::Env instance is deleted in BrowserProcessImpl::StartTearDown // after the metrics service is deleted. } - -namespace chrome { - -void AddAuraToolkitExtraParts(ChromeBrowserMainParts* main_parts) { - main_parts->AddParts(new ChromeBrowserMainExtraPartsAura()); -} - -} // namespace chrome diff --git a/chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.cc b/chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.cc index 8d7c88f..a6f5d49 100644 --- a/chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.cc +++ b/chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.cc @@ -8,7 +8,6 @@ #include "base/command_line.h" #include "chrome/browser/chrome_browser_main.h" -#include "chrome/browser/toolkit_extra_parts.h" #include "chrome/common/chrome_switches.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -79,11 +78,3 @@ void ChromeBrowserMainExtraPartsGtk::ShowMessageBox(const char* message) { gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_destroy(dialog); } - -namespace chrome { - -void AddGtkToolkitExtraParts(ChromeBrowserMainParts* main_parts) { - main_parts->AddParts(new ChromeBrowserMainExtraPartsGtk()); -} - -} // namespace chrome diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc index 877817c..50eba0c 100644 --- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc +++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc @@ -9,7 +9,6 @@ #include "base/command_line.h" #include "base/lazy_instance.h" #include "chrome/browser/chrome_browser_main.h" -#include "chrome/browser/toolkit_extra_parts.h" #include "chrome/browser/ui/ash/ash_init.h" #include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/views/ash/tab_scrubber.h" @@ -100,11 +99,3 @@ void ChromeBrowserMainExtraPartsAsh::PostProfileInit() { void ChromeBrowserMainExtraPartsAsh::PostMainMessageLoopRun() { chrome::CloseAsh(); } - -namespace chrome { - -void AddAshToolkitExtraParts(ChromeBrowserMainParts* main_parts) { - main_parts->AddParts(new ChromeBrowserMainExtraPartsAsh()); -} - -} // namespace chrome diff --git a/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc b/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc index 5bdb592..3bf186f 100644 --- a/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc +++ b/chrome/browser/ui/views/chrome_browser_main_extra_parts_views.cc @@ -5,7 +5,6 @@ #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" #include "chrome/browser/chrome_browser_main.h" -#include "chrome/browser/toolkit_extra_parts.h" #include "chrome/browser/ui/views/chrome_views_delegate.h" #include "chrome/common/chrome_switches.h" #include "ui/base/ui_base_switches.h" @@ -19,11 +18,3 @@ void ChromeBrowserMainExtraPartsViews::ToolkitInitialized() { if (!views::ViewsDelegate::views_delegate) views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; } - -namespace chrome { - -void AddViewsToolkitExtraParts(ChromeBrowserMainParts* main_parts) { - main_parts->AddParts(new ChromeBrowserMainExtraPartsViews()); -} - -} // namespace chrome diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index f57537a..bf93346 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -351,6 +351,8 @@ 'browser/chrome_browser_main_android.cc', 'browser/chrome_browser_main_android.h', 'browser/chrome_browser_main_extra_parts.h', + 'browser/chrome_browser_main_extra_parts_x11.cc', + 'browser/chrome_browser_main_extra_parts_x11.h', 'browser/chrome_browser_main_linux.cc', 'browser/chrome_browser_main_linux.h', 'browser/chrome_browser_main_mac.h', @@ -359,8 +361,6 @@ 'browser/chrome_browser_main_posix.h', 'browser/chrome_browser_main_win.cc', 'browser/chrome_browser_main_win.h', - 'browser/chrome_browser_main_x11.cc', - 'browser/chrome_browser_main_x11.h', 'browser/chrome_content_browser_client.cc', 'browser/chrome_content_browser_client.h', 'browser/chrome_page_zoom.cc', @@ -2255,7 +2255,6 @@ 'browser/thumbnails/thumbnailing_algorithm.h', 'browser/thumbnails/thumbnailing_context.cc', 'browser/thumbnails/thumbnailing_context.h', - 'browser/toolkit_extra_parts.h', 'browser/translate/options_menu_model.cc', 'browser/translate/options_menu_model.h', 'browser/translate/page_translated_details.h', |