diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-09 20:22:01 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-09 20:22:01 +0000 |
commit | a5e8c6d4aa3dbe86823813bab9935557c3db1e38 (patch) | |
tree | 9b2eb1bfc8f23ecefef2acc2a8283270fed9396e /chrome/browser/chrome_browser_main_linux.cc | |
parent | 02c8f82d504b4ecf983f1a10c10fb227ee1204cb (diff) | |
download | chromium_src-a5e8c6d4aa3dbe86823813bab9935557c3db1e38.zip chromium_src-a5e8c6d4aa3dbe86823813bab9935557c3db1e38.tar.gz chromium_src-a5e8c6d4aa3dbe86823813bab9935557c3db1e38.tar.bz2 |
Cleanup: Move some Linux only bits from ChromeBrowserMainParts to ChromeBrowserMainPartsLinux. (try 2)
previous attempt: https://chromiumcodereview.appspot.com/9866028/
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/9949045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131422 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chrome_browser_main_linux.cc')
-rw-r--r-- | chrome/browser/chrome_browser_main_linux.cc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/chrome/browser/chrome_browser_main_linux.cc b/chrome/browser/chrome_browser_main_linux.cc index b27580d..2ba1b41 100644 --- a/chrome/browser/chrome_browser_main_linux.cc +++ b/chrome/browser/chrome_browser_main_linux.cc @@ -4,7 +4,83 @@ #include "chrome/browser/chrome_browser_main_linux.h" +#if defined(USE_LINUX_BREAKPAD) +#include <stdlib.h> + +#include "base/linux_util.h" +#include "chrome/app/breakpad_linux.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/env_vars.h" +#include "chrome/common/pref_names.h" +#include "content/public/browser/browser_thread.h" + +#if defined(OS_CHROMEOS) +#include "chrome/browser/chromeos/cros_settings.h" +#include "chrome/browser/chromeos/cros_settings_names.h" +#include "chrome/common/chrome_switches.h" +#include "chrome/common/chrome_version_info.h" +#endif + +#endif // defined(USE_LINUX_BREAKPAD) + +namespace { + +#if defined(USE_LINUX_BREAKPAD) +void GetLinuxDistroCallback() { + base::GetLinuxDistro(); // Initialize base::linux_distro if needed. +} + +bool IsCrashReportingEnabled(const PrefService* local_state) { + // Check whether we should initialize the crash reporter. It may be disabled + // through configuration policy or user preference. It must be disabled for + // Guest mode on Chrome OS in Stable channel. + // The kHeadless environment variable overrides the decision, but only if the + // crash service is under control of the user. It is used by QA testing + // infrastructure to switch on generation of crash reports. +#if defined(OS_CHROMEOS) + bool is_guest_session = + CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession); + bool is_stable_channel = + chrome::VersionInfo::GetChannel() == chrome::VersionInfo::CHANNEL_STABLE; + // TODO(pastarmovj): Consider the TrustedGet here. + bool reporting_enabled; + chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, + &reporting_enabled); + bool breakpad_enabled = + !(is_guest_session && is_stable_channel) && reporting_enabled; + if (!breakpad_enabled) + breakpad_enabled = getenv(env_vars::kHeadless) != NULL; +#else + const PrefService::Preference* metrics_reporting_enabled = + local_state->FindPreference(prefs::kMetricsReportingEnabled); + CHECK(metrics_reporting_enabled); + bool breakpad_enabled = + local_state->GetBoolean(prefs::kMetricsReportingEnabled); + if (!breakpad_enabled && metrics_reporting_enabled->IsUserModifiable()) + breakpad_enabled = getenv(env_vars::kHeadless) != NULL; +#endif // defined(OS_CHROMEOS) + return breakpad_enabled; +} +#endif // defined(USE_LINUX_BREAKPAD) + +} // namespace + ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( const content::MainFunctionParams& parameters) : ChromeBrowserMainPartsPosix(parameters) { } + +void ChromeBrowserMainPartsLinux::PreProfileInit() { +#if defined(USE_LINUX_BREAKPAD) + // Needs to be called after we have chrome::DIR_USER_DATA and + // g_browser_process. This happens in PreCreateThreads. + content::BrowserThread::PostTask(content::BrowserThread::FILE, + FROM_HERE, + base::Bind(&GetLinuxDistroCallback)); + + if (IsCrashReportingEnabled(local_state())) + InitCrashReporter(); +#endif + + ChromeBrowserMainPartsPosix::PreProfileInit(); +} |