| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 129 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
| 130 // other platforms. For now, it's just a stub. This is a serious work in | 130 // other platforms. For now, it's just a stub. This is a serious work in |
| 131 // progress and should not be taken as an indication of a real refactoring. | 131 // progress and should not be taken as an indication of a real refactoring. |
| 132 | 132 |
| 133 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
| 134 #include <commctrl.h> | 134 #include <commctrl.h> |
| 135 #include <shellapi.h> | 135 #include <shellapi.h> |
| 136 #include <windows.h> | 136 #include <windows.h> |
| 137 | 137 |
| 138 #include "app/win/scoped_com_initializer.h" | 138 #include "app/win/scoped_com_initializer.h" |
| 139 #include "base/win/windows_version.h" |
| 139 #include "chrome/browser/browser_trial.h" | 140 #include "chrome/browser/browser_trial.h" |
| 140 #include "chrome/browser/metrics/user_metrics.h" | 141 #include "chrome/browser/metrics/user_metrics.h" |
| 141 #include "chrome/browser/net/url_fixer_upper.h" | 142 #include "chrome/browser/net/url_fixer_upper.h" |
| 142 #include "chrome/browser/rlz/rlz.h" | 143 #include "chrome/browser/rlz/rlz.h" |
| 143 #include "chrome/browser/ui/views/user_data_dir_dialog.h" | 144 #include "chrome/browser/ui/views/user_data_dir_dialog.h" |
| 144 #include "chrome/common/sandbox_policy.h" | 145 #include "chrome/common/sandbox_policy.h" |
| 145 #include "chrome/installer/util/helper.h" | 146 #include "chrome/installer/util/helper.h" |
| 146 #include "chrome/installer/util/install_util.h" | 147 #include "chrome/installer/util/install_util.h" |
| 147 #include "chrome/installer/util/shell_util.h" | 148 #include "chrome/installer/util/shell_util.h" |
| 148 #include "net/base/net_util.h" | 149 #include "net/base/net_util.h" |
| (...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 } // if (!first_run_ui_bypass) | 1554 } // if (!first_run_ui_bypass) |
| 1554 | 1555 |
| 1555 Browser::SetNewHomePagePrefs(user_prefs); | 1556 Browser::SetNewHomePagePrefs(user_prefs); |
| 1556 } | 1557 } |
| 1557 | 1558 |
| 1558 // Sets things up so that if we crash from this point on, a dialog will | 1559 // Sets things up so that if we crash from this point on, a dialog will |
| 1559 // popup asking the user to restart chrome. It is done this late to avoid | 1560 // popup asking the user to restart chrome. It is done this late to avoid |
| 1560 // testing against a bunch of special cases that are taken care early on. | 1561 // testing against a bunch of special cases that are taken care early on. |
| 1561 PrepareRestartOnCrashEnviroment(parsed_command_line); | 1562 PrepareRestartOnCrashEnviroment(parsed_command_line); |
| 1562 | 1563 |
| 1564 #if defined(OS_WIN) |
| 1565 // Registers Chrome with the Windows Restart Manager, which will restore the |
| 1566 // Chrome session when the computer is restarted after a system update. |
| 1567 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
| 1568 // but should run on startup if extended to handle crashes/hangs/patches. |
| 1569 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
| 1570 if (base::win::GetVersion() >= base::win::VERSION_VISTA) |
| 1571 DCHECK(RegisterApplicationRestart(parsed_command_line)); |
| 1572 #endif // OS_WIN |
| 1573 |
| 1563 // Initialize and maintain network predictor module, which handles DNS | 1574 // Initialize and maintain network predictor module, which handles DNS |
| 1564 // pre-resolution, as well as TCP/IP connection pre-warming. | 1575 // pre-resolution, as well as TCP/IP connection pre-warming. |
| 1565 // This also registers an observer to discard data when closing incognito | 1576 // This also registers an observer to discard data when closing incognito |
| 1566 // mode. | 1577 // mode. |
| 1567 bool preconnect_enabled = true; // Default status (easy to change!). | 1578 bool preconnect_enabled = true; // Default status (easy to change!). |
| 1568 if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) | 1579 if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) |
| 1569 preconnect_enabled = false; | 1580 preconnect_enabled = false; |
| 1570 else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) | 1581 else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) |
| 1571 preconnect_enabled = true; | 1582 preconnect_enabled = true; |
| 1572 chrome_browser_net::PredictorInit dns_prefetch( | 1583 chrome_browser_net::PredictorInit dns_prefetch( |
| 1573 user_prefs, | 1584 user_prefs, |
| 1574 local_state, | 1585 local_state, |
| 1575 preconnect_enabled); | 1586 preconnect_enabled); |
| 1576 | 1587 |
| 1577 #if defined(OS_WIN) | 1588 #if defined(OS_WIN) |
| 1578 app::win::ScopedCOMInitializer com_initializer; | 1589 app::win::ScopedCOMInitializer com_initializer; |
| 1579 | 1590 |
| 1580 #if defined(GOOGLE_CHROME_BUILD) | 1591 #if defined(GOOGLE_CHROME_BUILD) |
| 1581 // Init the RLZ library. This just binds the dll and schedules a task on the | 1592 // Init the RLZ library. This just binds the dll and schedules a task on the |
| 1582 // file thread to be run sometime later. If this is the first run we record | 1593 // file thread to be run sometime later. If this is the first run we record |
| 1583 // the installation event. | 1594 // the installation event. |
| 1584 RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay); | 1595 RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay); |
| 1585 #endif | 1596 #endif // GOOGLE_CHROME_BUILD |
| 1586 #endif | 1597 #endif // OS_WIN |
| 1587 | 1598 |
| 1588 // Configure modules that need access to resources. | 1599 // Configure modules that need access to resources. |
| 1589 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1600 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
| 1590 gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider); | 1601 gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider); |
| 1591 | 1602 |
| 1592 // Register our global network handler for chrome:// and | 1603 // Register our global network handler for chrome:// and |
| 1593 // chrome-extension:// URLs. | 1604 // chrome-extension:// URLs. |
| 1594 ChromeURLDataManagerBackend::Register(); | 1605 ChromeURLDataManagerBackend::Register(); |
| 1595 RegisterExtensionProtocols(); | 1606 RegisterExtensionProtocols(); |
| 1596 RegisterMetadataURLRequestHandler(); | 1607 RegisterMetadataURLRequestHandler(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 profile->GetCloudPrintProxyService(); | 1767 profile->GetCloudPrintProxyService(); |
| 1757 | 1768 |
| 1758 int result_code = ResultCodes::NORMAL_EXIT; | 1769 int result_code = ResultCodes::NORMAL_EXIT; |
| 1759 if (parameters.ui_task) { | 1770 if (parameters.ui_task) { |
| 1760 // We are in test mode. Run one task and enter the main message loop. | 1771 // We are in test mode. Run one task and enter the main message loop. |
| 1761 if (pool) | 1772 if (pool) |
| 1762 pool->Recycle(); | 1773 pool->Recycle(); |
| 1763 parameters.ui_task->Run(); | 1774 parameters.ui_task->Run(); |
| 1764 delete parameters.ui_task; | 1775 delete parameters.ui_task; |
| 1765 } else { | 1776 } else { |
| 1766 // We are in regular browser boot sequence. Open initial stabs and enter | 1777 // We are in regular browser boot sequence. Open initial tabs and enter the |
| 1767 // the main message loop. | 1778 // main message loop. |
| 1768 if (browser_init.Start(parsed_command_line, FilePath(), profile, | 1779 if (browser_init.Start(parsed_command_line, FilePath(), profile, |
| 1769 &result_code)) { | 1780 &result_code)) { |
| 1770 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1781 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 1771 // Initialize autoupdate timer. Timer callback costs basically nothing | 1782 // Initialize autoupdate timer. Timer callback costs basically nothing |
| 1772 // when browser is not in persistent mode, so it's OK to let it ride on | 1783 // when browser is not in persistent mode, so it's OK to let it ride on |
| 1773 // the main thread. This needs to be done here because we don't want | 1784 // the main thread. This needs to be done here because we don't want |
| 1774 // to start the timer when Chrome is run inside a test harness. | 1785 // to start the timer when Chrome is run inside a test harness. |
| 1775 g_browser_process->StartAutoupdateTimer(); | 1786 g_browser_process->StartAutoupdateTimer(); |
| 1776 #endif | 1787 #endif |
| 1777 | 1788 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1851 #if defined(OS_CHROMEOS) | 1862 #if defined(OS_CHROMEOS) |
| 1852 // To be precise, logout (browser shutdown) is not yet done, but the | 1863 // To be precise, logout (browser shutdown) is not yet done, but the |
| 1853 // remaining work is negligible, hence we say LogoutDone here. | 1864 // remaining work is negligible, hence we say LogoutDone here. |
| 1854 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 1865 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 1855 false); | 1866 false); |
| 1856 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 1867 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 1857 #endif | 1868 #endif |
| 1858 TRACE_EVENT_END("BrowserMain", 0, 0); | 1869 TRACE_EVENT_END("BrowserMain", 0, 0); |
| 1859 return result_code; | 1870 return result_code; |
| 1860 } | 1871 } |
| OLD | NEW |