| 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/chrome_browser_main.h" | 5 #include "chrome/browser/chrome_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 15 matching lines...) Expand all Loading... |
| 26 #include "base/sys_string_conversions.h" | 26 #include "base/sys_string_conversions.h" |
| 27 #include "base/threading/platform_thread.h" | 27 #include "base/threading/platform_thread.h" |
| 28 #include "base/time.h" | 28 #include "base/time.h" |
| 29 #include "base/utf_string_conversions.h" | 29 #include "base/utf_string_conversions.h" |
| 30 #include "base/values.h" | 30 #include "base/values.h" |
| 31 #include "build/build_config.h" | 31 #include "build/build_config.h" |
| 32 #include "chrome/browser/about_flags.h" | 32 #include "chrome/browser/about_flags.h" |
| 33 #include "chrome/browser/background/background_mode_manager.h" | 33 #include "chrome/browser/background/background_mode_manager.h" |
| 34 #include "chrome/browser/browser_process_impl.h" | 34 #include "chrome/browser/browser_process_impl.h" |
| 35 #include "chrome/browser/browser_shutdown.h" | 35 #include "chrome/browser/browser_shutdown.h" |
| 36 #include "chrome/browser/chrome_browser_main_gtk.h" | |
| 37 #include "chrome/browser/chrome_browser_main_win.h" | |
| 38 #include "chrome/browser/defaults.h" | 36 #include "chrome/browser/defaults.h" |
| 39 #include "chrome/browser/extensions/default_apps_trial.h" | 37 #include "chrome/browser/extensions/default_apps_trial.h" |
| 40 #include "chrome/browser/extensions/extension_protocols.h" | 38 #include "chrome/browser/extensions/extension_protocols.h" |
| 41 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
| 42 #include "chrome/browser/extensions/extensions_startup.h" | 40 #include "chrome/browser/extensions/extensions_startup.h" |
| 43 #include "chrome/browser/first_run/first_run_browser_process.h" | 41 #include "chrome/browser/first_run/first_run_browser_process.h" |
| 44 #include "chrome/browser/first_run/upgrade_util.h" | 42 #include "chrome/browser/first_run/upgrade_util.h" |
| 45 #include "chrome/browser/google/google_url_tracker.h" | 43 #include "chrome/browser/google/google_url_tracker.h" |
| 46 #include "chrome/browser/google/google_util.h" | 44 #include "chrome/browser/google/google_util.h" |
| 47 #include "chrome/browser/instant/instant_field_trial.h" | 45 #include "chrome/browser/instant/instant_field_trial.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 #include "net/url_request/url_request_throttler_manager.h" | 112 #include "net/url_request/url_request_throttler_manager.h" |
| 115 #include "net/websockets/websocket_job.h" | 113 #include "net/websockets/websocket_job.h" |
| 116 #include "ui/base/l10n/l10n_util.h" | 114 #include "ui/base/l10n/l10n_util.h" |
| 117 #include "ui/base/resource/resource_bundle.h" | 115 #include "ui/base/resource/resource_bundle.h" |
| 118 | 116 |
| 119 #if defined(USE_LINUX_BREAKPAD) | 117 #if defined(USE_LINUX_BREAKPAD) |
| 120 #include "base/linux_util.h" | 118 #include "base/linux_util.h" |
| 121 #include "chrome/app/breakpad_linux.h" | 119 #include "chrome/app/breakpad_linux.h" |
| 122 #endif | 120 #endif |
| 123 | 121 |
| 124 #if defined(TOOLKIT_USES_GTK) | |
| 125 #include "chrome/browser/ui/gtk/gtk_util.h" | |
| 126 #endif | |
| 127 | |
| 128 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 122 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 129 #include "chrome/browser/first_run/upgrade_util_linux.h" | 123 #include "chrome/browser/first_run/upgrade_util_linux.h" |
| 130 #endif | 124 #endif |
| 131 | 125 |
| 132 #if defined(OS_CHROMEOS) | 126 #if defined(OS_CHROMEOS) |
| 133 #include "chrome/browser/chromeos/audio_handler.h" | 127 #include "chrome/browser/chromeos/audio_handler.h" |
| 134 #include "chrome/browser/chromeos/boot_times_loader.h" | 128 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 135 #include "chrome/browser/chromeos/cros_settings_names.h" | 129 #include "chrome/browser/chromeos/cros_settings_names.h" |
| 136 #include "chrome/browser/chromeos/cros/cros_library.h" | 130 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 137 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | 131 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 154 // TODO(port): several win-only methods have been pulled out of this, but | 148 // TODO(port): several win-only methods have been pulled out of this, but |
| 155 // BrowserMain() as a whole needs to be broken apart so that it's usable by | 149 // BrowserMain() as a whole needs to be broken apart so that it's usable by |
| 156 // other platforms. For now, it's just a stub. This is a serious work in | 150 // other platforms. For now, it's just a stub. This is a serious work in |
| 157 // progress and should not be taken as an indication of a real refactoring. | 151 // progress and should not be taken as an indication of a real refactoring. |
| 158 | 152 |
| 159 #if defined(OS_WIN) | 153 #if defined(OS_WIN) |
| 160 #include "base/environment.h" // For PreRead experiment. | 154 #include "base/environment.h" // For PreRead experiment. |
| 161 #include "base/win/windows_version.h" | 155 #include "base/win/windows_version.h" |
| 162 #include "chrome/browser/browser_trial.h" | 156 #include "chrome/browser/browser_trial.h" |
| 163 #include "chrome/browser/browser_util_win.h" | 157 #include "chrome/browser/browser_util_win.h" |
| 158 #include "chrome/browser/chrome_browser_main_win.h" |
| 164 #include "chrome/browser/first_run/try_chrome_dialog_view.h" | 159 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
| 165 #include "chrome/browser/first_run/upgrade_util_win.h" | 160 #include "chrome/browser/first_run/upgrade_util_win.h" |
| 166 #include "chrome/browser/fragmentation_checker_win.h" | 161 #include "chrome/browser/fragmentation_checker_win.h" |
| 167 #include "chrome/browser/net/url_fixer_upper.h" | 162 #include "chrome/browser/net/url_fixer_upper.h" |
| 168 #include "chrome/browser/rlz/rlz.h" | 163 #include "chrome/browser/rlz/rlz.h" |
| 169 #include "chrome/browser/ui/views/user_data_dir_dialog.h" | 164 #include "chrome/browser/ui/views/user_data_dir_dialog.h" |
| 170 #include "chrome/installer/util/helper.h" | 165 #include "chrome/installer/util/helper.h" |
| 171 #include "chrome/installer/util/install_util.h" | 166 #include "chrome/installer/util/install_util.h" |
| 172 #include "chrome/installer/util/shell_util.h" | 167 #include "chrome/installer/util/shell_util.h" |
| 173 #include "content/browser/user_metrics.h" | 168 #include "content/browser/user_metrics.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 188 #include "chrome/browser/ui/views/chrome_views_delegate.h" | 183 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
| 189 #include "views/desktop/desktop_window_view.h" | 184 #include "views/desktop/desktop_window_view.h" |
| 190 #include "views/focus/accelerator_handler.h" | 185 #include "views/focus/accelerator_handler.h" |
| 191 #include "views/widget/widget.h" | 186 #include "views/widget/widget.h" |
| 192 #if defined(TOOLKIT_USES_GTK) | 187 #if defined(TOOLKIT_USES_GTK) |
| 193 #include "views/widget/native_widget_gtk.h" | 188 #include "views/widget/native_widget_gtk.h" |
| 194 #endif | 189 #endif |
| 195 #endif | 190 #endif |
| 196 | 191 |
| 197 #if defined(TOOLKIT_USES_GTK) | 192 #if defined(TOOLKIT_USES_GTK) |
| 193 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 198 #include "ui/gfx/gtk_util.h" | 194 #include "ui/gfx/gtk_util.h" |
| 199 #endif | 195 #endif |
| 200 | 196 |
| 201 #if defined(TOUCH_UI) | 197 #if defined(TOUCH_UI) |
| 202 #include "ui/base/touch/touch_factory.h" | 198 #include "ui/base/touch/touch_factory.h" |
| 203 #endif | 199 #endif |
| 204 | 200 |
| 201 #if defined(USE_X11) |
| 202 #include "chrome/browser/chrome_browser_main_x11.h" |
| 203 #endif |
| 204 |
| 205 #if defined(USE_AURA) | 205 #if defined(USE_AURA) |
| 206 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" | 206 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" |
| 207 #include "ui/aura/desktop.h" | 207 #include "ui/aura/desktop.h" |
| 208 #include "ui/aura_shell/shell.h" | 208 #include "ui/aura_shell/shell.h" |
| 209 #endif | 209 #endif |
| 210 | 210 |
| 211 namespace net { | 211 namespace net { |
| 212 class NetLog; | 212 class NetLog; |
| 213 } // namespace net | 213 } // namespace net |
| 214 | 214 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 // localization data files. | 674 // localization data files. |
| 675 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 675 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
| 676 const char kMissingLocaleDataMessage[] = | 676 const char kMissingLocaleDataMessage[] = |
| 677 "Unable to find locale data files. Please reinstall."; | 677 "Unable to find locale data files. Please reinstall."; |
| 678 } // namespace chrome_browser | 678 } // namespace chrome_browser |
| 679 | 679 |
| 680 // BrowserMainParts ------------------------------------------------------------ | 680 // BrowserMainParts ------------------------------------------------------------ |
| 681 | 681 |
| 682 ChromeBrowserMainParts::ChromeBrowserMainParts( | 682 ChromeBrowserMainParts::ChromeBrowserMainParts( |
| 683 const MainFunctionParams& parameters) | 683 const MainFunctionParams& parameters) |
| 684 : BrowserMainParts(parameters), | 684 : parameters_(parameters), |
| 685 parsed_command_line_(parameters.command_line_), |
| 686 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
| 685 shutdown_watcher_(new ShutdownWatcherHelper()), | 687 shutdown_watcher_(new ShutdownWatcherHelper()), |
| 686 record_search_engine_(false), | 688 record_search_engine_(false), |
| 687 translate_manager_(NULL), | 689 translate_manager_(NULL), |
| 688 profile_(NULL), | 690 profile_(NULL), |
| 689 run_message_loop_(true), | 691 run_message_loop_(true), |
| 690 notify_result_(ProcessSingleton::PROCESS_NONE) { | 692 notify_result_(ProcessSingleton::PROCESS_NONE) { |
| 691 // If we're running tests (ui_task is non-null). | 693 // If we're running tests (ui_task is non-null). |
| 692 if (parameters.ui_task) | 694 if (parameters.ui_task) |
| 693 browser_defaults::enable_help_app = false; | 695 browser_defaults::enable_help_app = false; |
| 694 } | 696 } |
| 695 | 697 |
| 696 ChromeBrowserMainParts::~ChromeBrowserMainParts() { | 698 ChromeBrowserMainParts::~ChromeBrowserMainParts() { |
| 697 } | 699 } |
| 698 | 700 |
| 699 // This will be called after the command-line has been mutated by about:flags | 701 // This will be called after the command-line has been mutated by about:flags |
| 700 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( | 702 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( |
| 701 const CommandLine& parsed_command_line, | |
| 702 PrefService* local_state) { | 703 PrefService* local_state) { |
| 703 // Must initialize metrics after labs have been converted into switches, | 704 // Must initialize metrics after labs have been converted into switches, |
| 704 // but before field trials are set up (so that client ID is available for | 705 // but before field trials are set up (so that client ID is available for |
| 705 // one-time randomized field trials). | 706 // one-time randomized field trials). |
| 706 MetricsService* metrics = InitializeMetrics(parsed_command_line, local_state); | 707 MetricsService* metrics = InitializeMetrics( |
| 708 parsed_command_line_, local_state); |
| 707 | 709 |
| 708 // Initialize FieldTrialList to support FieldTrials that use one-time | 710 // Initialize FieldTrialList to support FieldTrials that use one-time |
| 709 // randomization. The client ID will be empty if the user has not opted | 711 // randomization. The client ID will be empty if the user has not opted |
| 710 // to send metrics. | 712 // to send metrics. |
| 711 field_trial_list_.reset(new base::FieldTrialList(metrics->GetClientId())); | 713 field_trial_list_.reset(new base::FieldTrialList(metrics->GetClientId())); |
| 712 | 714 |
| 713 SetupFieldTrials(metrics->recording_active(), | 715 SetupFieldTrials(metrics->recording_active(), |
| 714 local_state->IsManagedPreference( | 716 local_state->IsManagedPreference( |
| 715 prefs::kMaxConnectionsPerProxy)); | 717 prefs::kMaxConnectionsPerProxy)); |
| 716 | 718 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { | 1171 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { |
| 1170 // Need an instance of AtExitManager to handle singleton creations and | 1172 // Need an instance of AtExitManager to handle singleton creations and |
| 1171 // deletions. We need this new instance because, the old instance created | 1173 // deletions. We need this new instance because, the old instance created |
| 1172 // in ChromeMain() got destructed when the function returned. | 1174 // in ChromeMain() got destructed when the function returned. |
| 1173 base::AtExitManager exit_manager; | 1175 base::AtExitManager exit_manager; |
| 1174 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 1176 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
| 1175 } | 1177 } |
| 1176 #endif | 1178 #endif |
| 1177 | 1179 |
| 1178 void ChromeBrowserMainParts::PreMainMessageLoopRun() { | 1180 void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
| 1179 set_result_code(PreMainMessageLoopRunInternal()); | 1181 result_code_ = PreMainMessageLoopRunImpl(); |
| 1180 } | 1182 } |
| 1181 | 1183 |
| 1182 int ChromeBrowserMainParts::PreMainMessageLoopRunInternal() { | 1184 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { |
| 1183 run_message_loop_ = false; | 1185 run_message_loop_ = false; |
| 1184 FilePath user_data_dir; | 1186 FilePath user_data_dir; |
| 1185 #if defined(OS_WIN) | 1187 #if defined(OS_WIN) |
| 1186 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 1188 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
| 1187 #else | 1189 #else |
| 1188 // Getting the user data dir can fail if the directory isn't | 1190 // Getting the user data dir can fail if the directory isn't |
| 1189 // creatable, for example; on Windows in code below we bring up a | 1191 // creatable, for example; on Windows in code below we bring up a |
| 1190 // dialog prompting the user to pick a different directory. | 1192 // dialog prompting the user to pick a different directory. |
| 1191 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, | 1193 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, |
| 1192 // so it's better to fail here than fail mysteriously elsewhere. | 1194 // so it's better to fail here than fail mysteriously elsewhere. |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1375 InitializeURLRequestThrottlerManager(browser_process_->net_log()); | 1377 InitializeURLRequestThrottlerManager(browser_process_->net_log()); |
| 1376 | 1378 |
| 1377 // Initialize histogram synchronizer system. This is a singleton and is used | 1379 // Initialize histogram synchronizer system. This is a singleton and is used |
| 1378 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of | 1380 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of |
| 1379 // scope. Even though NewRunnableMethod does AddRef and Release, the object | 1381 // scope. Even though NewRunnableMethod does AddRef and Release, the object |
| 1380 // will not be deleted after the Task is executed. | 1382 // will not be deleted after the Task is executed. |
| 1381 histogram_synchronizer_ = new HistogramSynchronizer(); | 1383 histogram_synchronizer_ = new HistogramSynchronizer(); |
| 1382 | 1384 |
| 1383 // Now the command line has been mutated based on about:flags, we can | 1385 // Now the command line has been mutated based on about:flags, we can |
| 1384 // set up metrics and initialize field trials. | 1386 // set up metrics and initialize field trials. |
| 1385 MetricsService* metrics = | 1387 MetricsService* metrics = SetupMetricsAndFieldTrials(local_state); |
| 1386 SetupMetricsAndFieldTrials(parsed_command_line(), local_state); | |
| 1387 | 1388 |
| 1388 #if defined(USE_WEBKIT_COMPOSITOR) | 1389 #if defined(USE_WEBKIT_COMPOSITOR) |
| 1389 // We need to ensure WebKit has been initialized before we start the WebKit | 1390 // We need to ensure WebKit has been initialized before we start the WebKit |
| 1390 // compositor. This is done by the ResourceDispatcherHost on creation. | 1391 // compositor. This is done by the ResourceDispatcherHost on creation. |
| 1391 g_browser_process->resource_dispatcher_host(); | 1392 g_browser_process->resource_dispatcher_host(); |
| 1392 #endif | 1393 #endif |
| 1393 #if defined(USE_AURA) | 1394 #if defined(USE_AURA) |
| 1394 // Shell takes ownership of ChromeShellDelegate. | 1395 // Shell takes ownership of ChromeShellDelegate. |
| 1395 aura_shell::Shell::GetInstance()->SetDelegate(new ChromeShellDelegate); | 1396 aura_shell::Shell::GetInstance()->SetDelegate(new ChromeShellDelegate); |
| 1396 #elif defined(TOOLKIT_VIEWS) | 1397 #elif defined(TOOLKIT_VIEWS) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 // On Windows, we use our startup as an opportunity to do upgrade/uninstall | 1466 // On Windows, we use our startup as an opportunity to do upgrade/uninstall |
| 1466 // tasks. Those care whether the browser is already running. On Linux/Mac, | 1467 // tasks. Those care whether the browser is already running. On Linux/Mac, |
| 1467 // upgrade/uninstall happen separately. | 1468 // upgrade/uninstall happen separately. |
| 1468 bool already_running = browser_util::IsBrowserAlreadyRunning(); | 1469 bool already_running = browser_util::IsBrowserAlreadyRunning(); |
| 1469 | 1470 |
| 1470 // If the command line specifies 'uninstall' then we need to work here | 1471 // If the command line specifies 'uninstall' then we need to work here |
| 1471 // unless we detect another chrome browser running. | 1472 // unless we detect another chrome browser running. |
| 1472 if (parsed_command_line().HasSwitch(switches::kUninstall)) { | 1473 if (parsed_command_line().HasSwitch(switches::kUninstall)) { |
| 1473 return DoUninstallTasks(already_running); | 1474 return DoUninstallTasks(already_running); |
| 1474 } | 1475 } |
| 1475 #endif | |
| 1476 | 1476 |
| 1477 if (parsed_command_line().HasSwitch(switches::kHideIcons) || | 1477 if (parsed_command_line().HasSwitch(switches::kHideIcons) || |
| 1478 parsed_command_line().HasSwitch(switches::kShowIcons)) { | 1478 parsed_command_line().HasSwitch(switches::kShowIcons)) { |
| 1479 return HandleIconsCommands(parsed_command_line()); | 1479 return ChromeBrowserMainPartsWin::HandleIconsCommands( |
| 1480 parsed_command_line_); |
| 1480 } | 1481 } |
| 1482 #endif |
| 1483 |
| 1481 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { | 1484 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { |
| 1482 return ShellIntegration::SetAsDefaultBrowser() ? | 1485 return ShellIntegration::SetAsDefaultBrowser() ? |
| 1483 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : | 1486 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : |
| 1484 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); | 1487 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); |
| 1485 } | 1488 } |
| 1486 | 1489 |
| 1487 // If the command line specifies --pack-extension, attempt the pack extension | 1490 // If the command line specifies --pack-extension, attempt the pack extension |
| 1488 // startup action and exit. | 1491 // startup action and exit. |
| 1489 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1492 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
| 1490 ExtensionsStartupUtil extension_startup_util; | 1493 ExtensionsStartupUtil extension_startup_util; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 if (parsed_command_line().HasSwitch(switches::kImport) || | 1626 if (parsed_command_line().HasSwitch(switches::kImport) || |
| 1624 parsed_command_line().HasSwitch(switches::kImportFromFile)) { | 1627 parsed_command_line().HasSwitch(switches::kImportFromFile)) { |
| 1625 return FirstRun::ImportNow(profile_, parsed_command_line()); | 1628 return FirstRun::ImportNow(profile_, parsed_command_line()); |
| 1626 } | 1629 } |
| 1627 #endif | 1630 #endif |
| 1628 | 1631 |
| 1629 #if defined(OS_WIN) | 1632 #if defined(OS_WIN) |
| 1630 // Do the tasks if chrome has been upgraded while it was last running. | 1633 // Do the tasks if chrome has been upgraded while it was last running. |
| 1631 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) | 1634 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) |
| 1632 return content::RESULT_CODE_NORMAL_EXIT; | 1635 return content::RESULT_CODE_NORMAL_EXIT; |
| 1633 #endif | |
| 1634 | 1636 |
| 1635 // Check if there is any machine level Chrome installed on the current | 1637 // Check if there is any machine level Chrome installed on the current |
| 1636 // machine. If yes and the current Chrome process is user level, we do not | 1638 // machine. If yes and the current Chrome process is user level, we do not |
| 1637 // allow the user level Chrome to run. So we notify the user and uninstall | 1639 // allow the user level Chrome to run. So we notify the user and uninstall |
| 1638 // user level Chrome. | 1640 // user level Chrome. |
| 1639 // Note this check should only happen here, after all the checks above | 1641 // Note this check should only happen here, after all the checks above |
| 1640 // (uninstall, resource bundle initialization, other chrome browser | 1642 // (uninstall, resource bundle initialization, other chrome browser |
| 1641 // processes etc). | 1643 // processes etc). |
| 1642 // Do not allow this to occur for Chrome Frame user-to-system handoffs. | 1644 // Do not allow this to occur for Chrome Frame user-to-system handoffs. |
| 1643 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) && | 1645 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) && |
| 1644 CheckMachineLevelInstall()) { | 1646 ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) { |
| 1645 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; | 1647 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; |
| 1646 } | 1648 } |
| 1649 #endif |
| 1647 | 1650 |
| 1648 // Create the TranslateManager singleton. | 1651 // Create the TranslateManager singleton. |
| 1649 translate_manager_ = TranslateManager::GetInstance(); | 1652 translate_manager_ = TranslateManager::GetInstance(); |
| 1650 DCHECK(translate_manager_ != NULL); | 1653 DCHECK(translate_manager_ != NULL); |
| 1651 | 1654 |
| 1652 #if defined(OS_MACOSX) | 1655 #if defined(OS_MACOSX) |
| 1653 if (!parsed_command_line().HasSwitch(switches::kNoFirstRun)) { | 1656 if (!parsed_command_line().HasSwitch(switches::kNoFirstRun)) { |
| 1654 // Disk image installation is sort of a first-run task, so it shares the | 1657 // Disk image installation is sort of a first-run task, so it shares the |
| 1655 // kNoFirstRun switch. | 1658 // kNoFirstRun switch. |
| 1656 if (MaybeInstallFromDiskImage()) { | 1659 if (MaybeInstallFromDiskImage()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1684 // the pref. | 1687 // the pref. |
| 1685 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 1688 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
| 1686 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); | 1689 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); |
| 1687 #endif // OS_POSIX | 1690 #endif // OS_POSIX |
| 1688 } // if (!first_run_ui_bypass) | 1691 } // if (!first_run_ui_bypass) |
| 1689 | 1692 |
| 1690 Browser::SetNewHomePagePrefs(user_prefs); | 1693 Browser::SetNewHomePagePrefs(user_prefs); |
| 1691 g_browser_process->profile_manager()->OnImportFinished(profile_); | 1694 g_browser_process->profile_manager()->OnImportFinished(profile_); |
| 1692 } // if (is_first_run) | 1695 } // if (is_first_run) |
| 1693 | 1696 |
| 1697 #if defined(OS_WIN) |
| 1694 // Sets things up so that if we crash from this point on, a dialog will | 1698 // Sets things up so that if we crash from this point on, a dialog will |
| 1695 // popup asking the user to restart chrome. It is done this late to avoid | 1699 // popup asking the user to restart chrome. It is done this late to avoid |
| 1696 // testing against a bunch of special cases that are taken care early on. | 1700 // testing against a bunch of special cases that are taken care early on. |
| 1697 PrepareRestartOnCrashEnviroment(parsed_command_line()); | 1701 ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( |
| 1702 parsed_command_line()); |
| 1698 | 1703 |
| 1699 // Start watching for hangs during startup. We disarm this hang detector when | |
| 1700 // ThreadWatcher takes over or when browser is shutdown. | |
| 1701 StartupTimeBomb::Arm(base::TimeDelta::FromSeconds(300)); | |
| 1702 | |
| 1703 #if defined(OS_WIN) | |
| 1704 // Registers Chrome with the Windows Restart Manager, which will restore the | 1704 // Registers Chrome with the Windows Restart Manager, which will restore the |
| 1705 // Chrome session when the computer is restarted after a system update. | 1705 // Chrome session when the computer is restarted after a system update. |
| 1706 // This could be run as late as WM_QUERYENDSESSION for system update reboots, | 1706 // This could be run as late as WM_QUERYENDSESSION for system update reboots, |
| 1707 // but should run on startup if extended to handle crashes/hangs/patches. | 1707 // but should run on startup if extended to handle crashes/hangs/patches. |
| 1708 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. | 1708 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. |
| 1709 if (base::win::GetVersion() >= base::win::VERSION_VISTA) | 1709 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 1710 RegisterApplicationRestart(parsed_command_line()); | 1710 ChromeBrowserMainPartsWin::RegisterApplicationRestart( |
| 1711 #endif // OS_WIN | 1711 parsed_command_line()); |
| 1712 } |
| 1712 | 1713 |
| 1713 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 1714 #if defined(GOOGLE_CHROME_BUILD) |
| 1714 // Init the RLZ library. This just binds the dll and schedules a task on the | 1715 // Init the RLZ library. This just binds the dll and schedules a task on the |
| 1715 // file thread to be run sometime later. If this is the first run we record | 1716 // file thread to be run sometime later. If this is the first run we record |
| 1716 // the installation event. | 1717 // the installation event. |
| 1717 bool google_search_default = false; | 1718 bool google_search_default = false; |
| 1718 TemplateURLService* template_url_service = | 1719 TemplateURLService* template_url_service = |
| 1719 TemplateURLServiceFactory::GetForProfile(profile_); | 1720 TemplateURLServiceFactory::GetForProfile(profile_); |
| 1720 if (template_url_service) { | 1721 if (template_url_service) { |
| 1721 const TemplateURL* url_template = | 1722 const TemplateURL* url_template = |
| 1722 template_url_service->GetDefaultSearchProvider(); | 1723 template_url_service->GetDefaultSearchProvider(); |
| 1723 if (url_template) { | 1724 if (url_template) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1736 homepage == GoogleURLTracker::kDefaultGoogleHomepage; | 1737 homepage == GoogleURLTracker::kDefaultGoogleHomepage; |
| 1737 } | 1738 } |
| 1738 | 1739 |
| 1739 RLZTracker::InitRlzDelayed(is_first_run, master_prefs_->ping_delay, | 1740 RLZTracker::InitRlzDelayed(is_first_run, master_prefs_->ping_delay, |
| 1740 google_search_default, google_search_homepage); | 1741 google_search_default, google_search_homepage); |
| 1741 | 1742 |
| 1742 // Prime the RLZ cache for the home page access point so that its avaiable | 1743 // Prime the RLZ cache for the home page access point so that its avaiable |
| 1743 // for the startup page if needed (i.e., when the startup page is set to | 1744 // for the startup page if needed (i.e., when the startup page is set to |
| 1744 // the home page). | 1745 // the home page). |
| 1745 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); | 1746 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); |
| 1746 #endif // GOOGLE_CHROME_BUILD && OS_WIN | 1747 #endif // GOOGLE_CHROME_BUILD |
| 1748 #endif // OS_WIN |
| 1749 |
| 1750 // Start watching for hangs during startup. We disarm this hang detector when |
| 1751 // ThreadWatcher takes over or when browser is shutdown. |
| 1752 StartupTimeBomb::Arm(base::TimeDelta::FromSeconds(300)); |
| 1747 | 1753 |
| 1748 // Configure modules that need access to resources. | 1754 // Configure modules that need access to resources. |
| 1749 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1755 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
| 1750 | 1756 |
| 1751 // In unittest mode, this will do nothing. In normal mode, this will create | 1757 // In unittest mode, this will do nothing. In normal mode, this will create |
| 1752 // the global GoogleURLTracker and IntranetRedirectDetector instances, which | 1758 // the global GoogleURLTracker and IntranetRedirectDetector instances, which |
| 1753 // will promptly go to sleep for five and seven seconds, respectively (to | 1759 // will promptly go to sleep for five and seven seconds, respectively (to |
| 1754 // avoid slowing startup), and wake up afterwards to see if they should do | 1760 // avoid slowing startup), and wake up afterwards to see if they should do |
| 1755 // anything else. | 1761 // anything else. |
| 1756 // | 1762 // |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 } | 1947 } |
| 1942 #endif | 1948 #endif |
| 1943 | 1949 |
| 1944 run_message_loop_ = true; | 1950 run_message_loop_ = true; |
| 1945 } | 1951 } |
| 1946 } | 1952 } |
| 1947 | 1953 |
| 1948 return result_code; | 1954 return result_code; |
| 1949 } | 1955 } |
| 1950 | 1956 |
| 1951 void ChromeBrowserMainParts::MainMessageLoopRun() { | 1957 bool ChromeBrowserMainParts::MainMessageLoopRun(int* result_code) { |
| 1958 // Set the result code set in PreMainMessageLoopRun. |
| 1959 *result_code = result_code_; |
| 1960 |
| 1952 if (!run_message_loop_) | 1961 if (!run_message_loop_) |
| 1953 return; | 1962 return true; // Don't run the default message loop. |
| 1954 | 1963 |
| 1955 // This should be invoked as close to the start of the browser's | 1964 // This should be invoked as close to the start of the browser's |
| 1956 // UI thread message loop as possible to get a stable measurement | 1965 // UI thread message loop as possible to get a stable measurement |
| 1957 // across versions. | 1966 // across versions. |
| 1958 RecordBrowserStartupTime(); | 1967 RecordBrowserStartupTime(); |
| 1959 | 1968 |
| 1960 #if defined(USE_AURA) | 1969 #if defined(USE_AURA) |
| 1961 aura::Desktop::GetInstance()->Run(); | 1970 aura::Desktop::GetInstance()->Run(); |
| 1962 #elif defined(TOOLKIT_VIEWS) | 1971 #elif defined(TOOLKIT_VIEWS) |
| 1963 views::AcceleratorHandler accelerator_handler; | 1972 views::AcceleratorHandler accelerator_handler; |
| 1964 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); | 1973 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); |
| 1965 #elif defined(USE_X11) | 1974 #elif defined(USE_X11) |
| 1966 MessageLoopForUI::current()->RunWithDispatcher(NULL); | 1975 MessageLoopForUI::current()->RunWithDispatcher(NULL); |
| 1967 #elif defined(OS_POSIX) | 1976 #elif defined(OS_POSIX) |
| 1968 MessageLoopForUI::current()->Run(); | 1977 MessageLoopForUI::current()->Run(); |
| 1969 #endif | 1978 #endif |
| 1970 #if defined(OS_CHROMEOS) | 1979 #if defined(OS_CHROMEOS) |
| 1971 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", | 1980 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", |
| 1972 true); | 1981 true); |
| 1973 #endif | 1982 #endif |
| 1983 |
| 1984 return true; |
| 1974 } | 1985 } |
| 1975 | 1986 |
| 1976 void ChromeBrowserMainParts::PostMainMessageLoopRun() { | 1987 void ChromeBrowserMainParts::PostMainMessageLoopRun() { |
| 1977 // Start watching for jank during shutdown. It gets disarmed when | 1988 // Start watching for jank during shutdown. It gets disarmed when |
| 1978 // |shutdown_watcher_| object is destructed. | 1989 // |shutdown_watcher_| object is destructed. |
| 1979 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(90)); | 1990 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(90)); |
| 1980 | 1991 |
| 1981 // Disarm the startup hang detector time bomb if it is still Arm'ed. | 1992 // Disarm the startup hang detector time bomb if it is still Arm'ed. |
| 1982 StartupTimeBomb::Disarm(); | 1993 StartupTimeBomb::Disarm(); |
| 1983 | 1994 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2108 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 2119 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
| 2109 (pre_read == "0" || pre_read == "1")) { | 2120 (pre_read == "0" || pre_read == "1")) { |
| 2110 std::string uma_name(name); | 2121 std::string uma_name(name); |
| 2111 uma_name += "_PreRead"; | 2122 uma_name += "_PreRead"; |
| 2112 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 2123 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
| 2113 AddPreReadHistogramTime(uma_name.c_str(), time); | 2124 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 2114 } | 2125 } |
| 2115 #endif | 2126 #endif |
| 2116 #endif | 2127 #endif |
| 2117 } | 2128 } |
| OLD | NEW |