OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | |
8 #include <windows.h> | |
9 #include <commctrl.h> | |
10 #endif | |
11 | |
12 #include <algorithm> | 7 #include <algorithm> |
13 | 8 |
14 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
15 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
16 #include "base/command_line.h" | 11 #include "base/command_line.h" |
17 #include "base/field_trial.h" | 12 #include "base/field_trial.h" |
18 #include "base/file_util.h" | 13 #include "base/file_util.h" |
19 #include "base/histogram.h" | 14 #include "base/histogram.h" |
20 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
21 #include "base/scoped_nsautorelease_pool.h" | 16 #include "base/scoped_nsautorelease_pool.h" |
(...skipping 22 matching lines...) Expand all Loading... |
44 #include "chrome/browser/shell_integration.h" | 39 #include "chrome/browser/shell_integration.h" |
45 #include "chrome/browser/user_data_manager.h" | 40 #include "chrome/browser/user_data_manager.h" |
46 #include "chrome/common/chrome_constants.h" | 41 #include "chrome/common/chrome_constants.h" |
47 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
48 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/jstemplate_builder.h" | 44 #include "chrome/common/jstemplate_builder.h" |
50 #include "chrome/common/main_function_params.h" | 45 #include "chrome/common/main_function_params.h" |
51 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
52 #include "chrome/common/pref_service.h" | 47 #include "chrome/common/pref_service.h" |
53 #include "chrome/common/result_codes.h" | 48 #include "chrome/common/result_codes.h" |
| 49 #include "chrome/installer/util/google_update_settings.h" |
54 #include "grit/chromium_strings.h" | 50 #include "grit/chromium_strings.h" |
55 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
56 #include "grit/net_resources.h" | 52 #include "grit/net_resources.h" |
57 #include "net/base/cookie_monster.h" | 53 #include "net/base/cookie_monster.h" |
58 #include "net/base/net_module.h" | 54 #include "net/base/net_module.h" |
59 #include "net/http/http_network_session.h" | 55 #include "net/http/http_network_session.h" |
60 | 56 |
61 #if defined(OS_POSIX) | 57 #if defined(OS_POSIX) |
62 // TODO(port): get rid of this include. It's used just to provide declarations | 58 // TODO(port): get rid of this include. It's used just to provide declarations |
63 // and stub definitions for classes we encouter during the porting effort. | 59 // and stub definitions for classes we encouter during the porting effort. |
64 #include "chrome/common/temp_scaffolding_stubs.h" | 60 #include "chrome/common/temp_scaffolding_stubs.h" |
65 #include <signal.h> | 61 #include <signal.h> |
66 #endif | 62 #endif |
67 | 63 |
68 #if defined(OS_LINUX) | 64 #if defined(OS_LINUX) |
69 #include "chrome/app/breakpad_linux.h" | 65 #include "chrome/app/breakpad_linux.h" |
70 #endif | 66 #endif |
71 | 67 |
72 // TODO(port): several win-only methods have been pulled out of this, but | 68 // TODO(port): several win-only methods have been pulled out of this, but |
73 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 69 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
74 // other platforms. For now, it's just a stub. This is a serious work in | 70 // other platforms. For now, it's just a stub. This is a serious work in |
75 // progress and should not be taken as an indication of a real refactoring. | 71 // progress and should not be taken as an indication of a real refactoring. |
76 | 72 |
77 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
78 | 74 |
79 #include <windows.h> | 75 #include <windows.h> |
| 76 #include <commctrl.h> |
80 #include <shellapi.h> | 77 #include <shellapi.h> |
81 | 78 |
82 #include "app/win_util.h" | 79 #include "app/win_util.h" |
83 #include "base/registry.h" | 80 #include "base/registry.h" |
84 #include "base/win_util.h" | 81 #include "base/win_util.h" |
85 #include "chrome/browser/browser.h" | 82 #include "chrome/browser/browser.h" |
86 #include "chrome/browser/browser_trial.h" | 83 #include "chrome/browser/browser_trial.h" |
87 #include "chrome/browser/extensions/extension_protocols.h" | 84 #include "chrome/browser/extensions/extension_protocols.h" |
88 #include "chrome/browser/jankometer.h" | 85 #include "chrome/browser/jankometer.h" |
89 #include "chrome/browser/metrics/user_metrics.h" | 86 #include "chrome/browser/metrics/user_metrics.h" |
(...skipping 14 matching lines...) Expand all Loading... |
104 #include "net/http/http_network_layer.h" | 101 #include "net/http/http_network_layer.h" |
105 #include "sandbox/src/sandbox.h" | 102 #include "sandbox/src/sandbox.h" |
106 #include "views/widget/accelerator_handler.h" | 103 #include "views/widget/accelerator_handler.h" |
107 | 104 |
108 #endif // defined(OS_WIN) | 105 #endif // defined(OS_WIN) |
109 | 106 |
110 #if defined(TOOLKIT_GTK) | 107 #if defined(TOOLKIT_GTK) |
111 #include "chrome/common/gtk_util.h" | 108 #include "chrome/common/gtk_util.h" |
112 #endif | 109 #endif |
113 | 110 |
114 #if defined(OS_WIN) || defined(OS_MACOSX) | |
115 #include "chrome/installer/util/google_update_settings.h" | |
116 #endif // OS_WIN || OS_MACOSX | |
117 | |
118 namespace Platform { | 111 namespace Platform { |
119 | 112 |
120 void WillInitializeMainMessageLoop(const CommandLine & command_line); | 113 void WillInitializeMainMessageLoop(const CommandLine & command_line); |
121 void WillTerminate(); | 114 void WillTerminate(); |
122 | 115 |
123 #if defined(OS_WIN) || defined(OS_LINUX) | 116 #if defined(OS_WIN) || defined(OS_LINUX) |
124 // Perform any platform-specific work that needs to be done before the main | 117 // Perform any platform-specific work that needs to be done before the main |
125 // message loop is created and initialized. | 118 // message loop is created and initialized. |
126 void WillInitializeMainMessageLoop(const CommandLine & command_line) { | 119 void WillInitializeMainMessageLoop(const CommandLine & command_line) { |
127 } | 120 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 238 |
246 #if defined(OS_POSIX) | 239 #if defined(OS_POSIX) |
247 // We need to accept SIGCHLD, even though our handler is a no-op because | 240 // We need to accept SIGCHLD, even though our handler is a no-op because |
248 // otherwise we cannot wait on children. (According to POSIX 2001.) | 241 // otherwise we cannot wait on children. (According to POSIX 2001.) |
249 struct sigaction action; | 242 struct sigaction action; |
250 memset(&action, 0, sizeof(action)); | 243 memset(&action, 0, sizeof(action)); |
251 action.sa_handler = SIGCHLDHandler; | 244 action.sa_handler = SIGCHLDHandler; |
252 CHECK(sigaction(SIGCHLD, &action, NULL) == 0); | 245 CHECK(sigaction(SIGCHLD, &action, NULL) == 0); |
253 #endif | 246 #endif |
254 | 247 |
255 #if defined(OS_LINUX) | |
256 EnableCrashDumping(); | |
257 #endif | |
258 | |
259 // Do platform-specific things (such as finishing initializing Cocoa) | 248 // Do platform-specific things (such as finishing initializing Cocoa) |
260 // prior to instantiating the message loop. This could be turned into a | 249 // prior to instantiating the message loop. This could be turned into a |
261 // broadcast notification. | 250 // broadcast notification. |
262 Platform::WillInitializeMainMessageLoop(parsed_command_line); | 251 Platform::WillInitializeMainMessageLoop(parsed_command_line); |
263 | 252 |
264 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | 253 MessageLoop main_message_loop(MessageLoop::TYPE_UI); |
265 | 254 |
266 // Initialize the SystemMonitor | 255 // Initialize the SystemMonitor |
267 base::SystemMonitor::Start(); | 256 base::SystemMonitor::Start(); |
268 #if defined(OS_WIN) | 257 #if defined(OS_WIN) |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // locale dll to load. | 322 // locale dll to load. |
334 PrefService* local_state = browser_process->local_state(); | 323 PrefService* local_state = browser_process->local_state(); |
335 DCHECK(local_state); | 324 DCHECK(local_state); |
336 | 325 |
337 // Initialize ResourceBundle which handles files loaded from external | 326 // Initialize ResourceBundle which handles files loaded from external |
338 // sources. This has to be done before uninstall code path and before prefs | 327 // sources. This has to be done before uninstall code path and before prefs |
339 // are registered. | 328 // are registered. |
340 local_state->RegisterStringPref(prefs::kApplicationLocale, L""); | 329 local_state->RegisterStringPref(prefs::kApplicationLocale, L""); |
341 local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); | 330 local_state->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); |
342 | 331 |
343 #if defined(OS_MACOSX) | 332 #if defined(OS_POSIX) |
344 // On Mac OS X we display the first run dialog as early as possible, so we can | 333 // On Mac OS X / Linux we display the first run dialog as early as possible, |
345 // get the stats enabled. | 334 // so we can get the stats enabled. |
346 // TODO: | 335 // TODO(port): |
347 // We check the kNoFirstRun command line switch explicitly here since the | 336 // We check the kNoFirstRun command line switch explicitly here since the |
348 // early placement of this block happens before that's factored into | 337 // early placement of this block happens before that's factored into |
349 // first_run_ui_bypass, we probably want to move that block up | 338 // first_run_ui_bypass, we probably want to move that block up |
350 // and remove the explicit check from here in the long run. | 339 // and remove the explicit check from here in the long run. |
351 if (is_first_run && !first_run_ui_bypass && | 340 if (is_first_run && !first_run_ui_bypass && |
352 !parsed_command_line.HasSwitch(switches::kNoFirstRun)) { | 341 !parsed_command_line.HasSwitch(switches::kNoFirstRun)) { |
353 // Dummy value, we don't need the profile for the OS X version of this | 342 // Dummy value, we don't need the profile for the OS X version of this |
354 // method at present. | 343 // method at present. |
355 Profile* profile = NULL; | 344 Profile* profile = NULL; |
356 OpenFirstRunDialog(profile, &process_singleton); | 345 OpenFirstRunDialog(profile, &process_singleton); |
357 } | 346 } |
358 #endif // OS_MACOSX | 347 #endif // OS_POSIX |
359 | 348 |
360 // During first run we read the google_update registry key to find what | 349 // During first run we read the google_update registry key to find what |
361 // language the user selected when downloading the installer. This | 350 // language the user selected when downloading the installer. This |
362 // becomes our default language in the prefs. | 351 // becomes our default language in the prefs. |
363 if (is_first_run) { | 352 if (is_first_run) { |
364 std::wstring install_lang; | 353 std::wstring install_lang; |
365 if (GoogleUpdateSettings::GetLanguage(&install_lang)) | 354 if (GoogleUpdateSettings::GetLanguage(&install_lang)) |
366 local_state->SetString(prefs::kApplicationLocale, install_lang); | 355 local_state->SetString(prefs::kApplicationLocale, install_lang); |
367 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 356 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
368 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); | 357 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS; | 529 return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS; |
541 | 530 |
542 process_singleton.Create(); | 531 process_singleton.Create(); |
543 | 532 |
544 #if defined(TOOLKIT_GTK) | 533 #if defined(TOOLKIT_GTK) |
545 // It is important for this to happen before the first run dialog, as it | 534 // It is important for this to happen before the first run dialog, as it |
546 // styles the dialog as well. | 535 // styles the dialog as well. |
547 gtk_util::InitRCStyles(); | 536 gtk_util::InitRCStyles(); |
548 #endif | 537 #endif |
549 | 538 |
550 // TODO: This block of code should probably be used on all platforms! | 539 // TODO(port): This block of code should probably be used on all platforms! |
551 // On Mac OS X we display this dialog before setting the value of | 540 // On Mac OS X / Linux we display this dialog before setting the value of |
552 // kMetricsReportingEnabled, so we display this dialog much earlier. | 541 // kMetricsReportingEnabled, so we display this dialog much earlier. |
553 // On Windows a download is tagged with stats enabled/disabled so the UI | 542 // On Windows a download is tagged with stats enabled/disabled so the UI |
554 // can be displayed later in the startup process. | 543 // can be displayed later in the startup process. |
555 #if !defined(OS_MACOSX) | 544 #if !defined(OS_POSIX) |
556 // Show the First Run UI if this is the first time Chrome has been run on | 545 // Show the First Run UI if this is the first time Chrome has been run on |
557 // this computer, or we're being compelled to do so by a command line flag. | 546 // this computer, or we're being compelled to do so by a command line flag. |
558 // Note that this be done _after_ the PrefService is initialized and all | 547 // Note that this be done _after_ the PrefService is initialized and all |
559 // preferences are registered, since some of the code that the importer | 548 // preferences are registered, since some of the code that the importer |
560 // touches reads preferences. | 549 // touches reads preferences. |
561 if (is_first_run && !first_run_ui_bypass) { | 550 if (is_first_run && !first_run_ui_bypass) { |
562 OpenFirstRunDialog(profile, &process_singleton); | 551 OpenFirstRunDialog(profile, &process_singleton); |
563 } | 552 } |
564 #endif // OS_MACOSX | 553 #endif // OS_POSIX |
565 | 554 |
566 // Sets things up so that if we crash from this point on, a dialog will | 555 // Sets things up so that if we crash from this point on, a dialog will |
567 // popup asking the user to restart chrome. It is done this late to avoid | 556 // popup asking the user to restart chrome. It is done this late to avoid |
568 // testing against a bunch of special cases that are taken care early on. | 557 // testing against a bunch of special cases that are taken care early on. |
569 PrepareRestartOnCrashEnviroment(parsed_command_line); | 558 PrepareRestartOnCrashEnviroment(parsed_command_line); |
570 | 559 |
571 #if defined(OS_WIN) | 560 #if defined(OS_WIN) |
572 // Initialize Winsock. | 561 // Initialize Winsock. |
573 net::EnsureWinsockInit(); | 562 net::EnsureWinsockInit(); |
574 #endif // defined(OS_WIN) | 563 #endif // defined(OS_WIN) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 if (metrics) | 725 if (metrics) |
737 metrics->Stop(); | 726 metrics->Stop(); |
738 | 727 |
739 // browser_shutdown takes care of deleting browser_process, so we need to | 728 // browser_shutdown takes care of deleting browser_process, so we need to |
740 // release it. | 729 // release it. |
741 browser_process.release(); | 730 browser_process.release(); |
742 browser_shutdown::Shutdown(); | 731 browser_shutdown::Shutdown(); |
743 | 732 |
744 return result_code; | 733 return result_code; |
745 } | 734 } |
OLD | NEW |