| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/browser_main_win.h" | 34 #include "chrome/browser/browser_main_win.h" |
| 35 #include "chrome/browser/chrome_content_browser_client.h" | 35 #include "chrome/browser/chrome_content_browser_client.h" |
| 36 #include "chrome/browser/defaults.h" | 36 #include "chrome/browser/defaults.h" |
| 37 #include "chrome/browser/browser_process.h" | 37 #include "chrome/browser/browser_process.h" |
| 38 #include "chrome/browser/browser_process_impl.h" | 38 #include "chrome/browser/browser_process_impl.h" |
| 39 #include "chrome/browser/browser_shutdown.h" | 39 #include "chrome/browser/browser_shutdown.h" |
| 40 #include "chrome/browser/extensions/extension_protocols.h" | 40 #include "chrome/browser/extensions/extension_protocols.h" |
| 41 #include "chrome/browser/extensions/extension_service.h" | 41 #include "chrome/browser/extensions/extension_service.h" |
| 42 #include "chrome/browser/extensions/extensions_startup.h" | 42 #include "chrome/browser/extensions/extensions_startup.h" |
| 43 #include "chrome/browser/first_run/first_run.h" | 43 #include "chrome/browser/first_run/first_run.h" |
| 44 #include "chrome/browser/first_run/upgrade_util.h" | 44 #include "chrome/browser/first_run/upgrade.h" |
| 45 #include "chrome/browser/gpu_data_manager.h" | 45 #include "chrome/browser/gpu_data_manager.h" |
| 46 #include "chrome/browser/jankometer.h" | 46 #include "chrome/browser/jankometer.h" |
| 47 #include "chrome/browser/metrics/histogram_synchronizer.h" | 47 #include "chrome/browser/metrics/histogram_synchronizer.h" |
| 48 #include "chrome/browser/metrics/metrics_log.h" | 48 #include "chrome/browser/metrics/metrics_log.h" |
| 49 #include "chrome/browser/metrics/metrics_service.h" | 49 #include "chrome/browser/metrics/metrics_service.h" |
| 50 #include "chrome/browser/metrics/thread_watcher.h" | 50 #include "chrome/browser/metrics/thread_watcher.h" |
| 51 #include "chrome/browser/net/blob_url_request_job_factory.h" | 51 #include "chrome/browser/net/blob_url_request_job_factory.h" |
| 52 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" | 52 #include "chrome/browser/net/chrome_dns_cert_provenance_checker.h" |
| 53 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" | 53 #include "chrome/browser/net/chrome_dns_cert_provenance_checker_factory.h" |
| 54 #include "chrome/browser/net/file_system_url_request_job_factory.h" | 54 #include "chrome/browser/net/file_system_url_request_job_factory.h" |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 1045 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
| 1046 extern "C" { | 1046 extern "C" { |
| 1047 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 1047 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 1050 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 1051 // Need an instance of AtExitManager to handle singleton creations and | 1051 // Need an instance of AtExitManager to handle singleton creations and |
| 1052 // deletions. We need this new instance because, the old instance created | 1052 // deletions. We need this new instance because, the old instance created |
| 1053 // in ChromeMain() got destructed when the function returned. | 1053 // in ChromeMain() got destructed when the function returned. |
| 1054 base::AtExitManager exit_manager; | 1054 base::AtExitManager exit_manager; |
| 1055 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 1055 Upgrade::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 1056 } | 1056 } |
| 1057 #endif | 1057 #endif |
| 1058 | 1058 |
| 1059 #if defined(USE_LINUX_BREAKPAD) | 1059 #if defined(USE_LINUX_BREAKPAD) |
| 1060 bool IsMetricsReportingEnabled(const PrefService* local_state) { | 1060 bool IsMetricsReportingEnabled(const PrefService* local_state) { |
| 1061 // Check whether we should initialize the crash reporter. It may be disabled | 1061 // Check whether we should initialize the crash reporter. It may be disabled |
| 1062 // through configuration policy or user preference. | 1062 // through configuration policy or user preference. |
| 1063 // The kHeadless environment variable overrides the decision, but only if the | 1063 // The kHeadless environment variable overrides the decision, but only if the |
| 1064 // crash service is under control of the user. It is used by QA testing | 1064 // crash service is under control of the user. It is used by QA testing |
| 1065 // infrastructure to switch on generation of crash reports. | 1065 // infrastructure to switch on generation of crash reports. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1227 std::string try_chrome = | 1227 std::string try_chrome = |
| 1228 parsed_command_line.GetSwitchValueASCII(switches::kTryChromeAgain); | 1228 parsed_command_line.GetSwitchValueASCII(switches::kTryChromeAgain); |
| 1229 if (!try_chrome.empty()) { | 1229 if (!try_chrome.empty()) { |
| 1230 #if defined(OS_WIN) | 1230 #if defined(OS_WIN) |
| 1231 // Setup.exe has determined that we need to run a retention experiment | 1231 // Setup.exe has determined that we need to run a retention experiment |
| 1232 // and has lauched chrome to show the experiment UI. | 1232 // and has lauched chrome to show the experiment UI. |
| 1233 if (process_singleton.FoundOtherProcessWindow()) { | 1233 if (process_singleton.FoundOtherProcessWindow()) { |
| 1234 // It seems that we don't need to run the experiment since chrome | 1234 // It seems that we don't need to run the experiment since chrome |
| 1235 // in the same profile is already running. | 1235 // in the same profile is already running. |
| 1236 VLOG(1) << "Retention experiment not required"; | 1236 VLOG(1) << "Retention experiment not required"; |
| 1237 return upgrade_util::NOT_NOW; | 1237 return Upgrade::NOT_NOW; |
| 1238 } | 1238 } |
| 1239 int try_chrome_int; | 1239 int try_chrome_int; |
| 1240 base::StringToInt(try_chrome, &try_chrome_int); | 1240 base::StringToInt(try_chrome, &try_chrome_int); |
| 1241 upgrade_util::TryResult answer = | 1241 Upgrade::TryResult answer = |
| 1242 upgrade_util::ShowTryChromeDialog(try_chrome_int, &process_singleton); | 1242 Upgrade::ShowTryChromeDialog(try_chrome_int, &process_singleton); |
| 1243 if (answer == upgrade_util::NOT_NOW) | 1243 if (answer == Upgrade::NOT_NOW) |
| 1244 return ResultCodes::NORMAL_EXIT_CANCEL; | 1244 return ResultCodes::NORMAL_EXIT_CANCEL; |
| 1245 if (answer == upgrade_util::UNINSTALL_CHROME) | 1245 if (answer == Upgrade::UNINSTALL_CHROME) |
| 1246 return ResultCodes::NORMAL_EXIT_EXP2; | 1246 return ResultCodes::NORMAL_EXIT_EXP2; |
| 1247 #else | 1247 #else |
| 1248 // We don't support retention experiments on Mac or Linux. | 1248 // We don't support retention experiments on Mac or Linux. |
| 1249 return ResultCodes::NORMAL_EXIT; | 1249 return ResultCodes::NORMAL_EXIT; |
| 1250 #endif // defined(OS_WIN) | 1250 #endif // defined(OS_WIN) |
| 1251 } | 1251 } |
| 1252 | 1252 |
| 1253 BrowserInit browser_init; | 1253 BrowserInit browser_init; |
| 1254 | 1254 |
| 1255 // On first run, we need to process the predictor preferences before the | 1255 // On first run, we need to process the predictor preferences before the |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 chromeos::OwnershipService::GetSharedInstance(); | 1335 chromeos::OwnershipService::GetSharedInstance(); |
| 1336 #endif | 1336 #endif |
| 1337 | 1337 |
| 1338 // Record last shutdown time into a histogram. | 1338 // Record last shutdown time into a histogram. |
| 1339 browser_shutdown::ReadLastShutdownInfo(); | 1339 browser_shutdown::ReadLastShutdownInfo(); |
| 1340 | 1340 |
| 1341 #if defined(OS_WIN) | 1341 #if defined(OS_WIN) |
| 1342 // On Windows, we use our startup as an opportunity to do upgrade/uninstall | 1342 // On Windows, we use our startup as an opportunity to do upgrade/uninstall |
| 1343 // tasks. Those care whether the browser is already running. On Linux/Mac, | 1343 // tasks. Those care whether the browser is already running. On Linux/Mac, |
| 1344 // upgrade/uninstall happen separately. | 1344 // upgrade/uninstall happen separately. |
| 1345 bool already_running = upgrade_util::IsBrowserAlreadyRunning(); | 1345 bool already_running = Upgrade::IsBrowserAlreadyRunning(); |
| 1346 | 1346 |
| 1347 // If the command line specifies 'uninstall' then we need to work here | 1347 // If the command line specifies 'uninstall' then we need to work here |
| 1348 // unless we detect another chrome browser running. | 1348 // unless we detect another chrome browser running. |
| 1349 if (parsed_command_line.HasSwitch(switches::kUninstall)) | 1349 if (parsed_command_line.HasSwitch(switches::kUninstall)) |
| 1350 return DoUninstallTasks(already_running); | 1350 return DoUninstallTasks(already_running); |
| 1351 #endif | 1351 #endif |
| 1352 | 1352 |
| 1353 if (parsed_command_line.HasSwitch(switches::kHideIcons) || | 1353 if (parsed_command_line.HasSwitch(switches::kHideIcons) || |
| 1354 parsed_command_line.HasSwitch(switches::kShowIcons)) | 1354 parsed_command_line.HasSwitch(switches::kShowIcons)) |
| 1355 return HandleIconsCommands(parsed_command_line); | 1355 return HandleIconsCommands(parsed_command_line); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 // TODO(port): Port the Mac's IPC-based implementation to other platforms to | 1478 // TODO(port): Port the Mac's IPC-based implementation to other platforms to |
| 1479 // replace this implementation. http://crbug.com/22142 | 1479 // replace this implementation. http://crbug.com/22142 |
| 1480 if (parsed_command_line.HasSwitch(switches::kImport) || | 1480 if (parsed_command_line.HasSwitch(switches::kImport) || |
| 1481 parsed_command_line.HasSwitch(switches::kImportFromFile)) { | 1481 parsed_command_line.HasSwitch(switches::kImportFromFile)) { |
| 1482 return FirstRun::ImportNow(profile, parsed_command_line); | 1482 return FirstRun::ImportNow(profile, parsed_command_line); |
| 1483 } | 1483 } |
| 1484 #endif | 1484 #endif |
| 1485 | 1485 |
| 1486 #if defined(OS_WIN) | 1486 #if defined(OS_WIN) |
| 1487 // Do the tasks if chrome has been upgraded while it was last running. | 1487 // Do the tasks if chrome has been upgraded while it was last running. |
| 1488 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line)) | 1488 if (!already_running && Upgrade::DoUpgradeTasks(parsed_command_line)) |
| 1489 return ResultCodes::NORMAL_EXIT; | 1489 return ResultCodes::NORMAL_EXIT; |
| 1490 #endif | 1490 #endif |
| 1491 | 1491 |
| 1492 // Check if there is any machine level Chrome installed on the current | 1492 // Check if there is any machine level Chrome installed on the current |
| 1493 // machine. If yes and the current Chrome process is user level, we do not | 1493 // machine. If yes and the current Chrome process is user level, we do not |
| 1494 // allow the user level Chrome to run. So we notify the user and uninstall | 1494 // allow the user level Chrome to run. So we notify the user and uninstall |
| 1495 // user level Chrome. | 1495 // user level Chrome. |
| 1496 // Note this check should only happen here, after all the checks above | 1496 // Note this check should only happen here, after all the checks above |
| 1497 // (uninstall, resource bundle initialization, other chrome browser | 1497 // (uninstall, resource bundle initialization, other chrome browser |
| 1498 // processes etc). | 1498 // processes etc). |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 // the main thread. This needs to be done here because we don't want | 1796 // the main thread. This needs to be done here because we don't want |
| 1797 // to start the timer when Chrome is run inside a test harness. | 1797 // to start the timer when Chrome is run inside a test harness. |
| 1798 g_browser_process->StartAutoupdateTimer(); | 1798 g_browser_process->StartAutoupdateTimer(); |
| 1799 #endif | 1799 #endif |
| 1800 | 1800 |
| 1801 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1801 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1802 // On Linux, the running exe will be updated if an upgrade becomes | 1802 // On Linux, the running exe will be updated if an upgrade becomes |
| 1803 // available while the browser is running. We need to save the last | 1803 // available while the browser is running. We need to save the last |
| 1804 // modified time of the exe, so we can compare to determine if there is | 1804 // modified time of the exe, so we can compare to determine if there is |
| 1805 // an upgrade while the browser is kept alive by a persistent extension. | 1805 // an upgrade while the browser is kept alive by a persistent extension. |
| 1806 upgrade_util::SaveLastModifiedTimeOfExe(); | 1806 Upgrade::SaveLastModifiedTimeOfExe(); |
| 1807 #endif | 1807 #endif |
| 1808 | 1808 |
| 1809 // Record now as the last successful chrome start. | 1809 // Record now as the last successful chrome start. |
| 1810 GoogleUpdateSettings::SetLastRunTime(); | 1810 GoogleUpdateSettings::SetLastRunTime(); |
| 1811 // Call Recycle() here as late as possible, before going into the loop | 1811 // Call Recycle() here as late as possible, before going into the loop |
| 1812 // because Start() will add things to it while creating the main window. | 1812 // because Start() will add things to it while creating the main window. |
| 1813 if (pool) | 1813 if (pool) |
| 1814 pool->Recycle(); | 1814 pool->Recycle(); |
| 1815 RunUIMessageLoop(browser_process.get()); | 1815 RunUIMessageLoop(browser_process.get()); |
| 1816 } | 1816 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 #if defined(OS_CHROMEOS) | 1877 #if defined(OS_CHROMEOS) |
| 1878 // To be precise, logout (browser shutdown) is not yet done, but the | 1878 // To be precise, logout (browser shutdown) is not yet done, but the |
| 1879 // remaining work is negligible, hence we say LogoutDone here. | 1879 // remaining work is negligible, hence we say LogoutDone here. |
| 1880 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 1880 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 1881 false); | 1881 false); |
| 1882 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 1882 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 1883 #endif | 1883 #endif |
| 1884 TRACE_EVENT_END("BrowserMain", 0, 0); | 1884 TRACE_EVENT_END("BrowserMain", 0, 0); |
| 1885 return result_code; | 1885 return result_code; |
| 1886 } | 1886 } |
| OLD | NEW |