OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chrome_browser_main_linux.h" | 5 #include "chrome/browser/chrome_browser_main_linux.h" |
6 | 6 |
7 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_
linux.h" | 7 #include "chrome/browser/system_monitor/media_transfer_protocol_device_observer_
linux.h" |
8 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" | 8 #include "device/media_transfer_protocol/media_transfer_protocol_manager.h" |
9 | 9 |
10 #if !defined(OS_CHROMEOS) | 10 #if !defined(OS_CHROMEOS) |
11 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" | 11 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" |
12 #endif | 12 #endif |
13 | 13 |
14 #if defined(USE_LINUX_BREAKPAD) | 14 #if defined(USE_LINUX_BREAKPAD) |
15 #include <stdlib.h> | 15 #include <stdlib.h> |
16 | 16 |
| 17 #include "base/command_line.h" |
17 #include "base/linux_util.h" | 18 #include "base/linux_util.h" |
18 #include "chrome/app/breakpad_linux.h" | 19 #include "chrome/app/breakpad_linux.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/common/env_vars.h" | 22 #include "chrome/common/env_vars.h" |
21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
23 | 25 |
24 #if defined(OS_CHROMEOS) | 26 #if defined(OS_CHROMEOS) |
25 #include "chrome/browser/chromeos/settings/cros_settings.h" | 27 #include "chrome/browser/chromeos/settings/cros_settings.h" |
26 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 28 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
27 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/chrome_version_info.h" | 30 #include "chrome/common/chrome_version_info.h" |
29 #endif | 31 #endif |
30 | 32 |
31 #endif // defined(USE_LINUX_BREAKPAD) | 33 #endif // defined(USE_LINUX_BREAKPAD) |
32 | 34 |
33 namespace { | 35 namespace { |
34 | 36 |
35 #if defined(USE_LINUX_BREAKPAD) | 37 #if defined(USE_LINUX_BREAKPAD) |
36 #if !defined(OS_CHROMEOS) | 38 #if !defined(OS_CHROMEOS) |
37 void GetLinuxDistroCallback() { | 39 void GetLinuxDistroCallback() { |
38 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. | 40 base::GetLinuxDistro(); // Initialize base::linux_distro if needed. |
39 } | 41 } |
40 #endif | 42 #endif |
41 | 43 |
42 bool IsCrashReportingEnabled(const PrefService* local_state) { | 44 bool IsCrashReportingEnabled(const PrefService* local_state) { |
43 // Check whether we should initialize the crash reporter. It may be disabled | 45 // Check whether we should initialize the crash reporter. It may be disabled |
44 // through configuration policy or user preference. It must be disabled for | 46 // through configuration policy or user preference. It must be disabled for |
45 // Guest mode on Chrome OS in Stable channel. | 47 // Guest mode on Chrome OS in Stable channel. |
46 // Environment variables may override the decision, but only if the | 48 // Also allow crash reporting to be enabled with a command-line flag if the |
47 // crash service is under control of the user. It is used by QA | 49 // crash service is under control of the user. It is used by QA |
48 // testing infrastructure to switch on generation of crash reports. | 50 // testing infrastructure to switch on generation of crash reports. |
49 bool use_env_var = true; | 51 bool use_switch = true; |
50 | 52 |
51 // Convert #define to a variable so that we can use if() rather than | 53 // Convert #define to a variable so that we can use if() rather than |
52 // #if below and so at least compile-test the Chrome code in | 54 // #if below and so at least compile-test the Chrome code in |
53 // Chromium builds. | 55 // Chromium builds. |
54 #if defined(GOOGLE_CHROME_BUILD) | 56 #if defined(GOOGLE_CHROME_BUILD) |
55 bool is_chrome_build = true; | 57 bool is_chrome_build = true; |
56 #else | 58 #else |
57 bool is_chrome_build = false; | 59 bool is_chrome_build = false; |
58 #endif | 60 #endif |
59 | 61 |
(...skipping 11 matching lines...) Expand all Loading... |
71 bool reporting_enabled; | 73 bool reporting_enabled; |
72 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 74 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
73 &reporting_enabled); | 75 &reporting_enabled); |
74 breakpad_enabled = | 76 breakpad_enabled = |
75 !(is_guest_session && is_stable_channel) && reporting_enabled; | 77 !(is_guest_session && is_stable_channel) && reporting_enabled; |
76 #else | 78 #else |
77 const PrefService::Preference* metrics_reporting_enabled = | 79 const PrefService::Preference* metrics_reporting_enabled = |
78 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 80 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
79 CHECK(metrics_reporting_enabled); | 81 CHECK(metrics_reporting_enabled); |
80 breakpad_enabled = local_state->GetBoolean(prefs::kMetricsReportingEnabled); | 82 breakpad_enabled = local_state->GetBoolean(prefs::kMetricsReportingEnabled); |
81 use_env_var = metrics_reporting_enabled->IsUserModifiable(); | 83 use_switch = metrics_reporting_enabled->IsUserModifiable(); |
82 #endif // defined(OS_CHROMEOS) | 84 #endif // defined(OS_CHROMEOS) |
83 } | 85 } |
84 | 86 |
85 if (use_env_var) { | 87 if (use_switch) { |
86 // Linux Breakpad interferes with the debug stack traces produced | 88 // Linux Breakpad interferes with the debug stack traces produced |
87 // by EnableInProcessStackDumping(), used in browser_tests, so we | 89 // by EnableInProcessStackDumping(), used in browser_tests, so we |
88 // do not allow CHROME_HEADLESS=1 to enable Breakpad in Chromium | 90 // do not allow CHROME_HEADLESS=1 to enable Breakpad in Chromium |
89 // because the buildbots have CHROME_HEADLESS set. However, we | 91 // because the buildbots have CHROME_HEADLESS set. However, we |
90 // allow CHROME_HEADLESS to enable Breakpad in Chrome for | 92 // allow CHROME_HEADLESS to enable Breakpad in Chrome for |
91 // compatibility with Breakpad/Chrome tests that may rely on this. | 93 // compatibility with Breakpad/Chrome tests that may rely on this. |
92 // TODO(mseaborn): Change tests to use CHROME_ENABLE_BREAKPAD | 94 // TODO(mseaborn): Change tests to use --enable-crash-reporter-for-testing |
93 // instead. | 95 // instead. |
94 if (is_chrome_build && !breakpad_enabled) | 96 if (is_chrome_build && !breakpad_enabled) |
95 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; | 97 breakpad_enabled = getenv(env_vars::kHeadless) != NULL; |
96 if (!breakpad_enabled) | 98 if (!breakpad_enabled) |
97 breakpad_enabled = getenv(env_vars::kEnableBreakpad) != NULL; | 99 breakpad_enabled = CommandLine::ForCurrentProcess()->HasSwitch( |
| 100 switches::kEnableCrashReporterForTesting); |
98 } | 101 } |
99 | 102 |
100 return breakpad_enabled; | 103 return breakpad_enabled; |
101 } | 104 } |
102 #endif // defined(USE_LINUX_BREAKPAD) | 105 #endif // defined(USE_LINUX_BREAKPAD) |
103 | 106 |
104 } // namespace | 107 } // namespace |
105 | 108 |
106 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( | 109 ChromeBrowserMainPartsLinux::ChromeBrowserMainPartsLinux( |
107 const content::MainFunctionParams& parameters) | 110 const content::MainFunctionParams& parameters) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 // Release it now. Otherwise the FILE thread would be gone when we try to | 157 // Release it now. Otherwise the FILE thread would be gone when we try to |
155 // release it in the dtor and Valgrind would report a leak on almost ever | 158 // release it in the dtor and Valgrind would report a leak on almost ever |
156 // single browser_test. | 159 // single browser_test. |
157 removable_device_notifications_linux_ = NULL; | 160 removable_device_notifications_linux_ = NULL; |
158 #endif | 161 #endif |
159 | 162 |
160 media_transfer_protocol_device_observer_.reset(); | 163 media_transfer_protocol_device_observer_.reset(); |
161 | 164 |
162 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); | 165 ChromeBrowserMainPartsPosix::PostMainMessageLoopRun(); |
163 } | 166 } |
OLD | NEW |