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 |
11 #include "base/at_exit.h" | 11 #include "base/at_exit.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" |
14 #include "base/file_path.h" | 14 #include "base/file_path.h" |
15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
16 #include "base/mac/scoped_nsautorelease_pool.h" | 16 #include "base/mac/scoped_nsautorelease_pool.h" |
17 #include "base/metrics/field_trial.h" | 17 #include "base/metrics/field_trial.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
21 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
22 #include "base/string_piece.h" | 22 #include "base/string_piece.h" |
23 #include "base/string_split.h" | 23 #include "base/string_split.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/sys_string_conversions.h" | 25 #include "base/sys_string_conversions.h" |
26 #include "base/threading/platform_thread.h" | 26 #include "base/threading/platform_thread.h" |
27 #include "base/threading/thread_restrictions.h" | |
28 #include "base/time.h" | 27 #include "base/time.h" |
29 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
30 #include "base/values.h" | 29 #include "base/values.h" |
31 #include "build/build_config.h" | 30 #include "build/build_config.h" |
32 #include "chrome/browser/about_flags.h" | 31 #include "chrome/browser/about_flags.h" |
33 #include "chrome/browser/browser_main_win.h" | 32 #include "chrome/browser/browser_main_win.h" |
34 #include "chrome/browser/browser_process.h" | |
35 #include "chrome/browser/browser_process_impl.h" | 33 #include "chrome/browser/browser_process_impl.h" |
36 #include "chrome/browser/browser_shutdown.h" | 34 #include "chrome/browser/browser_shutdown.h" |
37 #include "chrome/browser/defaults.h" | 35 #include "chrome/browser/defaults.h" |
38 #include "chrome/browser/extensions/extension_protocols.h" | 36 #include "chrome/browser/extensions/extension_protocols.h" |
39 #include "chrome/browser/extensions/extension_service.h" | 37 #include "chrome/browser/extensions/extension_service.h" |
40 #include "chrome/browser/extensions/extensions_startup.h" | 38 #include "chrome/browser/extensions/extensions_startup.h" |
41 #include "chrome/browser/first_run/first_run.h" | |
42 #include "chrome/browser/first_run/first_run_browser_process.h" | 39 #include "chrome/browser/first_run/first_run_browser_process.h" |
43 #include "chrome/browser/first_run/upgrade_util.h" | 40 #include "chrome/browser/first_run/upgrade_util.h" |
44 #include "chrome/browser/google/google_url_tracker.h" | 41 #include "chrome/browser/google/google_url_tracker.h" |
45 #include "chrome/browser/instant/instant_field_trial.h" | 42 #include "chrome/browser/instant/instant_field_trial.h" |
46 #include "chrome/browser/jankometer.h" | 43 #include "chrome/browser/jankometer.h" |
47 #include "chrome/browser/language_usage_metrics.h" | 44 #include "chrome/browser/language_usage_metrics.h" |
48 #include "chrome/browser/metrics/field_trial_synchronizer.h" | 45 #include "chrome/browser/metrics/field_trial_synchronizer.h" |
49 #include "chrome/browser/metrics/histogram_synchronizer.h" | 46 #include "chrome/browser/metrics/histogram_synchronizer.h" |
50 #include "chrome/browser/metrics/metrics_log.h" | 47 #include "chrome/browser/metrics/metrics_log.h" |
51 #include "chrome/browser/metrics/metrics_service.h" | 48 #include "chrome/browser/metrics/metrics_service.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 #endif | 145 #endif |
149 | 146 |
150 // 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 |
151 // 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 |
152 // 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 |
153 // 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. |
154 | 151 |
155 #if defined(OS_WIN) | 152 #if defined(OS_WIN) |
156 | 153 |
157 #include "base/environment.h" // For PreRead experiment. | 154 #include "base/environment.h" // For PreRead experiment. |
158 #include "base/win/scoped_com_initializer.h" | |
159 #include "base/win/windows_version.h" | 155 #include "base/win/windows_version.h" |
160 #include "chrome/browser/browser_trial.h" | 156 #include "chrome/browser/browser_trial.h" |
161 #include "chrome/browser/browser_util_win.h" | 157 #include "chrome/browser/browser_util_win.h" |
162 #include "chrome/browser/first_run/try_chrome_dialog_view.h" | 158 #include "chrome/browser/first_run/try_chrome_dialog_view.h" |
163 #include "chrome/browser/first_run/upgrade_util_win.h" | 159 #include "chrome/browser/first_run/upgrade_util_win.h" |
164 #include "chrome/browser/net/url_fixer_upper.h" | 160 #include "chrome/browser/net/url_fixer_upper.h" |
165 #include "chrome/browser/rlz/rlz.h" | 161 #include "chrome/browser/rlz/rlz.h" |
166 #include "chrome/browser/ui/views/user_data_dir_dialog.h" | 162 #include "chrome/browser/ui/views/user_data_dir_dialog.h" |
167 #include "chrome/installer/util/helper.h" | 163 #include "chrome/installer/util/helper.h" |
168 #include "chrome/installer/util/install_util.h" | 164 #include "chrome/installer/util/install_util.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 217 |
222 #if defined(OS_CHROMEOS) | 218 #if defined(OS_CHROMEOS) |
223 // Test loading libcros and exit. We return 0 if the library could be loaded, | 219 // Test loading libcros and exit. We return 0 if the library could be loaded, |
224 // and 1 if it can't be. This is for validation that the library is installed | 220 // and 1 if it can't be. This is for validation that the library is installed |
225 // and versioned properly for Chrome to find. | 221 // and versioned properly for Chrome to find. |
226 if (command_line.HasSwitch(switches::kTestLoadLibcros)) | 222 if (command_line.HasSwitch(switches::kTestLoadLibcros)) |
227 exit(!chromeos::CrosLibrary::Get()->EnsureLoaded()); | 223 exit(!chromeos::CrosLibrary::Get()->EnsureLoaded()); |
228 #endif | 224 #endif |
229 } | 225 } |
230 | 226 |
231 void RunUIMessageLoop(BrowserProcess* browser_process) { | |
232 TRACE_EVENT_BEGIN_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | |
233 // This should be invoked as close to the start of the browser's | |
234 // UI thread message loop as possible to get a stable measurement | |
235 // across versions. | |
236 RecordBrowserStartupTime(); | |
237 | |
238 // If the UI thread blocks, the whole UI is unresponsive. | |
239 // Do not allow disk IO from the UI thread. | |
240 base::ThreadRestrictions::SetIOAllowed(false); | |
241 | |
242 #if defined(TOOLKIT_VIEWS) | |
243 views::AcceleratorHandler accelerator_handler; | |
244 MessageLoopForUI::current()->Run(&accelerator_handler); | |
245 #elif defined(USE_X11) | |
246 MessageLoopForUI::current()->Run(NULL); | |
247 #elif defined(OS_POSIX) | |
248 MessageLoopForUI::current()->Run(); | |
249 #endif | |
250 #if defined(OS_CHROMEOS) | |
251 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", | |
252 true); | |
253 #endif | |
254 | |
255 TRACE_EVENT_END_ETW("BrowserMain:MESSAGE_LOOP", 0, ""); | |
256 } | |
257 | |
258 void AddFirstRunNewTabs(BrowserInit* browser_init, | 227 void AddFirstRunNewTabs(BrowserInit* browser_init, |
259 const std::vector<GURL>& new_tabs) { | 228 const std::vector<GURL>& new_tabs) { |
260 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); | 229 for (std::vector<GURL>::const_iterator it = new_tabs.begin(); |
261 it != new_tabs.end(); ++it) { | 230 it != new_tabs.end(); ++it) { |
262 if (it->is_valid()) | 231 if (it->is_valid()) |
263 browser_init->AddFirstRunTab(*it); | 232 browser_init->AddFirstRunTab(*it); |
264 } | 233 } |
265 } | 234 } |
266 | 235 |
267 #if defined(USE_LINUX_BREAKPAD) | 236 #if defined(USE_LINUX_BREAKPAD) |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 const char kMissingLocaleDataTitle[] = "Missing File Error"; | 660 const char kMissingLocaleDataTitle[] = "Missing File Error"; |
692 const char kMissingLocaleDataMessage[] = | 661 const char kMissingLocaleDataMessage[] = |
693 "Unable to find locale data files. Please reinstall."; | 662 "Unable to find locale data files. Please reinstall."; |
694 } // namespace chrome_browser | 663 } // namespace chrome_browser |
695 | 664 |
696 // BrowserMainParts ------------------------------------------------------------ | 665 // BrowserMainParts ------------------------------------------------------------ |
697 | 666 |
698 ChromeBrowserMainParts::ChromeBrowserMainParts( | 667 ChromeBrowserMainParts::ChromeBrowserMainParts( |
699 const MainFunctionParams& parameters) | 668 const MainFunctionParams& parameters) |
700 : BrowserMainParts(parameters), | 669 : BrowserMainParts(parameters), |
701 shutdown_watcher_(new ShutdownWatcherHelper()) { | 670 shutdown_watcher_(new ShutdownWatcherHelper()), |
| 671 record_search_engine_(false), |
| 672 translate_manager_(NULL), |
| 673 profile_(NULL), |
| 674 run_message_loop_(true) { |
702 // If we're running tests (ui_task is non-null). | 675 // If we're running tests (ui_task is non-null). |
703 if (parameters.ui_task) | 676 if (parameters.ui_task) |
704 browser_defaults::enable_help_app = false; | 677 browser_defaults::enable_help_app = false; |
705 } | 678 } |
706 | 679 |
707 ChromeBrowserMainParts::~ChromeBrowserMainParts() { | 680 ChromeBrowserMainParts::~ChromeBrowserMainParts() { |
708 } | 681 } |
709 | 682 |
710 void ChromeBrowserMainParts::SetupHistogramSynchronizer() { | |
711 histogram_synchronizer_ = new HistogramSynchronizer(); | |
712 } | |
713 | |
714 // This will be called after the command-line has been mutated by about:flags | 683 // This will be called after the command-line has been mutated by about:flags |
715 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( | 684 MetricsService* ChromeBrowserMainParts::SetupMetricsAndFieldTrials( |
716 const CommandLine& parsed_command_line, | 685 const CommandLine& parsed_command_line, |
717 PrefService* local_state) { | 686 PrefService* local_state) { |
718 // Must initialize metrics after labs have been converted into switches, | 687 // Must initialize metrics after labs have been converted into switches, |
719 // but before field trials are set up (so that client ID is available for | 688 // but before field trials are set up (so that client ID is available for |
720 // one-time randomized field trials). | 689 // one-time randomized field trials). |
721 MetricsService* metrics = InitializeMetrics(parsed_command_line, local_state); | 690 MetricsService* metrics = InitializeMetrics(parsed_command_line, local_state); |
722 | 691 |
723 // Initialize FieldTrialList to support FieldTrials that use one-time | 692 // Initialize FieldTrialList to support FieldTrials that use one-time |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 // in ChromeMain() got destructed when the function returned. | 1070 // in ChromeMain() got destructed when the function returned. |
1102 base::AtExitManager exit_manager; | 1071 base::AtExitManager exit_manager; |
1103 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); | 1072 upgrade_util::RelaunchChromeBrowserWithNewCommandLineIfNeeded(); |
1104 } | 1073 } |
1105 #endif | 1074 #endif |
1106 | 1075 |
1107 void ChromeBrowserMainParts::PostMainMessageLoopStart() { | 1076 void ChromeBrowserMainParts::PostMainMessageLoopStart() { |
1108 Profiling::MainMessageLoopStarted(); | 1077 Profiling::MainMessageLoopStarted(); |
1109 } | 1078 } |
1110 | 1079 |
1111 void ChromeBrowserMainParts::ToolkitInitialized() { | 1080 void ChromeBrowserMainParts::PreMainMessageLoopRun() { |
1112 #if defined(TOOLKIT_VIEWS) | 1081 set_result_code(PreMainMessageLoopRunInternal()); |
1113 // The delegate needs to be set before any UI is created so that windows | |
1114 // display the correct icon. | |
1115 if (!views::ViewsDelegate::views_delegate) | |
1116 views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; | |
1117 | |
1118 // TODO(beng): Move to WidgetImpl and implement on Windows too! | |
1119 if (parameters().command_line_.HasSwitch(switches::kDebugViewsPaint)) | |
1120 views::Widget::SetDebugPaintEnabled(true); | |
1121 #endif | |
1122 | |
1123 #if defined(OS_WIN) | |
1124 gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; | |
1125 gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; | |
1126 #endif | |
1127 } | 1082 } |
1128 | 1083 |
1129 int ChromeBrowserMainParts::TemporaryContinue() { | 1084 int ChromeBrowserMainParts::PreMainMessageLoopRunInternal() { |
| 1085 run_message_loop_ = false; |
1130 FilePath user_data_dir; | 1086 FilePath user_data_dir; |
1131 #if defined(OS_WIN) | 1087 #if defined(OS_WIN) |
1132 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | 1088 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); |
1133 #else | 1089 #else |
1134 // Getting the user data dir can fail if the directory isn't | 1090 // Getting the user data dir can fail if the directory isn't |
1135 // creatable, for example; on Windows in code below we bring up a | 1091 // creatable, for example; on Windows in code below we bring up a |
1136 // dialog prompting the user to pick a different directory. | 1092 // dialog prompting the user to pick a different directory. |
1137 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, | 1093 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, |
1138 // so it's better to fail here than fail mysteriously elsewhere. | 1094 // so it's better to fail here than fail mysteriously elsewhere. |
1139 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | 1095 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) |
1140 << "Must be able to get user data directory!"; | 1096 << "Must be able to get user data directory!"; |
1141 #endif | 1097 #endif |
1142 | 1098 |
1143 ProcessSingleton process_singleton(user_data_dir); | 1099 process_singleton_.reset(new ProcessSingleton(user_data_dir)); |
1144 | 1100 |
1145 bool is_first_run = FirstRun::IsChromeFirstRun() || | 1101 bool is_first_run = FirstRun::IsChromeFirstRun() || |
1146 parsed_command_line().HasSwitch(switches::kFirstRun); | 1102 parsed_command_line().HasSwitch(switches::kFirstRun); |
1147 | 1103 |
1148 scoped_ptr<BrowserProcessImpl> browser_process; | |
1149 if (parsed_command_line().HasSwitch(switches::kImport) || | 1104 if (parsed_command_line().HasSwitch(switches::kImport) || |
1150 parsed_command_line().HasSwitch(switches::kImportFromFile)) { | 1105 parsed_command_line().HasSwitch(switches::kImportFromFile)) { |
1151 // We use different BrowserProcess when importing so no GoogleURLTracker is | 1106 // We use different BrowserProcess when importing so no GoogleURLTracker is |
1152 // instantiated (as it makes a net::URLRequest and we don't have an IO | 1107 // instantiated (as it makes a net::URLRequest and we don't have an IO |
1153 // thread, see bug #1292702). | 1108 // thread, see bug #1292702). |
1154 browser_process.reset(new FirstRunBrowserProcess(parsed_command_line())); | 1109 browser_process_.reset(new FirstRunBrowserProcess(parsed_command_line())); |
1155 is_first_run = false; | 1110 is_first_run = false; |
1156 } else { | 1111 } else { |
1157 browser_process.reset(new BrowserProcessImpl(parsed_command_line())); | 1112 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); |
1158 } | 1113 } |
1159 | 1114 |
1160 // This forces the TabCloseableStateWatcher to be created and, on chromeos, | 1115 // This forces the TabCloseableStateWatcher to be created and, on chromeos, |
1161 // register for the notifications it needs to track the closeable state of | 1116 // register for the notifications it needs to track the closeable state of |
1162 // tabs. | 1117 // tabs. |
1163 g_browser_process->tab_closeable_state_watcher(); | 1118 g_browser_process->tab_closeable_state_watcher(); |
1164 | 1119 |
1165 PrefService* local_state = InitializeLocalState(parsed_command_line(), | 1120 PrefService* local_state = InitializeLocalState(parsed_command_line(), |
1166 is_first_run); | 1121 is_first_run); |
1167 | 1122 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 #if defined(TOOLKIT_GTK) | 1164 #if defined(TOOLKIT_GTK) |
1210 g_set_application_name(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str()); | 1165 g_set_application_name(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str()); |
1211 #endif | 1166 #endif |
1212 | 1167 |
1213 std::string try_chrome = | 1168 std::string try_chrome = |
1214 parsed_command_line().GetSwitchValueASCII(switches::kTryChromeAgain); | 1169 parsed_command_line().GetSwitchValueASCII(switches::kTryChromeAgain); |
1215 if (!try_chrome.empty()) { | 1170 if (!try_chrome.empty()) { |
1216 #if defined(OS_WIN) && !defined(USE_AURA) | 1171 #if defined(OS_WIN) && !defined(USE_AURA) |
1217 // Setup.exe has determined that we need to run a retention experiment | 1172 // Setup.exe has determined that we need to run a retention experiment |
1218 // and has lauched chrome to show the experiment UI. | 1173 // and has lauched chrome to show the experiment UI. |
1219 if (process_singleton.FoundOtherProcessWindow()) { | 1174 if (process_singleton_->FoundOtherProcessWindow()) { |
1220 // It seems that we don't need to run the experiment since chrome | 1175 // It seems that we don't need to run the experiment since chrome |
1221 // in the same profile is already running. | 1176 // in the same profile is already running. |
1222 VLOG(1) << "Retention experiment not required"; | 1177 VLOG(1) << "Retention experiment not required"; |
1223 return TryChromeDialogView::NOT_NOW; | 1178 return TryChromeDialogView::NOT_NOW; |
1224 } | 1179 } |
1225 int try_chrome_int; | 1180 int try_chrome_int; |
1226 base::StringToInt(try_chrome, &try_chrome_int); | 1181 base::StringToInt(try_chrome, &try_chrome_int); |
1227 TryChromeDialogView::Result answer = | 1182 TryChromeDialogView::Result answer = |
1228 TryChromeDialogView::Show(try_chrome_int, &process_singleton); | 1183 TryChromeDialogView::Show(try_chrome_int, process_singleton_.get()); |
1229 if (answer == TryChromeDialogView::NOT_NOW) | 1184 if (answer == TryChromeDialogView::NOT_NOW) |
1230 return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL; | 1185 return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL; |
1231 if (answer == TryChromeDialogView::UNINSTALL_CHROME) | 1186 if (answer == TryChromeDialogView::UNINSTALL_CHROME) |
1232 return chrome::RESULT_CODE_NORMAL_EXIT_EXP2; | 1187 return chrome::RESULT_CODE_NORMAL_EXIT_EXP2; |
1233 #else | 1188 #else |
1234 // We don't support retention experiments on Mac or Linux. | 1189 // We don't support retention experiments on Mac or Linux. |
1235 return content::RESULT_CODE_NORMAL_EXIT; | 1190 return content::RESULT_CODE_NORMAL_EXIT; |
1236 #endif // defined(OS_WIN) | 1191 #endif // defined(OS_WIN) |
1237 } | 1192 } |
1238 | 1193 |
(...skipping 23 matching lines...) Expand all Loading... |
1262 chrome_views_delegate->default_parent_view = | 1217 chrome_views_delegate->default_parent_view = |
1263 views::desktop::DesktopWindowView::desktop_window_view; | 1218 views::desktop::DesktopWindowView::desktop_window_view; |
1264 } | 1219 } |
1265 #endif | 1220 #endif |
1266 | 1221 |
1267 BrowserInit browser_init; | 1222 BrowserInit browser_init; |
1268 | 1223 |
1269 // On first run, we need to process the predictor preferences before the | 1224 // On first run, we need to process the predictor preferences before the |
1270 // browser's profile_manager object is created, but after ResourceBundle | 1225 // browser's profile_manager object is created, but after ResourceBundle |
1271 // is initialized. | 1226 // is initialized. |
1272 FirstRun::MasterPrefs master_prefs; | 1227 master_prefs_.reset(new FirstRun::MasterPrefs); |
1273 bool first_run_ui_bypass = false; // True to skip first run UI. | 1228 bool first_run_ui_bypass = false; // True to skip first run UI. |
1274 if (is_first_run) { | 1229 if (is_first_run) { |
1275 first_run_ui_bypass = | 1230 first_run_ui_bypass = |
1276 !FirstRun::ProcessMasterPreferences(user_data_dir, &master_prefs); | 1231 !FirstRun::ProcessMasterPreferences(user_data_dir, master_prefs_.get()); |
1277 AddFirstRunNewTabs(&browser_init, master_prefs.new_tabs); | 1232 AddFirstRunNewTabs(&browser_init, master_prefs_->new_tabs); |
1278 | 1233 |
1279 // If we are running in App mode, we do not want to show the importer | 1234 // If we are running in App mode, we do not want to show the importer |
1280 // (first run) UI. | 1235 // (first run) UI. |
1281 if (!first_run_ui_bypass && | 1236 if (!first_run_ui_bypass && |
1282 (parsed_command_line().HasSwitch(switches::kApp) || | 1237 (parsed_command_line().HasSwitch(switches::kApp) || |
1283 parsed_command_line().HasSwitch(switches::kAppId) || | 1238 parsed_command_line().HasSwitch(switches::kAppId) || |
1284 parsed_command_line().HasSwitch(switches::kNoFirstRun))) | 1239 parsed_command_line().HasSwitch(switches::kNoFirstRun))) |
1285 first_run_ui_bypass = true; | 1240 first_run_ui_bypass = true; |
1286 } | 1241 } |
1287 | 1242 |
(...skipping 10 matching lines...) Expand all Loading... |
1298 local_state->SetBoolean(prefs::kPrintingPrintPreviewEnabledOnce, true); | 1253 local_state->SetBoolean(prefs::kPrintingPrintPreviewEnabledOnce, true); |
1299 about_flags::SetExperimentEnabled(local_state, "print-preview", true); | 1254 about_flags::SetExperimentEnabled(local_state, "print-preview", true); |
1300 } | 1255 } |
1301 #endif | 1256 #endif |
1302 | 1257 |
1303 // Convert active labs into switches. Modifies the current command line. | 1258 // Convert active labs into switches. Modifies the current command line. |
1304 about_flags::ConvertFlagsToSwitches(local_state, | 1259 about_flags::ConvertFlagsToSwitches(local_state, |
1305 CommandLine::ForCurrentProcess()); | 1260 CommandLine::ForCurrentProcess()); |
1306 | 1261 |
1307 InitializeNetworkOptions(parsed_command_line()); | 1262 InitializeNetworkOptions(parsed_command_line()); |
1308 InitializeURLRequestThrottlerManager(browser_process->net_log()); | 1263 InitializeURLRequestThrottlerManager(browser_process_->net_log()); |
1309 | 1264 |
1310 // Initialize histogram synchronizer system. This is a singleton and is used | 1265 // Initialize histogram synchronizer system. This is a singleton and is used |
1311 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of | 1266 // for posting tasks via NewRunnableMethod. Its deleted when it goes out of |
1312 // scope. Even though NewRunnableMethod does AddRef and Release, the object | 1267 // scope. Even though NewRunnableMethod does AddRef and Release, the object |
1313 // will not be deleted after the Task is executed. | 1268 // will not be deleted after the Task is executed. |
1314 SetupHistogramSynchronizer(); | 1269 histogram_synchronizer_ = new HistogramSynchronizer(); |
1315 | 1270 |
1316 // Now the command line has been mutated based on about:flags, we can | 1271 // Now the command line has been mutated based on about:flags, we can |
1317 // set up metrics and initialize field trials. | 1272 // set up metrics and initialize field trials. |
1318 MetricsService* metrics = SetupMetricsAndFieldTrials( | 1273 MetricsService* metrics = |
1319 parsed_command_line(), local_state); | 1274 SetupMetricsAndFieldTrials(parsed_command_line(), local_state); |
1320 | 1275 |
1321 // Now that all preferences have been registered, set the install date | 1276 // Now that all preferences have been registered, set the install date |
1322 // for the uninstall metrics if this is our first run. This only actually | 1277 // for the uninstall metrics if this is our first run. This only actually |
1323 // gets used if the user has metrics reporting enabled at uninstall time. | 1278 // gets used if the user has metrics reporting enabled at uninstall time. |
1324 int64 install_date = | 1279 int64 install_date = |
1325 local_state->GetInt64(prefs::kUninstallMetricsInstallDate); | 1280 local_state->GetInt64(prefs::kUninstallMetricsInstallDate); |
1326 if (install_date == 0) { | 1281 if (install_date == 0) { |
1327 local_state->SetInt64(prefs::kUninstallMetricsInstallDate, | 1282 local_state->SetInt64(prefs::kUninstallMetricsInstallDate, |
1328 base::Time::Now().ToTimeT()); | 1283 base::Time::Now().ToTimeT()); |
1329 } | 1284 } |
1330 | 1285 |
1331 #if defined(OS_MACOSX) | 1286 #if defined(OS_MACOSX) |
1332 // Get the Keychain API to register for distributed notifications on the main | 1287 // Get the Keychain API to register for distributed notifications on the main |
1333 // thread, which has a proper CFRunloop, instead of later on the I/O thread, | 1288 // thread, which has a proper CFRunloop, instead of later on the I/O thread, |
1334 // which doesn't. This ensures those notifications will get delivered | 1289 // which doesn't. This ensures those notifications will get delivered |
1335 // properly. See issue 37766. | 1290 // properly. See issue 37766. |
1336 // (Note that the callback mask here is empty. I don't want to register for | 1291 // (Note that the callback mask here is empty. I don't want to register for |
1337 // any callbacks, I just want to initialize the mechanism.) | 1292 // any callbacks, I just want to initialize the mechanism.) |
1338 SecKeychainAddCallback(&KeychainCallback, 0, NULL); | 1293 SecKeychainAddCallback(&KeychainCallback, 0, NULL); |
1339 #endif | 1294 #endif |
1340 | 1295 |
1341 CreateChildThreads(browser_process.get()); | 1296 CreateChildThreads(browser_process_.get()); |
1342 | 1297 |
1343 #if defined(OS_CHROMEOS) | 1298 #if defined(OS_CHROMEOS) |
1344 // Now that the file thread exists we can record our stats. | 1299 // Now that the file thread exists we can record our stats. |
1345 chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); | 1300 chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); |
1346 | 1301 |
1347 // Read locale-specific GTK resource information. | 1302 // Read locale-specific GTK resource information. |
1348 std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC); | 1303 std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC); |
1349 if (!gtkrc.empty()) | 1304 if (!gtkrc.empty()) |
1350 gtk_rc_parse_string(gtkrc.c_str()); | 1305 gtk_rc_parse_string(gtkrc.c_str()); |
1351 | 1306 |
1352 // Trigger prefetching of ownership status. | 1307 // Trigger prefetching of ownership status. |
1353 chromeos::OwnershipService::GetSharedInstance()->Prewarm(); | 1308 chromeos::OwnershipService::GetSharedInstance()->Prewarm(); |
1354 #endif | 1309 #endif |
1355 | 1310 |
1356 // Record last shutdown time into a histogram. | 1311 // Record last shutdown time into a histogram. |
1357 browser_shutdown::ReadLastShutdownInfo(); | 1312 browser_shutdown::ReadLastShutdownInfo(); |
1358 | 1313 |
1359 #if defined(OS_WIN) | 1314 #if defined(OS_WIN) |
1360 // On Windows, we use our startup as an opportunity to do upgrade/uninstall | 1315 // On Windows, we use our startup as an opportunity to do upgrade/uninstall |
1361 // tasks. Those care whether the browser is already running. On Linux/Mac, | 1316 // tasks. Those care whether the browser is already running. On Linux/Mac, |
1362 // upgrade/uninstall happen separately. | 1317 // upgrade/uninstall happen separately. |
1363 bool already_running = browser_util::IsBrowserAlreadyRunning(); | 1318 bool already_running = browser_util::IsBrowserAlreadyRunning(); |
1364 | 1319 |
1365 // If the command line specifies 'uninstall' then we need to work here | 1320 // If the command line specifies 'uninstall' then we need to work here |
1366 // unless we detect another chrome browser running. | 1321 // unless we detect another chrome browser running. |
1367 if (parsed_command_line().HasSwitch(switches::kUninstall)) | 1322 if (parsed_command_line().HasSwitch(switches::kUninstall)) { |
1368 return DoUninstallTasks(already_running); | 1323 return DoUninstallTasks(already_running); |
| 1324 } |
1369 #endif | 1325 #endif |
1370 | 1326 |
1371 if (parsed_command_line().HasSwitch(switches::kHideIcons) || | 1327 if (parsed_command_line().HasSwitch(switches::kHideIcons) || |
1372 parsed_command_line().HasSwitch(switches::kShowIcons)) | 1328 parsed_command_line().HasSwitch(switches::kShowIcons)) { |
1373 return HandleIconsCommands(parsed_command_line()); | 1329 return HandleIconsCommands(parsed_command_line()); |
| 1330 } |
1374 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { | 1331 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { |
1375 return ShellIntegration::SetAsDefaultBrowser() ? | 1332 return ShellIntegration::SetAsDefaultBrowser() ? |
1376 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : | 1333 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : |
1377 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); | 1334 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); |
1378 } | 1335 } |
1379 | 1336 |
1380 // If the command line specifies --pack-extension, attempt the pack extension | 1337 // If the command line specifies --pack-extension, attempt the pack extension |
1381 // startup action and exit. | 1338 // startup action and exit. |
1382 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1339 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
1383 ExtensionsStartupUtil extension_startup_util; | 1340 ExtensionsStartupUtil extension_startup_util; |
1384 if (extension_startup_util.PackExtension(parsed_command_line())) { | 1341 if (extension_startup_util.PackExtension(parsed_command_line())) |
1385 return content::RESULT_CODE_NORMAL_EXIT; | 1342 return content::RESULT_CODE_NORMAL_EXIT; |
1386 } else { | 1343 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
1387 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | |
1388 } | |
1389 } | 1344 } |
1390 | 1345 |
1391 #if !defined(OS_MACOSX) | 1346 #if !defined(OS_MACOSX) |
1392 // In environments other than Mac OS X we support import of settings | 1347 // In environments other than Mac OS X we support import of settings |
1393 // from other browsers. In case this process is a short-lived "import" | 1348 // from other browsers. In case this process is a short-lived "import" |
1394 // process that another browser runs just to import the settings, we | 1349 // process that another browser runs just to import the settings, we |
1395 // don't want to be checking for another browser process, by design. | 1350 // don't want to be checking for another browser process, by design. |
1396 if (!(parsed_command_line().HasSwitch(switches::kImport) || | 1351 if (!(parsed_command_line().HasSwitch(switches::kImport) || |
1397 parsed_command_line().HasSwitch(switches::kImportFromFile))) { | 1352 parsed_command_line().HasSwitch(switches::kImportFromFile))) { |
1398 #endif | 1353 #endif |
1399 // When another process is running, use that process instead of starting a | 1354 // When another process is running, use that process instead of starting a |
1400 // new one. NotifyOtherProcess will currently give the other process up to | 1355 // new one. NotifyOtherProcess will currently give the other process up to |
1401 // 20 seconds to respond. Note that this needs to be done before we attempt | 1356 // 20 seconds to respond. Note that this needs to be done before we attempt |
1402 // to read the profile. | 1357 // to read the profile. |
1403 switch (process_singleton.NotifyOtherProcessOrCreate()) { | 1358 switch (process_singleton_->NotifyOtherProcessOrCreate()) { |
1404 case ProcessSingleton::PROCESS_NONE: | 1359 case ProcessSingleton::PROCESS_NONE: |
1405 // No process already running, fall through to starting a new one. | 1360 // No process already running, fall through to starting a new one. |
1406 break; | 1361 break; |
1407 | 1362 |
1408 case ProcessSingleton::PROCESS_NOTIFIED: | 1363 case ProcessSingleton::PROCESS_NOTIFIED: |
1409 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 1364 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
1410 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( | 1365 printf("%s\n", base::SysWideToNativeMB(UTF16ToWide( |
1411 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); | 1366 l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str()); |
1412 #endif | 1367 #endif |
1413 return content::RESULT_CODE_NORMAL_EXIT; | 1368 return content::RESULT_CODE_NORMAL_EXIT; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 username); | 1426 username); |
1472 } | 1427 } |
1473 #endif | 1428 #endif |
1474 | 1429 |
1475 if (is_first_run) { | 1430 if (is_first_run) { |
1476 // Warn the ProfileManager that an import process will run, possibly | 1431 // Warn the ProfileManager that an import process will run, possibly |
1477 // locking the WebDataService directory of the next Profile created. | 1432 // locking the WebDataService directory of the next Profile created. |
1478 g_browser_process->profile_manager()->SetWillImport(); | 1433 g_browser_process->profile_manager()->SetWillImport(); |
1479 } | 1434 } |
1480 | 1435 |
1481 Profile* profile = CreateProfile(parameters(), user_data_dir, | 1436 profile_ = CreateProfile(parameters(), user_data_dir, parsed_command_line()); |
1482 parsed_command_line()); | 1437 if (!profile_) |
1483 if (!profile) | |
1484 return content::RESULT_CODE_NORMAL_EXIT; | 1438 return content::RESULT_CODE_NORMAL_EXIT; |
1485 | 1439 |
1486 // Post-profile init --------------------------------------------------------- | 1440 // Post-profile init --------------------------------------------------------- |
1487 | 1441 |
1488 #if defined(OS_CHROMEOS) | 1442 #if defined(OS_CHROMEOS) |
1489 // Pass the TokenService pointer to the policy connector so user policy can | 1443 // Pass the TokenService pointer to the policy connector so user policy can |
1490 // grab a token and register with the policy server. | 1444 // grab a token and register with the policy server. |
1491 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. | 1445 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. |
1492 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 1446 if (parsed_command_line().HasSwitch(switches::kLoginUser) && |
1493 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | 1447 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { |
1494 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( | 1448 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( |
1495 profile->GetTokenService()); | 1449 profile_->GetTokenService()); |
1496 } | 1450 } |
1497 #endif | 1451 #endif |
1498 | 1452 |
1499 PrefService* user_prefs = profile->GetPrefs(); | 1453 PrefService* user_prefs = profile_->GetPrefs(); |
1500 DCHECK(user_prefs); | 1454 DCHECK(user_prefs); |
1501 | 1455 |
1502 // Tests should be able to tune login manager before showing it. | 1456 // Tests should be able to tune login manager before showing it. |
1503 // Thus only show login manager in normal (non-testing) mode. | 1457 // Thus only show login manager in normal (non-testing) mode. |
1504 if (!parameters().ui_task) { | 1458 if (!parameters().ui_task) |
1505 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile); | 1459 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile_); |
1506 } | |
1507 | 1460 |
1508 #if !defined(OS_MACOSX) | 1461 #if !defined(OS_MACOSX) |
1509 // Importing other browser settings is done in a browser-like process | 1462 // Importing other browser settings is done in a browser-like process |
1510 // that exits when this task has finished. | 1463 // that exits when this task has finished. |
1511 // TODO(port): Port the Mac's IPC-based implementation to other platforms to | 1464 // TODO(port): Port the Mac's IPC-based implementation to other platforms to |
1512 // replace this implementation. http://crbug.com/22142 | 1465 // replace this implementation. http://crbug.com/22142 |
1513 if (parsed_command_line().HasSwitch(switches::kImport) || | 1466 if (parsed_command_line().HasSwitch(switches::kImport) || |
1514 parsed_command_line().HasSwitch(switches::kImportFromFile)) { | 1467 parsed_command_line().HasSwitch(switches::kImportFromFile)) { |
1515 return FirstRun::ImportNow(profile, parsed_command_line()); | 1468 return FirstRun::ImportNow(profile_, parsed_command_line()); |
1516 } | 1469 } |
1517 #endif | 1470 #endif |
1518 | 1471 |
1519 #if defined(OS_WIN) | 1472 #if defined(OS_WIN) |
1520 // Do the tasks if chrome has been upgraded while it was last running. | 1473 // Do the tasks if chrome has been upgraded while it was last running. |
1521 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) | 1474 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) |
1522 return content::RESULT_CODE_NORMAL_EXIT; | 1475 return content::RESULT_CODE_NORMAL_EXIT; |
1523 #endif | 1476 #endif |
1524 | 1477 |
1525 // Check if there is any machine level Chrome installed on the current | 1478 // Check if there is any machine level Chrome installed on the current |
1526 // machine. If yes and the current Chrome process is user level, we do not | 1479 // machine. If yes and the current Chrome process is user level, we do not |
1527 // allow the user level Chrome to run. So we notify the user and uninstall | 1480 // allow the user level Chrome to run. So we notify the user and uninstall |
1528 // user level Chrome. | 1481 // user level Chrome. |
1529 // Note this check should only happen here, after all the checks above | 1482 // Note this check should only happen here, after all the checks above |
1530 // (uninstall, resource bundle initialization, other chrome browser | 1483 // (uninstall, resource bundle initialization, other chrome browser |
1531 // processes etc). | 1484 // processes etc). |
1532 // Do not allow this to occur for Chrome Frame user-to-system handoffs. | 1485 // Do not allow this to occur for Chrome Frame user-to-system handoffs. |
1533 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) && | 1486 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) && |
1534 CheckMachineLevelInstall()) | 1487 CheckMachineLevelInstall()) { |
1535 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; | 1488 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; |
| 1489 } |
1536 | 1490 |
1537 // Create the TranslateManager singleton. | 1491 // Create the TranslateManager singleton. |
1538 TranslateManager* translate_manager = TranslateManager::GetInstance(); | 1492 translate_manager_ = TranslateManager::GetInstance(); |
1539 DCHECK(translate_manager != NULL); | 1493 DCHECK(translate_manager_ != NULL); |
1540 | 1494 |
1541 #if defined(OS_MACOSX) | 1495 #if defined(OS_MACOSX) |
1542 if (!parsed_command_line().HasSwitch(switches::kNoFirstRun)) { | 1496 if (!parsed_command_line().HasSwitch(switches::kNoFirstRun)) { |
1543 // Disk image installation is sort of a first-run task, so it shares the | 1497 // Disk image installation is sort of a first-run task, so it shares the |
1544 // kNoFirstRun switch. | 1498 // kNoFirstRun switch. |
1545 if (MaybeInstallFromDiskImage()) { | 1499 if (MaybeInstallFromDiskImage()) { |
1546 // The application was installed and the installed copy has been | 1500 // The application was installed and the installed copy has been |
1547 // launched. This process is now obsolete. Exit. | 1501 // launched. This process is now obsolete. Exit. |
1548 return content::RESULT_CODE_NORMAL_EXIT; | 1502 return content::RESULT_CODE_NORMAL_EXIT; |
1549 } | 1503 } |
1550 } | 1504 } |
1551 #endif | 1505 #endif |
1552 | 1506 |
1553 // Show the First Run UI if this is the first time Chrome has been run on | 1507 // Show the First Run UI if this is the first time Chrome has been run on |
1554 // this computer, or we're being compelled to do so by a command line flag. | 1508 // this computer, or we're being compelled to do so by a command line flag. |
1555 // Note that this be done _after_ the PrefService is initialized and all | 1509 // Note that this be done _after_ the PrefService is initialized and all |
1556 // preferences are registered, since some of the code that the importer | 1510 // preferences are registered, since some of the code that the importer |
1557 // touches reads preferences. | 1511 // touches reads preferences. |
1558 if (is_first_run) { | 1512 if (is_first_run) { |
1559 if (!first_run_ui_bypass) { | 1513 if (!first_run_ui_bypass) { |
1560 FirstRun::AutoImport(profile, | 1514 FirstRun::AutoImport(profile_, |
1561 master_prefs.homepage_defined, | 1515 master_prefs_->homepage_defined, |
1562 master_prefs.do_import_items, | 1516 master_prefs_->do_import_items, |
1563 master_prefs.dont_import_items, | 1517 master_prefs_->dont_import_items, |
1564 master_prefs.run_search_engine_experiment, | 1518 master_prefs_->run_search_engine_experiment, |
1565 master_prefs.randomize_search_engine_experiment, | 1519 master_prefs_->randomize_search_engine_experiment, |
1566 master_prefs.make_chrome_default, | 1520 master_prefs_->make_chrome_default, |
1567 &process_singleton); | 1521 process_singleton_.get()); |
1568 #if defined(OS_POSIX) | 1522 #if defined(OS_POSIX) |
1569 // On Windows, the download is tagged with enable/disable stats so there | 1523 // On Windows, the download is tagged with enable/disable stats so there |
1570 // is no need for this code. | 1524 // is no need for this code. |
1571 | 1525 |
1572 // If stats reporting was turned on by the first run dialog then toggle | 1526 // If stats reporting was turned on by the first run dialog then toggle |
1573 // the pref. | 1527 // the pref. |
1574 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 1528 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
1575 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); | 1529 local_state->SetBoolean(prefs::kMetricsReportingEnabled, true); |
1576 #endif // OS_POSIX | 1530 #endif // OS_POSIX |
1577 } // if (!first_run_ui_bypass) | 1531 } // if (!first_run_ui_bypass) |
1578 | 1532 |
1579 Browser::SetNewHomePagePrefs(user_prefs); | 1533 Browser::SetNewHomePagePrefs(user_prefs); |
1580 g_browser_process->profile_manager()->OnImportFinished(profile); | 1534 g_browser_process->profile_manager()->OnImportFinished(profile_); |
1581 } // if (is_first_run) | 1535 } // if (is_first_run) |
1582 | 1536 |
1583 // Sets things up so that if we crash from this point on, a dialog will | 1537 // Sets things up so that if we crash from this point on, a dialog will |
1584 // popup asking the user to restart chrome. It is done this late to avoid | 1538 // popup asking the user to restart chrome. It is done this late to avoid |
1585 // testing against a bunch of special cases that are taken care early on. | 1539 // testing against a bunch of special cases that are taken care early on. |
1586 PrepareRestartOnCrashEnviroment(parsed_command_line()); | 1540 PrepareRestartOnCrashEnviroment(parsed_command_line()); |
1587 | 1541 |
1588 #if defined(OS_WIN) | 1542 #if defined(OS_WIN) |
1589 // Registers Chrome with the Windows Restart Manager, which will restore the | 1543 // Registers Chrome with the Windows Restart Manager, which will restore the |
1590 // Chrome session when the computer is restarted after a system update. | 1544 // Chrome session when the computer is restarted after a system update. |
(...skipping 11 matching lines...) Expand all Loading... |
1602 bool preconnect_enabled = true; // Default status (easy to change!). | 1556 bool preconnect_enabled = true; // Default status (easy to change!). |
1603 if (parsed_command_line().HasSwitch(switches::kDisablePreconnect)) | 1557 if (parsed_command_line().HasSwitch(switches::kDisablePreconnect)) |
1604 preconnect_enabled = false; | 1558 preconnect_enabled = false; |
1605 else if (parsed_command_line().HasSwitch(switches::kEnablePreconnect)) | 1559 else if (parsed_command_line().HasSwitch(switches::kEnablePreconnect)) |
1606 preconnect_enabled = true; | 1560 preconnect_enabled = true; |
1607 chrome_browser_net::PredictorInit dns_prefetch( | 1561 chrome_browser_net::PredictorInit dns_prefetch( |
1608 user_prefs, | 1562 user_prefs, |
1609 local_state, | 1563 local_state, |
1610 preconnect_enabled); | 1564 preconnect_enabled); |
1611 | 1565 |
1612 #if defined(OS_WIN) | 1566 #if defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
1613 base::win::ScopedCOMInitializer com_initializer; | |
1614 | |
1615 #if defined(GOOGLE_CHROME_BUILD) | |
1616 // Init the RLZ library. This just binds the dll and schedules a task on the | 1567 // Init the RLZ library. This just binds the dll and schedules a task on the |
1617 // file thread to be run sometime later. If this is the first run we record | 1568 // file thread to be run sometime later. If this is the first run we record |
1618 // the installation event. | 1569 // the installation event. |
1619 bool google_search_default = false; | 1570 bool google_search_default = false; |
1620 TemplateURLService* template_url_service = | 1571 TemplateURLService* template_url_service = |
1621 TemplateURLServiceFactory::GetForProfile(profile); | 1572 TemplateURLServiceFactory::GetForProfile(profile_); |
1622 if (template_url_service) { | 1573 if (template_url_service) { |
1623 const TemplateURL* url_template = | 1574 const TemplateURL* url_template = |
1624 template_url_service->GetDefaultSearchProvider(); | 1575 template_url_service->GetDefaultSearchProvider(); |
1625 if (url_template) { | 1576 if (url_template) { |
1626 const TemplateURLRef* urlref = url_template->url(); | 1577 const TemplateURLRef* urlref = url_template->url(); |
1627 if (urlref) { | 1578 if (urlref) { |
1628 google_search_default = urlref->HasGoogleBaseURLs(); | 1579 google_search_default = urlref->HasGoogleBaseURLs(); |
1629 } | 1580 } |
1630 } | 1581 } |
1631 } | 1582 } |
1632 | 1583 |
1633 bool google_search_homepage = false; | 1584 bool google_search_homepage = false; |
1634 PrefService* pref_service = profile->GetPrefs(); | 1585 PrefService* pref_service = profile_->GetPrefs(); |
1635 if (pref_service) { | 1586 if (pref_service) { |
1636 std::string homepage = pref_service->GetString(prefs::kHomePage); | 1587 std::string homepage = pref_service->GetString(prefs::kHomePage); |
1637 google_search_homepage = | 1588 google_search_homepage = |
1638 homepage == GoogleURLTracker::kDefaultGoogleHomepage; | 1589 homepage == GoogleURLTracker::kDefaultGoogleHomepage; |
1639 } | 1590 } |
1640 | 1591 |
1641 RLZTracker::InitRlzDelayed(is_first_run, master_prefs.ping_delay, | 1592 RLZTracker::InitRlzDelayed(is_first_run, master_prefs_->ping_delay, |
1642 google_search_default, google_search_homepage); | 1593 google_search_default, google_search_homepage); |
1643 | 1594 |
1644 // Prime the RLZ cache for the home page access point so that its avaiable | 1595 // Prime the RLZ cache for the home page access point so that its avaiable |
1645 // for the startup page if needed (i.e., when the startup page is set to | 1596 // for the startup page if needed (i.e., when the startup page is set to |
1646 // the home page). | 1597 // the home page). |
1647 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); | 1598 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); |
1648 | 1599 #endif // GOOGLE_CHROME_BUILD && OS_WIN |
1649 #endif // GOOGLE_CHROME_BUILD | |
1650 #endif // OS_WIN | |
1651 | 1600 |
1652 // Configure modules that need access to resources. | 1601 // Configure modules that need access to resources. |
1653 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); | 1602 net::NetModule::SetResourceProvider(chrome_common_net::NetResourceProvider); |
1654 | 1603 |
1655 // In unittest mode, this will do nothing. In normal mode, this will create | 1604 // In unittest mode, this will do nothing. In normal mode, this will create |
1656 // the global GoogleURLTracker and IntranetRedirectDetector instances, which | 1605 // the global GoogleURLTracker and IntranetRedirectDetector instances, which |
1657 // will promptly go to sleep for five and seven seconds, respectively (to | 1606 // will promptly go to sleep for five and seven seconds, respectively (to |
1658 // avoid slowing startup), and wake up afterwards to see if they should do | 1607 // avoid slowing startup), and wake up afterwards to see if they should do |
1659 // anything else. | 1608 // anything else. |
1660 // | 1609 // |
1661 // A simpler way of doing all this would be to have some function which could | 1610 // A simpler way of doing all this would be to have some function which could |
1662 // give the time elapsed since startup, and simply have these objects check | 1611 // give the time elapsed since startup, and simply have these objects check |
1663 // that when asked to initialize themselves, but this doesn't seem to exist. | 1612 // that when asked to initialize themselves, but this doesn't seem to exist. |
1664 // | 1613 // |
1665 // These can't be created in the BrowserProcessImpl constructor because they | 1614 // These can't be created in the BrowserProcessImpl constructor because they |
1666 // need to read prefs that get set after that runs. | 1615 // need to read prefs that get set after that runs. |
1667 browser_process->google_url_tracker(); | 1616 browser_process_->google_url_tracker(); |
1668 browser_process->intranet_redirect_detector(); | 1617 browser_process_->intranet_redirect_detector(); |
1669 | 1618 |
1670 // Prepare for memory caching of SDCH dictionaries. | 1619 // Prepare for memory caching of SDCH dictionaries. |
1671 // Perform A/B test to measure global impact of SDCH support. | 1620 // Perform A/B test to measure global impact of SDCH support. |
1672 // Set up a field trial to see what disabling SDCH does to latency of page | 1621 // Set up a field trial to see what disabling SDCH does to latency of page |
1673 // layout globally. | 1622 // layout globally. |
1674 base::FieldTrial::Probability kSDCH_DIVISOR = 1000; | 1623 base::FieldTrial::Probability kSDCH_DIVISOR = 1000; |
1675 base::FieldTrial::Probability kSDCH_DISABLE_PROBABILITY = 1; // 0.1% prob. | 1624 base::FieldTrial::Probability kSDCH_DISABLE_PROBABILITY = 1; // 0.1% prob. |
1676 // After June 30, 2011 builds, it will always be in default group. | 1625 // After June 30, 2011 builds, it will always be in default group. |
1677 scoped_refptr<base::FieldTrial> sdch_trial( | 1626 scoped_refptr<base::FieldTrial> sdch_trial( |
1678 new base::FieldTrial("GlobalSdch", kSDCH_DIVISOR, "global_enable_sdch", | 1627 new base::FieldTrial("GlobalSdch", kSDCH_DIVISOR, "global_enable_sdch", |
(...skipping 28 matching lines...) Expand all Loading... |
1707 | 1656 |
1708 #if defined(TOUCH_UI) | 1657 #if defined(TOUCH_UI) |
1709 views::TouchFactory::GetInstance()->set_keep_mouse_cursor( | 1658 views::TouchFactory::GetInstance()->set_keep_mouse_cursor( |
1710 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepMouseCursor)); | 1659 CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepMouseCursor)); |
1711 #endif | 1660 #endif |
1712 | 1661 |
1713 HandleTestParameters(parsed_command_line()); | 1662 HandleTestParameters(parsed_command_line()); |
1714 RecordBreakpadStatusUMA(metrics); | 1663 RecordBreakpadStatusUMA(metrics); |
1715 about_flags::RecordUMAStatistics(local_state); | 1664 about_flags::RecordUMAStatistics(local_state); |
1716 LanguageUsageMetrics::RecordAcceptLanguages( | 1665 LanguageUsageMetrics::RecordAcceptLanguages( |
1717 profile->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 1666 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
1718 LanguageUsageMetrics::RecordApplicationLanguage( | 1667 LanguageUsageMetrics::RecordApplicationLanguage( |
1719 g_browser_process->GetApplicationLocale()); | 1668 g_browser_process->GetApplicationLocale()); |
1720 | 1669 |
1721 #if defined(OS_CHROMEOS) | 1670 #if defined(OS_CHROMEOS) |
1722 metrics->StartExternalMetrics(); | 1671 metrics->StartExternalMetrics(); |
1723 | 1672 |
1724 // Initialize the brightness observer so that we'll display an onscreen | 1673 // Initialize the brightness observer so that we'll display an onscreen |
1725 // indication of brightness changes during login. | 1674 // indication of brightness changes during login. |
1726 static chromeos::BrightnessObserver* brightness_observer = | 1675 static chromeos::BrightnessObserver* brightness_observer = |
1727 new chromeos::BrightnessObserver(); | 1676 new chromeos::BrightnessObserver(); |
1728 chromeos::CrosLibrary::Get()->GetBrightnessLibrary()->AddObserver( | 1677 chromeos::CrosLibrary::Get()->GetBrightnessLibrary()->AddObserver( |
1729 brightness_observer); | 1678 brightness_observer); |
1730 | 1679 |
1731 // Listen for system key events so that the user will be able to adjust the | 1680 // Listen for system key events so that the user will be able to adjust the |
1732 // volume on the login screen. | 1681 // volume on the login screen. |
1733 chromeos::SystemKeyEventListener::GetInstance(); | 1682 chromeos::SystemKeyEventListener::GetInstance(); |
1734 | 1683 |
1735 // Listen for XI_HierarchyChanged events. | 1684 // Listen for XI_HierarchyChanged events. |
1736 chromeos::XInputHierarchyChangedEventListener::GetInstance(); | 1685 chromeos::XInputHierarchyChangedEventListener::GetInstance(); |
1737 #endif | 1686 #endif |
1738 | 1687 |
1739 // The extension service may be available at this point. If the command line | 1688 // The extension service may be available at this point. If the command line |
1740 // specifies --uninstall-extension, attempt the uninstall extension startup | 1689 // specifies --uninstall-extension, attempt the uninstall extension startup |
1741 // action. | 1690 // action. |
1742 if (parsed_command_line().HasSwitch(switches::kUninstallExtension)) { | 1691 if (parsed_command_line().HasSwitch(switches::kUninstallExtension)) { |
1743 ExtensionsStartupUtil ext_startup_util; | 1692 ExtensionsStartupUtil ext_startup_util; |
1744 if (ext_startup_util.UninstallExtension(parsed_command_line(), profile)) { | 1693 if (ext_startup_util.UninstallExtension(parsed_command_line(), profile_)) |
1745 return content::RESULT_CODE_NORMAL_EXIT; | 1694 return content::RESULT_CODE_NORMAL_EXIT; |
1746 } else { | 1695 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; |
1747 return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR; | |
1748 } | |
1749 } | 1696 } |
1750 | 1697 |
1751 #if defined(OS_WIN) | 1698 #if defined(OS_WIN) |
1752 // We check this here because if the profile is OTR (chromeos possibility) | 1699 // We check this here because if the profile is OTR (chromeos possibility) |
1753 // it won't still be accessible after browser is destroyed. | 1700 // it won't still be accessible after browser is destroyed. |
1754 bool record_search_engine = is_first_run && !profile->IsOffTheRecord(); | 1701 record_search_engine_ = is_first_run && !profile_->IsOffTheRecord(); |
1755 #endif | 1702 #endif |
1756 | 1703 |
1757 // ChildProcess:: is a misnomer unless you consider context. Use | 1704 // ChildProcess:: is a misnomer unless you consider context. Use |
1758 // of --wait-for-debugger only makes sense when Chrome itself is a | 1705 // of --wait-for-debugger only makes sense when Chrome itself is a |
1759 // child process (e.g. when launched by PyAuto). | 1706 // child process (e.g. when launched by PyAuto). |
1760 if (parsed_command_line().HasSwitch(switches::kWaitForDebugger)) { | 1707 if (parsed_command_line().HasSwitch(switches::kWaitForDebugger)) { |
1761 ChildProcess::WaitForDebugger("Browser"); | 1708 ChildProcess::WaitForDebugger("Browser"); |
1762 } | 1709 } |
1763 | 1710 |
1764 #if defined(OS_CHROMEOS) | 1711 #if defined(OS_CHROMEOS) |
1765 // Run the Out of Memory priority manager while in this scope. Wait | 1712 // Run the Out of Memory priority manager while in this scope. Wait |
1766 // until here to start so that we give the most amount of time for | 1713 // until here to start so that we give the most amount of time for |
1767 // the other services to start up before we start adjusting the oom | 1714 // the other services to start up before we start adjusting the oom |
1768 // priority. In reality, it doesn't matter much where in this scope | 1715 // priority. In reality, it doesn't matter much where in this scope |
1769 // this is started, but it must be started in this scope so it will | 1716 // this is started, but it must be started in this scope so it will |
1770 // also be terminated when this scope exits. | 1717 // also be terminated when this scope exits. |
1771 scoped_ptr<browser::OomPriorityManager> oom_priority_manager( | 1718 scoped_ptr<browser::OomPriorityManager> oom_priority_manager( |
1772 new browser::OomPriorityManager); | 1719 new browser::OomPriorityManager); |
1773 #endif | 1720 #endif |
1774 | 1721 |
1775 // Create the instance of the cloud print proxy service so that it can launch | 1722 // Create the instance of the cloud print proxy service so that it can launch |
1776 // the service process if needed. This is needed because the service process | 1723 // the service process if needed. This is needed because the service process |
1777 // might have shutdown because an update was available. | 1724 // might have shutdown because an update was available. |
1778 // TODO(torne): this should maybe be done with | 1725 // TODO(torne): this should maybe be done with |
1779 // ProfileKeyedServiceFactory::ServiceIsCreatedWithProfile() instead? | 1726 // ProfileKeyedServiceFactory::ServiceIsCreatedWithProfile() instead? |
1780 CloudPrintProxyServiceFactory::GetForProfile(profile); | 1727 CloudPrintProxyServiceFactory::GetForProfile(profile_); |
1781 | 1728 |
1782 // Initialize GpuDataManager and collect preliminary gpu info on FILE thread. | 1729 // Initialize GpuDataManager and collect preliminary gpu info on FILE thread. |
1783 // Upon completion, it posts GpuBlacklist auto update task on UI thread. | 1730 // Upon completion, it posts GpuBlacklist auto update task on UI thread. |
1784 BrowserThread::PostTask( | 1731 BrowserThread::PostTask( |
1785 BrowserThread::FILE, FROM_HERE, | 1732 BrowserThread::FILE, FROM_HERE, |
1786 NewRunnableFunction(&GpuBlacklistUpdater::SetupOnFileThread)); | 1733 NewRunnableFunction(&GpuBlacklistUpdater::SetupOnFileThread)); |
1787 | 1734 |
1788 // Start watching all browser threads for responsiveness. | 1735 // Start watching all browser threads for responsiveness. |
1789 ThreadWatcherList::StartWatchingAll(parsed_command_line()); | 1736 ThreadWatcherList::StartWatchingAll(parsed_command_line()); |
1790 | 1737 |
1791 int result_code = content::RESULT_CODE_NORMAL_EXIT; | 1738 int result_code = content::RESULT_CODE_NORMAL_EXIT; |
1792 base::mac::ScopedNSAutoreleasePool* pool = parameters().autorelease_pool_; | 1739 base::mac::ScopedNSAutoreleasePool* pool = parameters().autorelease_pool_; |
1793 if (parameters().ui_task) { | 1740 if (parameters().ui_task) { |
1794 // We are in test mode. Run one task and enter the main message loop. | 1741 // We are in test mode. Run one task and enter the main message loop. |
1795 if (pool) | 1742 if (pool) |
1796 pool->Recycle(); | 1743 pool->Recycle(); |
1797 parameters().ui_task->Run(); | 1744 parameters().ui_task->Run(); |
1798 delete parameters().ui_task; | 1745 delete parameters().ui_task; |
1799 } else { | 1746 } else { |
1800 // Most general initialization is behind us, but opening a | 1747 // Most general initialization is behind us, but opening a |
1801 // tab and/or session restore and such is still to be done. | 1748 // tab and/or session restore and such is still to be done. |
1802 base::TimeTicks browser_open_start = base::TimeTicks::Now(); | 1749 base::TimeTicks browser_open_start = base::TimeTicks::Now(); |
1803 | 1750 |
1804 // We are in regular browser boot sequence. Open initial tabs and enter the | 1751 // We are in regular browser boot sequence. Open initial tabs and enter the |
1805 // main message loop. | 1752 // main message loop. |
1806 if (browser_init.Start(parsed_command_line(), FilePath(), profile, | 1753 if (browser_init.Start(parsed_command_line(), FilePath(), profile_, |
1807 &result_code)) { | 1754 &result_code)) { |
1808 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1755 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
1809 // Initialize autoupdate timer. Timer callback costs basically nothing | 1756 // Initialize autoupdate timer. Timer callback costs basically nothing |
1810 // when browser is not in persistent mode, so it's OK to let it ride on | 1757 // when browser is not in persistent mode, so it's OK to let it ride on |
1811 // the main thread. This needs to be done here because we don't want | 1758 // the main thread. This needs to be done here because we don't want |
1812 // to start the timer when Chrome is run inside a test harness. | 1759 // to start the timer when Chrome is run inside a test harness. |
1813 g_browser_process->StartAutoupdateTimer(); | 1760 g_browser_process->StartAutoupdateTimer(); |
1814 #endif | 1761 #endif |
1815 | 1762 |
1816 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1763 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
(...skipping 12 matching lines...) Expand all Loading... |
1829 pool->Recycle(); | 1776 pool->Recycle(); |
1830 | 1777 |
1831 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", | 1778 RecordPreReadExperimentTime("Startup.BrowserOpenTabs", |
1832 base::TimeTicks::Now() - browser_open_start); | 1779 base::TimeTicks::Now() - browser_open_start); |
1833 | 1780 |
1834 // TODO(mad): Move this call in a proper place on CrOS. | 1781 // TODO(mad): Move this call in a proper place on CrOS. |
1835 // http://crosbug.com/17687 | 1782 // http://crosbug.com/17687 |
1836 #if !defined(OS_CHROMEOS) | 1783 #if !defined(OS_CHROMEOS) |
1837 // If we're running tests (ui_task is non-null), then we don't want to | 1784 // If we're running tests (ui_task is non-null), then we don't want to |
1838 // call FetchLanguageListFromTranslateServer | 1785 // call FetchLanguageListFromTranslateServer |
1839 if (parameters().ui_task == NULL && translate_manager != NULL) { | 1786 if (parameters().ui_task == NULL && translate_manager_ != NULL) { |
1840 // TODO(willchan): Get rid of this after TranslateManager doesn't use | 1787 // TODO(willchan): Get rid of this after TranslateManager doesn't use |
1841 // the default request context. http://crbug.com/89396. | 1788 // the default request context. http://crbug.com/89396. |
1842 // This is necessary to force |default_request_context_| to be | 1789 // This is necessary to force |default_request_context_| to be |
1843 // initialized. | 1790 // initialized. |
1844 profile->GetRequestContext(); | 1791 profile_->GetRequestContext(); |
1845 translate_manager->FetchLanguageListFromTranslateServer(user_prefs); | 1792 translate_manager_->FetchLanguageListFromTranslateServer(user_prefs); |
1846 } | 1793 } |
1847 #endif | 1794 #endif |
1848 | 1795 |
1849 RunUIMessageLoop(browser_process.get()); | 1796 run_message_loop_ = true; |
1850 } | 1797 } |
1851 } | 1798 } |
1852 | 1799 |
| 1800 return result_code; |
| 1801 } |
| 1802 |
| 1803 void ChromeBrowserMainParts::MainMessageLoopRun() { |
| 1804 if (!run_message_loop_) |
| 1805 return; |
| 1806 |
| 1807 // This should be invoked as close to the start of the browser's |
| 1808 // UI thread message loop as possible to get a stable measurement |
| 1809 // across versions. |
| 1810 RecordBrowserStartupTime(); |
| 1811 |
| 1812 #if defined(TOOLKIT_VIEWS) |
| 1813 views::AcceleratorHandler accelerator_handler; |
| 1814 MessageLoopForUI::current()->Run(&accelerator_handler); |
| 1815 #elif defined(USE_X11) |
| 1816 MessageLoopForUI::current()->Run(NULL); |
| 1817 #elif defined(OS_POSIX) |
| 1818 MessageLoopForUI::current()->Run(); |
| 1819 #endif |
| 1820 #if defined(OS_CHROMEOS) |
| 1821 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", |
| 1822 true); |
| 1823 #endif |
| 1824 } |
| 1825 |
| 1826 void ChromeBrowserMainParts::PostMainMessageLoopRun() { |
1853 // Start watching for jank during shutdown. It gets disarmed when | 1827 // Start watching for jank during shutdown. It gets disarmed when |
1854 // |shutdown_watcher_| object is destructed. | 1828 // |shutdown_watcher_| object is destructed. |
1855 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(45)); | 1829 shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(45)); |
1856 | 1830 |
1857 #if defined(OS_WIN) | 1831 #if defined(OS_WIN) |
1858 // If it's the first run, log the search engine chosen. We wait until | 1832 // If it's the first run, log the search engine chosen. We wait until |
1859 // shutdown because otherwise we can't be sure the user has finished | 1833 // shutdown because otherwise we can't be sure the user has finished |
1860 // selecting a search engine through the dialog reached from the first run | 1834 // selecting a search engine through the dialog reached from the first run |
1861 // bubble link. | 1835 // bubble link. |
1862 if (record_search_engine) { | 1836 if (record_search_engine_) { |
1863 TemplateURLService* url_service = | 1837 TemplateURLService* url_service = |
1864 TemplateURLServiceFactory::GetForProfile(profile); | 1838 TemplateURLServiceFactory::GetForProfile(profile_); |
1865 const TemplateURL* default_search_engine = | 1839 const TemplateURL* default_search_engine = |
1866 url_service->GetDefaultSearchProvider(); | 1840 url_service->GetDefaultSearchProvider(); |
1867 // The default engine can be NULL if the administrator has disabled | 1841 // The default engine can be NULL if the administrator has disabled |
1868 // default search. | 1842 // default search. |
1869 SearchEngineType search_engine_type = | 1843 SearchEngineType search_engine_type = |
1870 default_search_engine ? default_search_engine->search_engine_type() : | 1844 default_search_engine ? default_search_engine->search_engine_type() : |
1871 SEARCH_ENGINE_OTHER; | 1845 SEARCH_ENGINE_OTHER; |
1872 // Record the search engine chosen. | 1846 // Record the search engine chosen. |
1873 if (master_prefs.run_search_engine_experiment) { | 1847 if (master_prefs_->run_search_engine_experiment) { |
1874 UMA_HISTOGRAM_ENUMERATION( | 1848 UMA_HISTOGRAM_ENUMERATION( |
1875 "Chrome.SearchSelectExperiment", | 1849 "Chrome.SearchSelectExperiment", |
1876 search_engine_type, | 1850 search_engine_type, |
1877 SEARCH_ENGINE_MAX); | 1851 SEARCH_ENGINE_MAX); |
1878 // If the selection has been randomized, also record the winner by slot. | 1852 // If the selection has been randomized, also record the winner by slot. |
1879 if (master_prefs.randomize_search_engine_experiment) { | 1853 if (master_prefs_->randomize_search_engine_experiment) { |
1880 size_t engine_pos = url_service->GetSearchEngineDialogSlot(); | 1854 size_t engine_pos = url_service->GetSearchEngineDialogSlot(); |
1881 if (engine_pos < 4) { | 1855 if (engine_pos < 4) { |
1882 std::string experiment_type = "Chrome.SearchSelectExperimentSlot"; | 1856 std::string experiment_type = "Chrome.SearchSelectExperimentSlot"; |
1883 // Nicer in UMA if slots are 1-based. | 1857 // Nicer in UMA if slots are 1-based. |
1884 experiment_type.push_back('1' + engine_pos); | 1858 experiment_type.push_back('1' + engine_pos); |
1885 UMA_HISTOGRAM_ENUMERATION( | 1859 UMA_HISTOGRAM_ENUMERATION( |
1886 experiment_type, | 1860 experiment_type, |
1887 search_engine_type, | 1861 search_engine_type, |
1888 SEARCH_ENGINE_MAX); | 1862 SEARCH_ENGINE_MAX); |
1889 } else { | 1863 } else { |
1890 NOTREACHED() << "Invalid search engine selection slot."; | 1864 NOTREACHED() << "Invalid search engine selection slot."; |
1891 } | 1865 } |
1892 } | 1866 } |
1893 } else { | 1867 } else { |
1894 UMA_HISTOGRAM_ENUMERATION( | 1868 UMA_HISTOGRAM_ENUMERATION( |
1895 "Chrome.SearchSelectExempt", | 1869 "Chrome.SearchSelectExempt", |
1896 search_engine_type, | 1870 search_engine_type, |
1897 SEARCH_ENGINE_MAX); | 1871 SEARCH_ENGINE_MAX); |
1898 } | 1872 } |
1899 } | 1873 } |
1900 #endif | 1874 #endif |
1901 | 1875 |
1902 // Some tests don't set parameters.ui_task, so they started translate | 1876 // Some tests don't set parameters.ui_task, so they started translate |
1903 // language fetch that was never completed so we need to cleanup here | 1877 // language fetch that was never completed so we need to cleanup here |
1904 // otherwise it will be done by the destructor in a wrong thread. | 1878 // otherwise it will be done by the destructor in a wrong thread. |
1905 if (parameters().ui_task == NULL && translate_manager != NULL) | 1879 if (parameters().ui_task == NULL && translate_manager_ != NULL) |
1906 translate_manager->CleanupPendingUlrFetcher(); | 1880 translate_manager_->CleanupPendingUlrFetcher(); |
1907 | 1881 |
1908 | 1882 process_singleton_->Cleanup(); |
1909 process_singleton.Cleanup(); | |
1910 | 1883 |
1911 // Stop all tasks that might run on WatchDogThread. | 1884 // Stop all tasks that might run on WatchDogThread. |
1912 ThreadWatcherList::StopWatchingAll(); | 1885 ThreadWatcherList::StopWatchingAll(); |
1913 | 1886 |
1914 metrics->Stop(); | 1887 g_browser_process->metrics_service()->Stop(); |
1915 | 1888 |
1916 // browser_shutdown takes care of deleting browser_process, so we need to | 1889 // browser_shutdown takes care of deleting browser_process, so we need to |
1917 // release it. | 1890 // release it. |
1918 ignore_result(browser_process.release()); | 1891 ignore_result(browser_process_.release()); |
1919 browser_shutdown::Shutdown(); | 1892 browser_shutdown::Shutdown(); |
| 1893 master_prefs_.reset(); |
| 1894 process_singleton_.reset(); |
| 1895 } |
1920 | 1896 |
1921 return result_code; | 1897 void ChromeBrowserMainParts::ToolkitInitialized() { |
| 1898 #if defined(TOOLKIT_VIEWS) |
| 1899 // The delegate needs to be set before any UI is created so that windows |
| 1900 // display the correct icon. |
| 1901 if (!views::ViewsDelegate::views_delegate) |
| 1902 views::ViewsDelegate::views_delegate = new ChromeViewsDelegate; |
| 1903 |
| 1904 // TODO(beng): Move to WidgetImpl and implement on Windows too! |
| 1905 if (parameters().command_line_.HasSwitch(switches::kDebugViewsPaint)) |
| 1906 views::Widget::SetDebugPaintEnabled(true); |
| 1907 #endif |
| 1908 |
| 1909 #if defined(OS_WIN) |
| 1910 gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont; |
| 1911 gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize; |
| 1912 #endif |
1922 } | 1913 } |
1923 | 1914 |
1924 // This code is specific to the Windows-only PreReadExperiment field-trial. | 1915 // This code is specific to the Windows-only PreReadExperiment field-trial. |
1925 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { | 1916 void RecordPreReadExperimentTime(const char* name, base::TimeDelta time) { |
1926 DCHECK(name != NULL); | 1917 DCHECK(name != NULL); |
1927 | 1918 |
1928 // This gets called with different histogram names, so we don't want to use | 1919 // This gets called with different histogram names, so we don't want to use |
1929 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the | 1920 // the UMA_HISTOGRAM_CUSTOM_TIMES macro--it uses a static variable, and the |
1930 // first call wins. | 1921 // first call wins. |
1931 AddPreReadHistogramTime(name, time); | 1922 AddPreReadHistogramTime(name, time); |
1932 | 1923 |
1933 #if defined(OS_WIN) | 1924 #if defined(OS_WIN) |
1934 #if defined(GOOGLE_CHROME_BUILD) | 1925 #if defined(GOOGLE_CHROME_BUILD) |
1935 // The pre-read experiment is Windows and Google Chrome specific. | 1926 // The pre-read experiment is Windows and Google Chrome specific. |
1936 scoped_ptr<base::Environment> env(base::Environment::Create()); | 1927 scoped_ptr<base::Environment> env(base::Environment::Create()); |
1937 | 1928 |
1938 // Only record the sub-histogram result if the experiment is running | 1929 // Only record the sub-histogram result if the experiment is running |
1939 // (environment variable is set, and valid). | 1930 // (environment variable is set, and valid). |
1940 std::string pre_read; | 1931 std::string pre_read; |
1941 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && | 1932 if (env->GetVar(chrome::kPreReadEnvironmentVariable, &pre_read) && |
1942 (pre_read == "0" || pre_read == "1")) { | 1933 (pre_read == "0" || pre_read == "1")) { |
1943 std::string uma_name(name); | 1934 std::string uma_name(name); |
1944 uma_name += "_PreRead"; | 1935 uma_name += "_PreRead"; |
1945 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; | 1936 uma_name += pre_read == "1" ? "Enabled" : "Disabled"; |
1946 AddPreReadHistogramTime(uma_name.c_str(), time); | 1937 AddPreReadHistogramTime(uma_name.c_str(), time); |
1947 } | 1938 } |
1948 #endif | 1939 #endif |
1949 #endif | 1940 #endif |
1950 } | 1941 } |
OLD | NEW |