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 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 #include "chrome/installer/util/shell_util.h" | 105 #include "chrome/installer/util/shell_util.h" |
106 #include "chrome/installer/util/version.h" | 106 #include "chrome/installer/util/version.h" |
107 #include "net/base/net_util.h" | 107 #include "net/base/net_util.h" |
108 #include "net/base/sdch_manager.h" | 108 #include "net/base/sdch_manager.h" |
109 #include "net/base/winsock_init.h" | 109 #include "net/base/winsock_init.h" |
110 #include "net/http/http_network_layer.h" | 110 #include "net/http/http_network_layer.h" |
111 #include "printing/printed_document.h" | 111 #include "printing/printed_document.h" |
112 #include "sandbox/src/sandbox.h" | 112 #include "sandbox/src/sandbox.h" |
113 #endif // defined(OS_WIN) | 113 #endif // defined(OS_WIN) |
114 | 114 |
115 #if defined(OS_LINUX) | 115 #if defined(USE_X11) |
116 #include "chrome/common/gtk_util.h" | 116 #include "chrome/common/gtk_util.h" |
117 #endif | 117 #endif |
118 | 118 |
119 #if defined(TOOLKIT_VIEWS) | 119 #if defined(TOOLKIT_VIEWS) |
120 #include "chrome/browser/views/chrome_views_delegate.h" | 120 #include "chrome/browser/views/chrome_views_delegate.h" |
121 #include "views/focus/accelerator_handler.h" | 121 #include "views/focus/accelerator_handler.h" |
122 #endif | 122 #endif |
123 | 123 |
124 #if defined(OS_CHROMEOS) | 124 #if defined(OS_CHROMEOS) |
125 #include "chrome/browser/chromeos/external_cookie_handler.h" | 125 #include "chrome/browser/chromeos/external_cookie_handler.h" |
126 #endif | 126 #endif |
127 | 127 |
128 namespace Platform { | 128 namespace Platform { |
129 | 129 |
130 void WillInitializeMainMessageLoop(const MainFunctionParams& parameters); | 130 void WillInitializeMainMessageLoop(const MainFunctionParams& parameters); |
131 void WillTerminate(); | 131 void WillTerminate(); |
132 | 132 |
133 #if defined(OS_WIN) || defined(OS_LINUX) | 133 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_FREEBSD) |
134 // Perform any platform-specific work that needs to be done before the main | 134 // Perform any platform-specific work that needs to be done before the main |
135 // message loop is created and initialized. | 135 // message loop is created and initialized. |
136 void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) { | 136 void WillInitializeMainMessageLoop(const MainFunctionParams& parameters) { |
137 } | 137 } |
138 | 138 |
139 // Perform platform-specific work that needs to be done after the main event | 139 // Perform platform-specific work that needs to be done after the main event |
140 // loop has ended. | 140 // loop has ended. |
141 void WillTerminate() { | 141 void WillTerminate() { |
142 } | 142 } |
143 #endif | 143 #endif |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (IDR_DIR_HEADER_HTML == key) | 196 if (IDR_DIR_HEADER_HTML == key) |
197 return base::StringPiece(lazy_dir_lister.Pointer()->html_data); | 197 return base::StringPiece(lazy_dir_lister.Pointer()->html_data); |
198 | 198 |
199 return ResourceBundle::GetSharedInstance().GetRawDataResource(key); | 199 return ResourceBundle::GetSharedInstance().GetRawDataResource(key); |
200 } | 200 } |
201 | 201 |
202 void RunUIMessageLoop(BrowserProcess* browser_process) { | 202 void RunUIMessageLoop(BrowserProcess* browser_process) { |
203 #if defined(TOOLKIT_VIEWS) | 203 #if defined(TOOLKIT_VIEWS) |
204 views::AcceleratorHandler accelerator_handler; | 204 views::AcceleratorHandler accelerator_handler; |
205 MessageLoopForUI::current()->Run(&accelerator_handler); | 205 MessageLoopForUI::current()->Run(&accelerator_handler); |
206 #elif defined(OS_LINUX) | 206 #elif defined(USE_X11) |
207 MessageLoopForUI::current()->Run(NULL); | 207 MessageLoopForUI::current()->Run(NULL); |
208 #elif defined(OS_POSIX) | 208 #elif defined(OS_POSIX) |
209 MessageLoopForUI::current()->Run(); | 209 MessageLoopForUI::current()->Run(); |
210 #endif | 210 #endif |
211 } | 211 } |
212 | 212 |
213 #if defined(OS_POSIX) | 213 #if defined(OS_POSIX) |
214 // See comment below, where sigaction is called. | 214 // See comment below, where sigaction is called. |
215 void SIGCHLDHandler(int signal) { | 215 void SIGCHLDHandler(int signal) { |
216 } | 216 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // on anything since it comes from Cocoa. | 448 // on anything since it comes from Cocoa. |
449 #if !defined(OS_MACOSX) | 449 #if !defined(OS_MACOSX) |
450 if (!parameters.ui_task) { | 450 if (!parameters.ui_task) { |
451 ResourceBundle::InitSharedInstance( | 451 ResourceBundle::InitSharedInstance( |
452 local_state->GetString(prefs::kApplicationLocale)); | 452 local_state->GetString(prefs::kApplicationLocale)); |
453 // We only load the theme dll in the browser process. | 453 // We only load the theme dll in the browser process. |
454 ResourceBundle::GetSharedInstance().LoadThemeResources(); | 454 ResourceBundle::GetSharedInstance().LoadThemeResources(); |
455 } | 455 } |
456 #endif // !defined(OS_MACOSX) | 456 #endif // !defined(OS_MACOSX) |
457 | 457 |
458 #if defined(OS_LINUX) | 458 #if defined(USE_X11) |
459 gtk_util::SetDefaultWindowIcon(); | 459 gtk_util::SetDefaultWindowIcon(); |
460 #endif | 460 #endif |
461 | 461 |
462 #if defined(OS_WIN) | 462 #if defined(OS_WIN) |
463 // This is experimental code. See first_run_win.cc for more info. | 463 // This is experimental code. See first_run_win.cc for more info. |
464 std::wstring try_chrome = | 464 std::wstring try_chrome = |
465 parsed_command_line.GetSwitchValue(switches::kTryChromeAgain); | 465 parsed_command_line.GetSwitchValue(switches::kTryChromeAgain); |
466 if (!try_chrome.empty()) { | 466 if (!try_chrome.empty()) { |
467 Upgrade::TryResult answer = | 467 Upgrade::TryResult answer = |
468 Upgrade::ShowTryChromeDialog(StringToInt(try_chrome)); | 468 Upgrade::ShowTryChromeDialog(StringToInt(try_chrome)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 ProfileManager* profile_manager = browser_process->profile_manager(); | 527 ProfileManager* profile_manager = browser_process->profile_manager(); |
528 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); | 528 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); |
529 if (!profile) { | 529 if (!profile) { |
530 // Ideally, we should be able to run w/o access to disk. For now, we | 530 // Ideally, we should be able to run w/o access to disk. For now, we |
531 // prompt the user to pick a different user-data-dir and restart chrome | 531 // prompt the user to pick a different user-data-dir and restart chrome |
532 // with the new dir. | 532 // with the new dir. |
533 // http://code.google.com/p/chromium/issues/detail?id=11510 | 533 // http://code.google.com/p/chromium/issues/detail?id=11510 |
534 #if defined(OS_WIN) | 534 #if defined(OS_WIN) |
535 user_data_dir = FilePath::FromWStringHack( | 535 user_data_dir = FilePath::FromWStringHack( |
536 UserDataDirDialog::RunUserDataDirDialog(user_data_dir.ToWStringHack())); | 536 UserDataDirDialog::RunUserDataDirDialog(user_data_dir.ToWStringHack())); |
537 #elif defined(OS_LINUX) | 537 #elif defined(OS_LINUX) || defined(OS_FREEBSD) |
538 // TODO(port): fix this. | 538 // TODO(port): fix this. |
539 user_data_dir = FilePath("/tmp"); | 539 user_data_dir = FilePath("/tmp"); |
540 #endif | 540 #endif |
541 #if defined(OS_WIN) || defined(OS_LINUX) | 541 #if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_FREEBSD) |
542 if (!parameters.ui_task && browser_shutdown::delete_resources_on_shutdown) { | 542 if (!parameters.ui_task && browser_shutdown::delete_resources_on_shutdown) { |
543 // Only delete the resources if we're not running tests. If we're running | 543 // Only delete the resources if we're not running tests. If we're running |
544 // tests the resources need to be reused as many places in the UI cache | 544 // tests the resources need to be reused as many places in the UI cache |
545 // SkBitmaps from the ResourceBundle. | 545 // SkBitmaps from the ResourceBundle. |
546 ResourceBundle::CleanupSharedInstance(); | 546 ResourceBundle::CleanupSharedInstance(); |
547 } | 547 } |
548 | 548 |
549 if (!user_data_dir.empty()) { | 549 if (!user_data_dir.empty()) { |
550 // Because of the way CommandLine parses, it's sufficient to append a new | 550 // Because of the way CommandLine parses, it's sufficient to append a new |
551 // --user-data-dir switch. The last flag of the same name wins. | 551 // --user-data-dir switch. The last flag of the same name wins. |
552 // TODO(tc): It would be nice to remove the flag we don't want, but that | 552 // TODO(tc): It would be nice to remove the flag we don't want, but that |
553 // sounds risky if we parse differently than CommandLineToArgvW. | 553 // sounds risky if we parse differently than CommandLineToArgvW. |
554 CommandLine new_command_line = parsed_command_line; | 554 CommandLine new_command_line = parsed_command_line; |
555 new_command_line.AppendSwitchWithValue(switches::kUserDataDir, | 555 new_command_line.AppendSwitchWithValue(switches::kUserDataDir, |
556 user_data_dir.ToWStringHack()); | 556 user_data_dir.ToWStringHack()); |
557 base::LaunchApp(new_command_line, false, false, NULL); | 557 base::LaunchApp(new_command_line, false, false, NULL); |
558 } | 558 } |
559 #endif // defined(OS_WIN) || defined(OS_LINUX) | 559 #endif // defined(OS_WIN) || defined(OS_LINUX) || defined(OS_FREEBSD) |
560 | 560 |
561 return ResultCodes::NORMAL_EXIT; | 561 return ResultCodes::NORMAL_EXIT; |
562 } | 562 } |
563 if (profile->GetBlacklist() && !profile->GetBlacklist()->is_good()) { | 563 if (profile->GetBlacklist() && !profile->GetBlacklist()->is_good()) { |
564 // TODO(idanan): Enable this for other platforms once the dispatching | 564 // TODO(idanan): Enable this for other platforms once the dispatching |
565 // support code has been ported. See ifdefs in message_loop.h. | 565 // support code has been ported. See ifdefs in message_loop.h. |
566 #if defined(OS_WIN) | 566 #if defined(OS_WIN) |
567 bool accepted = BlacklistErrorDialog::RunBlacklistErrorDialog(); | 567 bool accepted = BlacklistErrorDialog::RunBlacklistErrorDialog(); |
568 if (!accepted) | 568 if (!accepted) |
569 return ResultCodes::NORMAL_EXIT; | 569 return ResultCodes::NORMAL_EXIT; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 if (parsed_command_line.HasSwitch(switches::kImport)) | 614 if (parsed_command_line.HasSwitch(switches::kImport)) |
615 return FirstRun::ImportNow(profile, parsed_command_line); | 615 return FirstRun::ImportNow(profile, parsed_command_line); |
616 | 616 |
617 // When another process is running, use it instead of starting us. | 617 // When another process is running, use it instead of starting us. |
618 switch (process_singleton.NotifyOtherProcess()) { | 618 switch (process_singleton.NotifyOtherProcess()) { |
619 case ProcessSingleton::PROCESS_NONE: | 619 case ProcessSingleton::PROCESS_NONE: |
620 // No process already running, fall through to starting a new one. | 620 // No process already running, fall through to starting a new one. |
621 break; | 621 break; |
622 | 622 |
623 case ProcessSingleton::PROCESS_NOTIFIED: | 623 case ProcessSingleton::PROCESS_NOTIFIED: |
624 #if defined(OS_LINUX) | 624 #if defined(OS_LINUX) || defined(OS_FREEBSD) |
625 printf("%s\n", base::SysWideToNativeMB( | 625 printf("%s\n", base::SysWideToNativeMB( |
626 l10n_util::GetString(IDS_USED_EXISTING_BROWSER)).c_str()); | 626 l10n_util::GetString(IDS_USED_EXISTING_BROWSER)).c_str()); |
627 #endif | 627 #endif |
628 return ResultCodes::NORMAL_EXIT; | 628 return ResultCodes::NORMAL_EXIT; |
629 | 629 |
630 case ProcessSingleton::PROFILE_IN_USE: | 630 case ProcessSingleton::PROFILE_IN_USE: |
631 return ResultCodes::PROFILE_IN_USE; | 631 return ResultCodes::PROFILE_IN_USE; |
632 | 632 |
633 default: | 633 default: |
634 NOTREACHED(); | 634 NOTREACHED(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 if (metrics) | 858 if (metrics) |
859 metrics->Stop(); | 859 metrics->Stop(); |
860 | 860 |
861 // browser_shutdown takes care of deleting browser_process, so we need to | 861 // browser_shutdown takes care of deleting browser_process, so we need to |
862 // release it. | 862 // release it. |
863 browser_process.release(); | 863 browser_process.release(); |
864 browser_shutdown::Shutdown(); | 864 browser_shutdown::Shutdown(); |
865 | 865 |
866 return result_code; | 866 return result_code; |
867 } | 867 } |
OLD | NEW |