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 "chrome/browser/browser_main.h" | 5 #include "chrome/browser/browser_main.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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 271 |
272 // Initialize statistical testing infrastructure. | 272 // Initialize statistical testing infrastructure. |
273 FieldTrialList field_trial; | 273 FieldTrialList field_trial; |
274 | 274 |
275 std::wstring app_name = chrome::kBrowserAppName; | 275 std::wstring app_name = chrome::kBrowserAppName; |
276 std::string thread_name_string = WideToASCII(app_name + L"_BrowserMain"); | 276 std::string thread_name_string = WideToASCII(app_name + L"_BrowserMain"); |
277 | 277 |
278 const char* thread_name = thread_name_string.c_str(); | 278 const char* thread_name = thread_name_string.c_str(); |
279 PlatformThread::SetName(thread_name); | 279 PlatformThread::SetName(thread_name); |
280 main_message_loop.set_thread_name(thread_name); | 280 main_message_loop.set_thread_name(thread_name); |
281 bool already_running = Upgrade::IsBrowserAlreadyRunning(); | |
282 | 281 |
283 // Register the main thread by instantiating it, but don't call any methods. | 282 // Register the main thread by instantiating it, but don't call any methods. |
284 ChromeThread main_thread; | 283 ChromeThread main_thread; |
285 | 284 |
286 FilePath user_data_dir; | 285 FilePath user_data_dir; |
287 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 286 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
288 ProcessSingleton process_singleton(user_data_dir); | 287 ProcessSingleton process_singleton(user_data_dir); |
289 | 288 |
290 bool is_first_run = FirstRun::IsChromeFirstRun() || | 289 bool is_first_run = FirstRun::IsChromeFirstRun() || |
291 parsed_command_line.HasSwitch(switches::kFirstRun); | 290 parsed_command_line.HasSwitch(switches::kFirstRun); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 if (answer == Upgrade::TD_UNINSTALL_CHROME) | 428 if (answer == Upgrade::TD_UNINSTALL_CHROME) |
430 return ResultCodes::NORMAL_EXIT_EXP2; | 429 return ResultCodes::NORMAL_EXIT_EXP2; |
431 } | 430 } |
432 #endif // OS_WIN | 431 #endif // OS_WIN |
433 | 432 |
434 BrowserInit browser_init; | 433 BrowserInit browser_init; |
435 | 434 |
436 int rlz_ping_delay = 0; | 435 int rlz_ping_delay = 0; |
437 bool homepage_defined = false; | 436 bool homepage_defined = false; |
438 if (is_first_run) { | 437 if (is_first_run) { |
439 // On first run, we need to process the master preferences before the | 438 // On first run, we need to process the master preferences before the |
440 // browser's profile_manager object is created, but after ResourceBundle | 439 // browser's profile_manager object is created, but after ResourceBundle |
441 // is initialized. | 440 // is initialized. |
442 std::vector<std::wstring> first_run_tabs; | 441 std::vector<std::wstring> first_run_tabs; |
443 first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir, | 442 first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir, |
444 FilePath(), &first_run_tabs, &rlz_ping_delay, &homepage_defined); | 443 FilePath(), &first_run_tabs, &rlz_ping_delay, &homepage_defined); |
445 // The master prefs might specify a set of urls to display. | 444 // The master prefs might specify a set of urls to display. |
446 if (first_run_tabs.size()) | 445 if (first_run_tabs.size()) |
447 AddFirstRunNewTabs(&browser_init, first_run_tabs); | 446 AddFirstRunNewTabs(&browser_init, first_run_tabs); |
448 | 447 |
449 // If we are running in App mode, we do not want to show the importer | 448 // If we are running in App mode, we do not want to show the importer |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 int64 install_date = | 543 int64 install_date = |
545 local_state->GetInt64(prefs::kUninstallMetricsInstallDate); | 544 local_state->GetInt64(prefs::kUninstallMetricsInstallDate); |
546 if (install_date == 0) { | 545 if (install_date == 0) { |
547 local_state->SetInt64(prefs::kUninstallMetricsInstallDate, | 546 local_state->SetInt64(prefs::kUninstallMetricsInstallDate, |
548 base::Time::Now().ToTimeT()); | 547 base::Time::Now().ToTimeT()); |
549 } | 548 } |
550 | 549 |
551 #if defined(OS_WIN) | 550 #if defined(OS_WIN) |
552 // Record last shutdown time into a histogram. | 551 // Record last shutdown time into a histogram. |
553 browser_shutdown::ReadLastShutdownInfo(); | 552 browser_shutdown::ReadLastShutdownInfo(); |
554 #endif | 553 |
| 554 // On Windows, we use our startup as an opportunity to do upgrade/uninstall |
| 555 // tasks. Those care whether the browser is already running. On Linux/Mac, |
| 556 // upgrade/uninstall happen separately. |
| 557 bool already_running = Upgrade::IsBrowserAlreadyRunning(); |
555 | 558 |
556 // If the command line specifies 'uninstall' then we need to work here | 559 // If the command line specifies 'uninstall' then we need to work here |
557 // unless we detect another chrome browser running. | 560 // unless we detect another chrome browser running. |
558 if (parsed_command_line.HasSwitch(switches::kUninstall)) | 561 if (parsed_command_line.HasSwitch(switches::kUninstall)) |
559 return DoUninstallTasks(already_running); | 562 return DoUninstallTasks(already_running); |
| 563 #endif |
560 | 564 |
561 if (parsed_command_line.HasSwitch(switches::kHideIcons) || | 565 if (parsed_command_line.HasSwitch(switches::kHideIcons) || |
562 parsed_command_line.HasSwitch(switches::kShowIcons)) { | 566 parsed_command_line.HasSwitch(switches::kShowIcons)) { |
563 return HandleIconsCommands(parsed_command_line); | 567 return HandleIconsCommands(parsed_command_line); |
564 } else if (parsed_command_line.HasSwitch(switches::kMakeDefaultBrowser)) { | 568 } else if (parsed_command_line.HasSwitch(switches::kMakeDefaultBrowser)) { |
565 if (ShellIntegration::SetAsDefaultBrowser()) { | 569 if (ShellIntegration::SetAsDefaultBrowser()) { |
566 return ResultCodes::NORMAL_EXIT; | 570 return ResultCodes::NORMAL_EXIT; |
567 } else { | 571 } else { |
568 return ResultCodes::SHELL_INTEGRATION_FAILED; | 572 return ResultCodes::SHELL_INTEGRATION_FAILED; |
569 } | 573 } |
(...skipping 17 matching lines...) Expand all Loading... |
587 #endif | 591 #endif |
588 return ResultCodes::NORMAL_EXIT; | 592 return ResultCodes::NORMAL_EXIT; |
589 | 593 |
590 case ProcessSingleton::PROFILE_IN_USE: | 594 case ProcessSingleton::PROFILE_IN_USE: |
591 return ResultCodes::PROFILE_IN_USE; | 595 return ResultCodes::PROFILE_IN_USE; |
592 | 596 |
593 default: | 597 default: |
594 NOTREACHED(); | 598 NOTREACHED(); |
595 } | 599 } |
596 | 600 |
| 601 #if defined(OS_WIN) |
597 // Do the tasks if chrome has been upgraded while it was last running. | 602 // Do the tasks if chrome has been upgraded while it was last running. |
598 if (!already_running && DoUpgradeTasks(parsed_command_line)) { | 603 if (!already_running && DoUpgradeTasks(parsed_command_line)) { |
599 return ResultCodes::NORMAL_EXIT; | 604 return ResultCodes::NORMAL_EXIT; |
600 } | 605 } |
| 606 #endif |
601 | 607 |
602 // Check if there is any machine level Chrome installed on the current | 608 // Check if there is any machine level Chrome installed on the current |
603 // machine. If yes and the current Chrome process is user level, we do not | 609 // machine. If yes and the current Chrome process is user level, we do not |
604 // allow the user level Chrome to run. So we notify the user and uninstall | 610 // allow the user level Chrome to run. So we notify the user and uninstall |
605 // user level Chrome. | 611 // user level Chrome. |
606 // Note this check should only happen here, after all the checks above | 612 // Note this check should only happen here, after all the checks above |
607 // (uninstall, resource bundle initialization, other chrome browser | 613 // (uninstall, resource bundle initialization, other chrome browser |
608 // processes etc). | 614 // processes etc). |
609 if (CheckMachineLevelInstall()) | 615 if (CheckMachineLevelInstall()) |
610 return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS; | 616 return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 if (metrics) | 824 if (metrics) |
819 metrics->Stop(); | 825 metrics->Stop(); |
820 | 826 |
821 // browser_shutdown takes care of deleting browser_process, so we need to | 827 // browser_shutdown takes care of deleting browser_process, so we need to |
822 // release it. | 828 // release it. |
823 browser_process.release(); | 829 browser_process.release(); |
824 browser_shutdown::Shutdown(); | 830 browser_shutdown::Shutdown(); |
825 | 831 |
826 return result_code; | 832 return result_code; |
827 } | 833 } |
OLD | NEW |