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_posix.h" | 5 #include "chrome/browser/chrome_browser_main_posix.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <pthread.h> | 9 #include <pthread.h> |
10 #include <signal.h> | 10 #include <signal.h> |
11 #include <sys/resource.h> | 11 #include <sys/resource.h> |
12 #include <unistd.h> | 12 #include <unistd.h> |
13 | 13 |
14 #include <string> | 14 #include <string> |
15 | 15 |
16 #include "base/bind.h" | 16 #include "base/bind.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/posix/eintr_wrapper.h" | 19 #include "base/posix/eintr_wrapper.h" |
20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
21 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
22 #include "chrome/browser/lifetime/application_lifetime.h" | 22 #include "chrome/browser/lifetime/application_lifetime.h" |
23 #include "chrome/browser/sessions/session_restore.h" | 23 #include "chrome/browser/sessions/session_restore.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/notification_observer.h" | 26 #include "content/public/browser/notification_observer.h" |
27 #include "content/public/browser/notification_registrar.h" | 27 #include "content/public/browser/notification_registrar.h" |
28 #include "content/public/browser/notification_service.h" | 28 #include "content/public/browser/notification_service.h" |
29 | 29 |
30 #if defined(TOOLKIT_GTK) | |
31 #include "chrome/browser/ui/gtk/chrome_browser_main_extra_parts_gtk.h" | |
32 | |
33 #if defined(ENABLE_PRINTING) | |
34 #include "chrome/browser/printing/print_dialog_gtk.h" | |
35 #include "chrome/browser/printing/printing_gtk_util.h" | |
36 #endif // defined(ENABLE_PRINTING) | |
37 #endif // defined(TOOLKIT_GTK) | |
38 | |
39 using content::BrowserThread; | 30 using content::BrowserThread; |
40 | 31 |
41 namespace { | 32 namespace { |
42 | 33 |
43 // See comment in |PreEarlyInitialization()|, where sigaction is called. | 34 // See comment in |PreEarlyInitialization()|, where sigaction is called. |
44 void SIGCHLDHandler(int signal) { | 35 void SIGCHLDHandler(int signal) { |
45 } | 36 } |
46 | 37 |
47 // The OSX fork() implementation can crash in the child process before | 38 // The OSX fork() implementation can crash in the child process before |
48 // fork() returns. In that case, the shutdown pipe will still be | 39 // fork() returns. In that case, the shutdown pipe will still be |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 action.sa_handler = SIGTERMHandler; | 335 action.sa_handler = SIGTERMHandler; |
345 CHECK(sigaction(SIGTERM, &action, NULL) == 0); | 336 CHECK(sigaction(SIGTERM, &action, NULL) == 0); |
346 // Also handle SIGINT - when the user terminates the browser via Ctrl+C. If | 337 // Also handle SIGINT - when the user terminates the browser via Ctrl+C. If |
347 // the browser process is being debugged, GDB will catch the SIGINT first. | 338 // the browser process is being debugged, GDB will catch the SIGINT first. |
348 action.sa_handler = SIGINTHandler; | 339 action.sa_handler = SIGINTHandler; |
349 CHECK(sigaction(SIGINT, &action, NULL) == 0); | 340 CHECK(sigaction(SIGINT, &action, NULL) == 0); |
350 // And SIGHUP, for when the terminal disappears. On shutdown, many Linux | 341 // And SIGHUP, for when the terminal disappears. On shutdown, many Linux |
351 // distros send SIGHUP, SIGTERM, and then SIGKILL. | 342 // distros send SIGHUP, SIGTERM, and then SIGKILL. |
352 action.sa_handler = SIGHUPHandler; | 343 action.sa_handler = SIGHUPHandler; |
353 CHECK(sigaction(SIGHUP, &action, NULL) == 0); | 344 CHECK(sigaction(SIGHUP, &action, NULL) == 0); |
354 | |
355 #if defined(TOOLKIT_GTK) && defined(ENABLE_PRINTING) | |
356 printing::PrintingContextLinux::SetCreatePrintDialogFunction( | |
357 &PrintDialogGtk::CreatePrintDialog); | |
358 printing::PrintingContextLinux::SetPdfPaperSizeFunction( | |
359 &GetPdfPaperSizeDeviceUnitsGtk); | |
360 #endif | |
361 } | 345 } |
362 | 346 |
363 void ChromeBrowserMainPartsPosix::ShowMissingLocaleMessageBox() { | 347 void ChromeBrowserMainPartsPosix::ShowMissingLocaleMessageBox() { |
364 #if defined(OS_CHROMEOS) | 348 #if defined(OS_CHROMEOS) |
365 NOTREACHED(); // Should not ever happen on ChromeOS. | 349 NOTREACHED(); // Should not ever happen on ChromeOS. |
366 #elif defined(OS_MACOSX) | 350 #elif defined(OS_MACOSX) |
367 // Not called on Mac because we load the locale files differently. | 351 // Not called on Mac because we load the locale files differently. |
368 NOTREACHED(); | 352 NOTREACHED(); |
369 #elif defined(TOOLKIT_GTK) | |
370 ChromeBrowserMainExtraPartsGtk::ShowMessageBox( | |
371 chrome_browser::kMissingLocaleDataMessage); | |
372 #elif defined(USE_AURA) | 353 #elif defined(USE_AURA) |
373 // TODO(port): We may want a views based message dialog here eventually, but | 354 // TODO(port): We may want a views based message dialog here eventually, but |
374 // for now, crash. | 355 // for now, crash. |
375 NOTREACHED(); | 356 NOTREACHED(); |
376 #else | 357 #else |
377 #error "Need MessageBox implementation." | 358 #error "Need MessageBox implementation." |
378 #endif | 359 #endif |
379 } | 360 } |
OLD | NEW |