| 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 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1576     }  // if (!first_run_ui_bypass) | 1577     }  // if (!first_run_ui_bypass) | 
| 1577 | 1578 | 
| 1578     Browser::SetNewHomePagePrefs(user_prefs); | 1579     Browser::SetNewHomePagePrefs(user_prefs); | 
| 1579   } | 1580   } | 
| 1580 | 1581 | 
| 1581   // Sets things up so that if we crash from this point on, a dialog will | 1582   // Sets things up so that if we crash from this point on, a dialog will | 
| 1582   // popup asking the user to restart chrome. It is done this late to avoid | 1583   // popup asking the user to restart chrome. It is done this late to avoid | 
| 1583   // testing against a bunch of special cases that are taken care early on. | 1584   // testing against a bunch of special cases that are taken care early on. | 
| 1584   PrepareRestartOnCrashEnviroment(parsed_command_line); | 1585   PrepareRestartOnCrashEnviroment(parsed_command_line); | 
| 1585 | 1586 | 
|  | 1587 #if defined(OS_WIN) | 
|  | 1588   // Registers Chrome with the Windows Restart Manager, which will restore the | 
|  | 1589   // Chrome session when the computer is restarted after a system update. | 
|  | 1590   // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 
|  | 1591   // but should run on startup if extended to handle crashes/hangs/patches. | 
|  | 1592   // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 
|  | 1593   if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 
|  | 1594     DCHECK(RegisterApplicationRestart(parsed_command_line)); | 
|  | 1595 #endif  // OS_WIN | 
|  | 1596 | 
| 1586   // Initialize and maintain network predictor module, which handles DNS | 1597   // Initialize and maintain network predictor module, which handles DNS | 
| 1587   // pre-resolution, as well as TCP/IP connection pre-warming. | 1598   // pre-resolution, as well as TCP/IP connection pre-warming. | 
| 1588   // This also registers an observer to discard data when closing incognito | 1599   // This also registers an observer to discard data when closing incognito | 
| 1589   // mode. | 1600   // mode. | 
| 1590   bool preconnect_enabled = true;  // Default status (easy to change!). | 1601   bool preconnect_enabled = true;  // Default status (easy to change!). | 
| 1591   if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) | 1602   if (parsed_command_line.HasSwitch(switches::kDisablePreconnect)) | 
| 1592     preconnect_enabled = false; | 1603     preconnect_enabled = false; | 
| 1593   else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) | 1604   else if (parsed_command_line.HasSwitch(switches::kEnablePreconnect)) | 
| 1594     preconnect_enabled = true; | 1605     preconnect_enabled = true; | 
| 1595   chrome_browser_net::PredictorInit dns_prefetch( | 1606   chrome_browser_net::PredictorInit dns_prefetch( | 
| 1596       user_prefs, | 1607       user_prefs, | 
| 1597       local_state, | 1608       local_state, | 
| 1598       preconnect_enabled); | 1609       preconnect_enabled); | 
| 1599 | 1610 | 
| 1600 #if defined(OS_WIN) | 1611 #if defined(OS_WIN) | 
| 1601   app::win::ScopedCOMInitializer com_initializer; | 1612   app::win::ScopedCOMInitializer com_initializer; | 
| 1602 | 1613 | 
| 1603 #if defined(GOOGLE_CHROME_BUILD) | 1614 #if defined(GOOGLE_CHROME_BUILD) | 
| 1604   // Init the RLZ library. This just binds the dll and schedules a task on the | 1615   // Init the RLZ library. This just binds the dll and schedules a task on the | 
| 1605   // file thread to be run sometime later. If this is the first run we record | 1616   // file thread to be run sometime later. If this is the first run we record | 
| 1606   // the installation event. | 1617   // the installation event. | 
| 1607   RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay); | 1618   RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay); | 
| 1608 #endif | 1619 #endif  // GOOGLE_CHROME_BUILD | 
| 1609 #endif | 1620 #endif  // OS_WIN | 
| 1610 | 1621 | 
| 1611   // Configure modules that need access to resources. | 1622   // Configure modules that need access to resources. | 
| 1612   net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1623   net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 
| 1613   gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider); | 1624   gfx::GfxModule::SetResourceProvider(chrome::GfxResourceProvider); | 
| 1614 | 1625 | 
| 1615   // Register our global network handler for chrome:// and | 1626   // Register our global network handler for chrome:// and | 
| 1616   // chrome-extension:// URLs. | 1627   // chrome-extension:// URLs. | 
| 1617   ChromeURLDataManagerBackend::Register(); | 1628   ChromeURLDataManagerBackend::Register(); | 
| 1618   RegisterExtensionProtocols(); | 1629   RegisterExtensionProtocols(); | 
| 1619   RegisterMetadataURLRequestHandler(); | 1630   RegisterMetadataURLRequestHandler(); | 
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1779   profile->GetCloudPrintProxyService(); | 1790   profile->GetCloudPrintProxyService(); | 
| 1780 | 1791 | 
| 1781   int result_code = ResultCodes::NORMAL_EXIT; | 1792   int result_code = ResultCodes::NORMAL_EXIT; | 
| 1782   if (parameters.ui_task) { | 1793   if (parameters.ui_task) { | 
| 1783     // We are in test mode. Run one task and enter the main message loop. | 1794     // We are in test mode. Run one task and enter the main message loop. | 
| 1784     if (pool) | 1795     if (pool) | 
| 1785       pool->Recycle(); | 1796       pool->Recycle(); | 
| 1786     parameters.ui_task->Run(); | 1797     parameters.ui_task->Run(); | 
| 1787     delete parameters.ui_task; | 1798     delete parameters.ui_task; | 
| 1788   } else { | 1799   } else { | 
| 1789     // We are in regular browser boot sequence. Open initial stabs and enter | 1800     // We are in regular browser boot sequence. Open initial tabs and enter the | 
| 1790     // the main message loop. | 1801     // main message loop. | 
| 1791     if (browser_init.Start(parsed_command_line, FilePath(), profile, | 1802     if (browser_init.Start(parsed_command_line, FilePath(), profile, | 
| 1792                            &result_code)) { | 1803                            &result_code)) { | 
| 1793 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1804 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 
| 1794       // Initialize autoupdate timer. Timer callback costs basically nothing | 1805       // Initialize autoupdate timer. Timer callback costs basically nothing | 
| 1795       // when browser is not in persistent mode, so it's OK to let it ride on | 1806       // when browser is not in persistent mode, so it's OK to let it ride on | 
| 1796       // the main thread. This needs to be done here because we don't want | 1807       // 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. | 1808       // to start the timer when Chrome is run inside a test harness. | 
| 1798       g_browser_process->StartAutoupdateTimer(); | 1809       g_browser_process->StartAutoupdateTimer(); | 
| 1799 #endif | 1810 #endif | 
| 1800 | 1811 | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1874 #if defined(OS_CHROMEOS) | 1885 #if defined(OS_CHROMEOS) | 
| 1875   // To be precise, logout (browser shutdown) is not yet done, but the | 1886   // To be precise, logout (browser shutdown) is not yet done, but the | 
| 1876   // remaining work is negligible, hence we say LogoutDone here. | 1887   // remaining work is negligible, hence we say LogoutDone here. | 
| 1877   chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 1888   chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 
| 1878                                                         false); | 1889                                                         false); | 
| 1879   chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 1890   chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 
| 1880 #endif | 1891 #endif | 
| 1881   TRACE_EVENT_END("BrowserMain", 0, 0); | 1892   TRACE_EVENT_END("BrowserMain", 0, 0); | 
| 1882   return result_code; | 1893   return result_code; | 
| 1883 } | 1894 } | 
| OLD | NEW | 
|---|