browser_main_gtk.cc revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2008 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/browser_main.h"
6
7#include "app/x11_util.h"
8#include "app/x11_util_internal.h"
9#include "base/command_line.h"
10#include "base/debug_util.h"
11#include "chrome/browser/browser_list.h"
12#include "chrome/browser/browser_main_gtk.h"
13#include "chrome/browser/browser_main_win.h"
14#include "chrome/browser/metrics/metrics_service.h"
15#include "chrome/common/result_codes.h"
16
17#if defined(USE_LINUX_BREAKPAD)
18#include "chrome/app/breakpad_linux.h"
19#endif
20
21namespace {
22
23// Indicates that we're currently responding to an IO error (by shutting down).
24bool g_in_x11_io_error_handler = false;
25
26int BrowserX11ErrorHandler(Display* d, XErrorEvent* error) {
27  if (!g_in_x11_io_error_handler)
28    LOG(ERROR) << x11_util::GetErrorEventDescription(d, error);
29  return 0;
30}
31
32int BrowserX11IOErrorHandler(Display* d) {
33  // If there's an IO error it likely means the X server has gone away
34  if (!g_in_x11_io_error_handler) {
35    g_in_x11_io_error_handler = true;
36    LOG(ERROR) << "X IO Error detected";
37    BrowserList::WindowsSessionEnding();
38  }
39
40  return 0;
41}
42
43}  // namespace
44
45void DidEndMainMessageLoop() {
46}
47
48void RecordBreakpadStatusUMA(MetricsService* metrics) {
49#if defined(USE_LINUX_BREAKPAD)
50  metrics->RecordBreakpadRegistration(IsCrashReporterEnabled());
51#else
52  metrics->RecordBreakpadRegistration(false);
53#endif
54  metrics->RecordBreakpadHasDebugger(DebugUtil::BeingDebugged());
55}
56
57void WarnAboutMinimumSystemRequirements() {
58  // Nothing to warn about on GTK right now.
59}
60
61// From browser_main_win.h, stubs until we figure out the right thing...
62
63int DoUninstallTasks(bool chrome_still_running) {
64  return ResultCodes::NORMAL_EXIT;
65}
66
67int HandleIconsCommands(const CommandLine &parsed_command_line) {
68  return 0;
69}
70
71bool CheckMachineLevelInstall() {
72  return false;
73}
74
75void PrepareRestartOnCrashEnviroment(const CommandLine &parsed_command_line) {
76}
77
78void SetBrowserX11ErrorHandlers() {
79  // Set up error handlers to make sure profile gets written if X server
80  // goes away.
81  x11_util::SetX11ErrorHandlers(
82      BrowserX11ErrorHandler,
83      BrowserX11IOErrorHandler);
84}
85