Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 8302016: Make GTK and Aura parts orthogonal to OS parts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 15 matching lines...) Expand all
153 // TODO(port): several win-only methods have been pulled out of this, but 147 // TODO(port): several win-only methods have been pulled out of this, but
154 // BrowserMain() as a whole needs to be broken apart so that it's usable by 148 // BrowserMain() as a whole needs to be broken apart so that it's usable by
155 // other platforms. For now, it's just a stub. This is a serious work in 149 // other platforms. For now, it's just a stub. This is a serious work in
156 // progress and should not be taken as an indication of a real refactoring. 150 // progress and should not be taken as an indication of a real refactoring.
157 151
158 #if defined(OS_WIN) 152 #if defined(OS_WIN)
159 #include "base/environment.h" // For PreRead experiment. 153 #include "base/environment.h" // For PreRead experiment.
160 #include "base/win/windows_version.h" 154 #include "base/win/windows_version.h"
161 #include "chrome/browser/browser_trial.h" 155 #include "chrome/browser/browser_trial.h"
162 #include "chrome/browser/browser_util_win.h" 156 #include "chrome/browser/browser_util_win.h"
157 #include "chrome/browser/chrome_browser_main_win.h"
163 #include "chrome/browser/first_run/try_chrome_dialog_view.h" 158 #include "chrome/browser/first_run/try_chrome_dialog_view.h"
164 #include "chrome/browser/first_run/upgrade_util_win.h" 159 #include "chrome/browser/first_run/upgrade_util_win.h"
165 #include "chrome/browser/fragmentation_checker_win.h" 160 #include "chrome/browser/fragmentation_checker_win.h"
166 #include "chrome/browser/net/url_fixer_upper.h" 161 #include "chrome/browser/net/url_fixer_upper.h"
167 #include "chrome/browser/rlz/rlz.h" 162 #include "chrome/browser/rlz/rlz.h"
168 #include "chrome/browser/ui/views/user_data_dir_dialog.h" 163 #include "chrome/browser/ui/views/user_data_dir_dialog.h"
169 #include "chrome/installer/util/helper.h" 164 #include "chrome/installer/util/helper.h"
170 #include "chrome/installer/util/install_util.h" 165 #include "chrome/installer/util/install_util.h"
171 #include "chrome/installer/util/shell_util.h" 166 #include "chrome/installer/util/shell_util.h"
172 #include "content/browser/user_metrics.h" 167 #include "content/browser/user_metrics.h"
(...skipping 14 matching lines...) Expand all
187 #include "chrome/browser/ui/views/chrome_views_delegate.h" 182 #include "chrome/browser/ui/views/chrome_views_delegate.h"
188 #include "views/desktop/desktop_window_view.h" 183 #include "views/desktop/desktop_window_view.h"
189 #include "views/focus/accelerator_handler.h" 184 #include "views/focus/accelerator_handler.h"
190 #include "views/widget/widget.h" 185 #include "views/widget/widget.h"
191 #if defined(TOOLKIT_USES_GTK) 186 #if defined(TOOLKIT_USES_GTK)
192 #include "views/widget/native_widget_gtk.h" 187 #include "views/widget/native_widget_gtk.h"
193 #endif 188 #endif
194 #endif 189 #endif
195 190
196 #if defined(TOOLKIT_USES_GTK) 191 #if defined(TOOLKIT_USES_GTK)
192 #include "chrome/browser/ui/gtk/gtk_util.h"
197 #include "ui/gfx/gtk_util.h" 193 #include "ui/gfx/gtk_util.h"
198 #endif 194 #endif
199 195
200 #if defined(TOUCH_UI) 196 #if defined(TOUCH_UI)
201 #include "ui/base/touch/touch_factory.h" 197 #include "ui/base/touch/touch_factory.h"
202 #endif 198 #endif
203 199
200 #if defined(USE_X11)
201 #include "chrome/browser/chrome_browser_main_x11.h"
202 #endif
203
204 #if defined(USE_AURA) 204 #if defined(USE_AURA)
205 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h" 205 #include "chrome/browser/ui/views/aura/chrome_shell_delegate.h"
206 #include "ui/aura/desktop.h" 206 #include "ui/aura/desktop.h"
207 #include "ui/aura_shell/shell.h" 207 #include "ui/aura_shell/shell.h"
208 #endif 208 #endif
209 209
210 namespace net { 210 namespace net {
211 class NetLog; 211 class NetLog;
212 } // namespace net 212 } // namespace net
213 213
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 // localization data files. 678 // localization data files.
679 const char kMissingLocaleDataTitle[] = "Missing File Error"; 679 const char kMissingLocaleDataTitle[] = "Missing File Error";
680 const char kMissingLocaleDataMessage[] = 680 const char kMissingLocaleDataMessage[] =
681 "Unable to find locale data files. Please reinstall."; 681 "Unable to find locale data files. Please reinstall.";
682 } // namespace chrome_browser 682 } // namespace chrome_browser
683 683
684 // BrowserMainParts ------------------------------------------------------------ 684 // BrowserMainParts ------------------------------------------------------------
685 685
686 ChromeBrowserMainParts::ChromeBrowserMainParts( 686 ChromeBrowserMainParts::ChromeBrowserMainParts(
687 const MainFunctionParams& parameters) 687 const MainFunctionParams& parameters)
688 : BrowserMainParts(parameters), 688 : content::BrowserMainParts(),
jam 2011/10/24 19:36:00 not necessary
stevenjb 2011/10/25 02:51:04 Done.
689 parameters_(parameters),
690 parsed_command_line_(parameters.command_line_),
689 shutdown_watcher_(new ShutdownWatcherHelper()), 691 shutdown_watcher_(new ShutdownWatcherHelper()),
690 record_search_engine_(false), 692 record_search_engine_(false),
691 translate_manager_(NULL), 693 translate_manager_(NULL),
692 profile_(NULL), 694 profile_(NULL),
693 run_message_loop_(true), 695 run_message_loop_(true),
694 notify_result_(ProcessSingleton::PROCESS_NONE) { 696 notify_result_(ProcessSingleton::PROCESS_NONE) {
695 // If we're running tests (ui_task is non-null). 697 // If we're running tests (ui_task is non-null).
696 if (parameters.ui_task) 698 if (parameters.ui_task)
697 browser_defaults::enable_help_app = false; 699 browser_defaults::enable_help_app = false;
698 } 700 }
699 701
700 ChromeBrowserMainParts::~ChromeBrowserMainParts() { 702 ChromeBrowserMainParts::~ChromeBrowserMainParts() {
701 } 703 }
702 704
703 // This will be called after the command-line has been mutated by about:flags 705 // This will be called after the command-line has been mutated by about:flags
704 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( 706 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials(
705 const CommandLine& parsed_command_line,
706 PrefService* local_state) { 707 PrefService* local_state) {
707 // Must initialize metrics after labs have been converted into switches, 708 // Must initialize metrics after labs have been converted into switches,
708 // but before field trials are set up (so that client ID is available for 709 // but before field trials are set up (so that client ID is available for
709 // one-time randomized field trials). 710 // one-time randomized field trials).
710 MetricsService* metrics = InitializeMetrics(parsed_command_line, local_state); 711 MetricsService* metrics = InitializeMetrics(
712 parsed_command_line(), local_state);
jam 2011/10/24 19:36:00 nit: now that this is a member variable, just pars
stevenjb 2011/10/25 02:51:04 Done.
711 713
712 // Initialize FieldTrialList to support FieldTrials that use one-time 714 // Initialize FieldTrialList to support FieldTrials that use one-time
713 // randomization. The client ID will be empty if the user has not opted 715 // randomization. The client ID will be empty if the user has not opted
714 // to send metrics. 716 // to send metrics.
715 field_trial_list_.reset(new base::FieldTrialList(metrics->GetClientId())); 717 field_trial_list_.reset(new base::FieldTrialList(metrics->GetClientId()));
716 718
717 SetupFieldTrials(metrics->recording_active(), 719 SetupFieldTrials(metrics->recording_active(),
718 local_state->IsManagedPreference( 720 local_state->IsManagedPreference(
719 prefs::kMaxConnectionsPerProxy)); 721 prefs::kMaxConnectionsPerProxy));
720 722
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 1174
1173 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() { 1175 DLLEXPORT void __cdecl RelaunchChromeBrowserWithNewCommandLineIfNeeded() {
1174 // Need an instance of AtExitManager to handle singleton creations and 1176 // Need an instance of AtExitManager to handle singleton creations and
1175 // deletions. We need this new instance because, the old instance created 1177 // deletions. We need this new instance because, the old instance created
1176 // in ChromeMain() got destructed when the function returned. 1178 // in ChromeMain() got destructed when the function returned.
1177 base::AtExitManager exit_manager; 1179 base::AtExitManager exit_manager;
1178 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); 1180 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded();
1179 } 1181 }
1180 #endif 1182 #endif
1181 1183
1182 void ChromeBrowserMainParts::PreMainMessageLoopRun() { 1184 int ChromeBrowserMainParts::PreMainMessageLoopRun() {
1183 set_result_code(PreMainMessageLoopRunInternal());
1184 }
1185
1186 int ChromeBrowserMainParts::PreMainMessageLoopRunInternal() {
1187 run_message_loop_ = false; 1185 run_message_loop_ = false;
1188 FilePath user_data_dir; 1186 FilePath user_data_dir;
1189 #if defined(OS_WIN) 1187 #if defined(OS_WIN)
1190 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 1188 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
1191 #else 1189 #else
1192 // 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
1193 // 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
1194 // dialog prompting the user to pick a different directory. 1192 // dialog prompting the user to pick a different directory.
1195 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, 1193 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux,
1196 // so it's better to fail here than fail mysteriously elsewhere. 1194 // so it's better to fail here than fail mysteriously elsewhere.
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 InitializeURLRequestThrottlerManager(browser_process_->net_log()); 1400 InitializeURLRequestThrottlerManager(browser_process_->net_log());
1403 1401
1404 // Initialize histogram synchronizer system. This is a singleton and is used 1402 // Initialize histogram synchronizer system. This is a singleton and is used
1405 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of 1403 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of
1406 // scope. Even though NewRunnableMethod does AddRef and Release, the object 1404 // scope. Even though NewRunnableMethod does AddRef and Release, the object
1407 // will not be deleted after the Task is executed. 1405 // will not be deleted after the Task is executed.
1408 histogram_synchronizer_ = new HistogramSynchronizer(); 1406 histogram_synchronizer_ = new HistogramSynchronizer();
1409 1407
1410 // Now the command line has been mutated based on about:flags, we can 1408 // Now the command line has been mutated based on about:flags, we can
1411 // set up metrics and initialize field trials. 1409 // set up metrics and initialize field trials.
1412 MetricsService* metrics = 1410 MetricsService* metrics = SetupMetricsAndFieldTrials(local_state);
1413 SetupMetricsAndFieldTrials(parsed_command_line(), local_state);
1414 1411
1415 // Now that all preferences have been registered, set the install date 1412 // Now that all preferences have been registered, set the install date
1416 // for the uninstall metrics if this is our first run. This only actually 1413 // for the uninstall metrics if this is our first run. This only actually
1417 // gets used if the user has metrics reporting enabled at uninstall time. 1414 // gets used if the user has metrics reporting enabled at uninstall time.
1418 int64 install_date = 1415 int64 install_date =
1419 local_state->GetInt64(prefs::kUninstallMetricsInstallDate); 1416 local_state->GetInt64(prefs::kUninstallMetricsInstallDate);
1420 if (install_date == 0) { 1417 if (install_date == 0) {
1421 local_state->SetInt64(prefs::kUninstallMetricsInstallDate, 1418 local_state->SetInt64(prefs::kUninstallMetricsInstallDate,
1422 base::Time::Now().ToTimeT()); 1419 base::Time::Now().ToTimeT());
1423 } 1420 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 // On Windows, we use our startup as an opportunity to do upgrade/uninstall 1456 // On Windows, we use our startup as an opportunity to do upgrade/uninstall
1460 // tasks. Those care whether the browser is already running. On Linux/Mac, 1457 // tasks. Those care whether the browser is already running. On Linux/Mac,
1461 // upgrade/uninstall happen separately. 1458 // upgrade/uninstall happen separately.
1462 bool already_running = browser_util::IsBrowserAlreadyRunning(); 1459 bool already_running = browser_util::IsBrowserAlreadyRunning();
1463 1460
1464 // If the command line specifies 'uninstall' then we need to work here 1461 // If the command line specifies 'uninstall' then we need to work here
1465 // unless we detect another chrome browser running. 1462 // unless we detect another chrome browser running.
1466 if (parsed_command_line().HasSwitch(switches::kUninstall)) { 1463 if (parsed_command_line().HasSwitch(switches::kUninstall)) {
1467 return DoUninstallTasks(already_running); 1464 return DoUninstallTasks(already_running);
1468 } 1465 }
1469 #endif
1470 1466
1471 if (parsed_command_line().HasSwitch(switches::kHideIcons) || 1467 if (parsed_command_line().HasSwitch(switches::kHideIcons) ||
1472 parsed_command_line().HasSwitch(switches::kShowIcons)) { 1468 parsed_command_line().HasSwitch(switches::kShowIcons)) {
1473 return HandleIconsCommands(parsed_command_line()); 1469 return ChromeBrowserMainPartsWin::HandleIconsCommands(
1470 parsed_command_line());
jam 2011/10/24 19:36:00 ditto
stevenjb 2011/10/25 02:51:04 Done.
1474 } 1471 }
1472 #endif
1473
1475 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { 1474 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) {
1476 return ShellIntegration::SetAsDefaultBrowser() ? 1475 return ShellIntegration::SetAsDefaultBrowser() ?
1477 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : 1476 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) :
1478 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); 1477 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
1479 } 1478 }
1480 1479
1481 // If the command line specifies --pack-extension, attempt the pack extension 1480 // If the command line specifies --pack-extension, attempt the pack extension
1482 // startup action and exit. 1481 // startup action and exit.
1483 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { 1482 if (parsed_command_line().HasSwitch(switches::kPackExtension)) {
1484 ExtensionsStartupUtil extension_startup_util; 1483 ExtensionsStartupUtil extension_startup_util;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 if (parsed_command_line().HasSwitch(switches::kImport) || 1616 if (parsed_command_line().HasSwitch(switches::kImport) ||
1618 parsed_command_line().HasSwitch(switches::kImportFromFile)) { 1617 parsed_command_line().HasSwitch(switches::kImportFromFile)) {
1619 return FirstRun::ImportNow(profile_, parsed_command_line()); 1618 return FirstRun::ImportNow(profile_, parsed_command_line());
1620 } 1619 }
1621 #endif 1620 #endif
1622 1621
1623 #if defined(OS_WIN) 1622 #if defined(OS_WIN)
1624 // Do the tasks if chrome has been upgraded while it was last running. 1623 // Do the tasks if chrome has been upgraded while it was last running.
1625 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) 1624 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line()))
1626 return content::RESULT_CODE_NORMAL_EXIT; 1625 return content::RESULT_CODE_NORMAL_EXIT;
1627 #endif
1628 1626
1629 // Check if there is any machine level Chrome installed on the current 1627 // Check if there is any machine level Chrome installed on the current
1630 // machine. If yes and the current Chrome process is user level, we do not 1628 // machine. If yes and the current Chrome process is user level, we do not
1631 // allow the user level Chrome to run. So we notify the user and uninstall 1629 // allow the user level Chrome to run. So we notify the user and uninstall
1632 // user level Chrome. 1630 // user level Chrome.
1633 // Note this check should only happen here, after all the checks above 1631 // Note this check should only happen here, after all the checks above
1634 // (uninstall, resource bundle initialization, other chrome browser 1632 // (uninstall, resource bundle initialization, other chrome browser
1635 // processes etc). 1633 // processes etc).
1636 // Do not allow this to occur for Chrome Frame user-to-system handoffs. 1634 // Do not allow this to occur for Chrome Frame user-to-system handoffs.
1637 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) && 1635 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) &&
1638 CheckMachineLevelInstall()) { 1636 ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) {
1639 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; 1637 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS;
1640 } 1638 }
1639 #endif
1641 1640
1642 // Create the TranslateManager singleton. 1641 // Create the TranslateManager singleton.
1643 translate_manager_ = TranslateManager::GetInstance(); 1642 translate_manager_ = TranslateManager::GetInstance();
1644 DCHECK(translate_manager_ != NULL); 1643 DCHECK(translate_manager_ != NULL);
1645 1644
1646 #if defined(OS_MACOSX) 1645 #if defined(OS_MACOSX)
1647 if (!parsed_command_line().HasSwitch(switches::kNoFirstRun)) { 1646 if (!parsed_command_line().HasSwitch(switches::kNoFirstRun)) {
1648 // Disk image installation is sort of a first-run task, so it shares the 1647 // Disk image installation is sort of a first-run task, so it shares the
1649 // kNoFirstRun switch. 1648 // kNoFirstRun switch.
1650 if (MaybeInstallFromDiskImage()) { 1649 if (MaybeInstallFromDiskImage()) {
(...skipping 27 matching lines...) Expand all
1678 // the pref. 1677 // the pref.
1679 if (GoogleUpdateSettings::GetCollectStatsConsent()) 1678 if (GoogleUpdateSettings::GetCollectStatsConsent())
1680 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); 1679 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true);
1681 #endif // OS_POSIX 1680 #endif // OS_POSIX
1682 } // if (!first_run_ui_bypass) 1681 } // if (!first_run_ui_bypass)
1683 1682
1684 Browser::SetNewHomePagePrefs(user_prefs); 1683 Browser::SetNewHomePagePrefs(user_prefs);
1685 g_browser_process->profile_manager()->OnImportFinished(profile_); 1684 g_browser_process->profile_manager()->OnImportFinished(profile_);
1686 } // if (is_first_run) 1685 } // if (is_first_run)
1687 1686
1687 #if defined(OS_WIN)
1688 // Sets things up so that if we crash from this point on, a dialog will 1688 // Sets things up so that if we crash from this point on, a dialog will
1689 // popup asking the user to restart chrome. It is done this late to avoid 1689 // popup asking the user to restart chrome. It is done this late to avoid
1690 // testing against a bunch of special cases that are taken care early on. 1690 // testing against a bunch of special cases that are taken care early on.
1691 PrepareRestartOnCrashEnviroment(parsed_command_line()); 1691 ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment(
1692 parsed_command_line());
1693 #endif // OS_WIN
1692 1694
1693 // Start watching for hangs during startup. We disarm this hang detector when 1695 // Start watching for hangs during startup. We disarm this hang detector when
1694 // ThreadWatcher takes over or when browser is shutdown. 1696 // ThreadWatcher takes over or when browser is shutdown.
1695 StartupTimeBomb::Arm(base::TimeDelta::FromSeconds(300)); 1697 StartupTimeBomb::Arm(base::TimeDelta::FromSeconds(300));
jam 2011/10/24 19:36:00 let's move this to line 1746 so that we can one O
stevenjb 2011/10/25 02:51:04 Done. (Had considered doing that but wasn't certai
1696 1698
1697 #if defined(OS_WIN) 1699 #if defined(OS_WIN)
1698 // Registers Chrome with the Windows Restart Manager, which will restore the 1700 // Registers Chrome with the Windows Restart Manager, which will restore the
1699 // Chrome session when the computer is restarted after a system update. 1701 // Chrome session when the computer is restarted after a system update.
1700 // This could be run as late as WM_QUERYENDSESSION for system update reboots, 1702 // This could be run as late as WM_QUERYENDSESSION for system update reboots,
1701 // but should run on startup if extended to handle crashes/hangs/patches. 1703 // but should run on startup if extended to handle crashes/hangs/patches.
1702 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION. 1704 // Also, better to run once here than once for each HWND's WM_QUERYENDSESSION.
1703 if (base::win::GetVersion() >= base::win::VERSION_VISTA) 1705 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1704 RegisterApplicationRestart(parsed_command_line()); 1706 ChromeBrowserMainPartsWin::RegisterApplicationRestart(
1707 parsed_command_line());
1708 }
1705 #endif // OS_WIN 1709 #endif // OS_WIN
1706 1710
1707 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) 1711 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD)
1708 // Init the RLZ library. This just binds the dll and schedules a task on the 1712 // Init the RLZ library. This just binds the dll and schedules a task on the
1709 // file thread to be run sometime later. If this is the first run we record 1713 // file thread to be run sometime later. If this is the first run we record
1710 // the installation event. 1714 // the installation event.
1711 bool google_search_default = false; 1715 bool google_search_default = false;
1712 TemplateURLService* template_url_service = 1716 TemplateURLService* template_url_service =
1713 TemplateURLServiceFactory::GetForProfile(profile_); 1717 TemplateURLServiceFactory::GetForProfile(profile_);
1714 if (template_url_service) { 1718 if (template_url_service) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 } 1935 }
1932 #endif 1936 #endif
1933 1937
1934 run_message_loop_ = true; 1938 run_message_loop_ = true;
1935 } 1939 }
1936 } 1940 }
1937 1941
1938 return result_code; 1942 return result_code;
1939 } 1943 }
1940 1944
1941 void ChromeBrowserMainParts::MainMessageLoopRun() { 1945 bool ChromeBrowserMainParts::MainMessageLoopRun() {
1942 if (!run_message_loop_) 1946 if (!run_message_loop_)
1943 return; 1947 return true; // Don't run the default message loop.
1944 1948
1945 // This should be invoked as close to the start of the browser's 1949 // This should be invoked as close to the start of the browser's
1946 // UI thread message loop as possible to get a stable measurement 1950 // UI thread message loop as possible to get a stable measurement
1947 // across versions. 1951 // across versions.
1948 RecordBrowserStartupTime(); 1952 RecordBrowserStartupTime();
1949 1953
1950 #if defined(USE_AURA) 1954 #if defined(USE_AURA)
1951 aura::Desktop::GetInstance()->Run(); 1955 aura::Desktop::GetInstance()->Run();
1952 #elif defined(TOOLKIT_VIEWS) 1956 #elif defined(TOOLKIT_VIEWS)
1953 views::AcceleratorHandler accelerator_handler; 1957 views::AcceleratorHandler accelerator_handler;
1954 MessageLoopForUI::current()->Run(&accelerator_handler); 1958 MessageLoopForUI::current()->Run(&accelerator_handler);
1955 #elif defined(USE_X11) 1959 #elif defined(USE_X11)
1956 MessageLoopForUI::current()->Run(NULL); 1960 MessageLoopForUI::current()->Run(NULL);
1957 #elif defined(OS_POSIX) 1961 #elif defined(OS_POSIX)
1958 MessageLoopForUI::current()->Run(); 1962 MessageLoopForUI::current()->Run();
1959 #endif 1963 #endif
1960 #if defined(OS_CHROMEOS) 1964 #if defined(OS_CHROMEOS)
1961 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", 1965 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded",
1962 true); 1966 true);
1963 #endif 1967 #endif
1968
1969 return true;
1964 } 1970 }
1965 1971
1966 void ChromeBrowserMainParts::PostMainMessageLoopRun() { 1972 void ChromeBrowserMainParts::PostMainMessageLoopRun() {
1967 // Start watching for jank during shutdown. It gets disarmed when 1973 // Start watching for jank during shutdown. It gets disarmed when
1968 // |shutdown_watcher_| object is destructed. 1974 // |shutdown_watcher_| object is destructed.
1969 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(90)); 1975 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(90));
1970 1976
1971 // Disarm the startup hang detector time bomb if it is still Arm'ed. 1977 // Disarm the startup hang detector time bomb if it is still Arm'ed.
1972 StartupTimeBomb::Disarm(); 1978 StartupTimeBomb::Disarm();
1973 1979
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && 2102 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) &&
2097 (pre_read == "0" || pre_read == "1")) { 2103 (pre_read == "0" || pre_read == "1")) {
2098 std::string uma_name(name); 2104 std::string uma_name(name);
2099 uma_name += "_PreRead"; 2105 uma_name += "_PreRead";
2100 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; 2106 uma_name += pre_read == "1" ? "Enabled" : "Disabled";
2101 AddPreReadHistogramTime(uma_name.c_str(), time); 2107 AddPreReadHistogramTime(uma_name.c_str(), time);
2102 } 2108 }
2103 #endif 2109 #endif
2104 #endif 2110 #endif
2105 } 2111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698