OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 #if !defined(OS_ANDROID) | 747 #if !defined(OS_ANDROID) |
748 process_singleton_.reset(new ChromeProcessSingleton( | 748 process_singleton_.reset(new ChromeProcessSingleton( |
749 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 749 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); |
750 | 750 |
751 bool force_first_run = | 751 bool force_first_run = |
752 parsed_command_line().HasSwitch(switches::kForceFirstRun); | 752 parsed_command_line().HasSwitch(switches::kForceFirstRun); |
753 bool force_skip_first_run_tasks = | 753 bool force_skip_first_run_tasks = |
754 (!force_first_run && | 754 (!force_first_run && |
755 parsed_command_line().HasSwitch(switches::kNoFirstRun)); | 755 parsed_command_line().HasSwitch(switches::kNoFirstRun)); |
756 | 756 |
757 is_first_run = | 757 is_first_run = force_first_run || first_run::IsChromeFirstRun(); |
758 (force_first_run || first_run::IsChromeFirstRun()) && | |
759 !ProfileManager::IsImportProcess(parsed_command_line()); | |
760 #endif | 758 #endif |
761 | 759 |
762 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = | 760 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
763 JsonPrefStore::GetTaskRunnerForFile( | 761 JsonPrefStore::GetTaskRunnerForFile( |
764 base::FilePath(chrome::kLocalStorePoolName), | 762 base::FilePath(chrome::kLocalStorePoolName), |
765 BrowserThread::GetBlockingPool()); | 763 BrowserThread::GetBlockingPool()); |
766 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner, | 764 browser_process_.reset(new BrowserProcessImpl(local_state_task_runner, |
767 parsed_command_line())); | 765 parsed_command_line())); |
768 | 766 |
769 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { | 767 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 #if !defined(OS_ANDROID) | 1091 #if !defined(OS_ANDROID) |
1094 // If the command line specifies --pack-extension, attempt the pack extension | 1092 // If the command line specifies --pack-extension, attempt the pack extension |
1095 // startup action and exit. | 1093 // startup action and exit. |
1096 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1094 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
1097 extensions::StartupHelper extension_startup_helper; | 1095 extensions::StartupHelper extension_startup_helper; |
1098 if (extension_startup_helper.PackExtension(parsed_command_line())) | 1096 if (extension_startup_helper.PackExtension(parsed_command_line())) |
1099 return content::RESULT_CODE_NORMAL_EXIT; | 1097 return content::RESULT_CODE_NORMAL_EXIT; |
1100 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1098 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
1101 } | 1099 } |
1102 | 1100 |
1103 bool pass_command_line = true; | |
1104 | |
1105 #if !defined(OS_MACOSX) | |
1106 // In environments other than Mac OS X we support import of settings | |
1107 // from other browsers. In case this process is a short-lived "import" | |
1108 // process that another browser runs just to import the settings, we | |
1109 // don't want to be checking for another browser process, by design. | |
1110 pass_command_line = !ProfileManager::IsImportProcess(parsed_command_line()); | |
1111 #endif | |
1112 | |
1113 // If we're being launched just to check the connector policy, we are | 1101 // If we're being launched just to check the connector policy, we are |
1114 // short-lived and don't want to be passing that switch off. | 1102 // short-lived and don't want to be passing that switch off. |
1115 pass_command_line = pass_command_line && !parsed_command_line().HasSwitch( | 1103 bool pass_command_line = !parsed_command_line().HasSwitch( |
1116 switches::kCheckCloudPrintConnectorPolicy); | 1104 switches::kCheckCloudPrintConnectorPolicy); |
1117 | 1105 |
1118 if (pass_command_line) { | 1106 if (pass_command_line) { |
1119 // When another process is running, use that process instead of starting a | 1107 // When another process is running, use that process instead of starting a |
1120 // new one. NotifyOtherProcess will currently give the other process up to | 1108 // new one. NotifyOtherProcess will currently give the other process up to |
1121 // 20 seconds to respond. Note that this needs to be done before we attempt | 1109 // 20 seconds to respond. Note that this needs to be done before we attempt |
1122 // to read the profile. | 1110 // to read the profile. |
1123 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1111 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
1124 UMA_HISTOGRAM_ENUMERATION("NotifyOtherProcessOrCreate.Result", | 1112 UMA_HISTOGRAM_ENUMERATION("NotifyOtherProcessOrCreate.Result", |
1125 notify_result_, | 1113 notify_result_, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 if (!profile_) | 1197 if (!profile_) |
1210 return content::RESULT_CODE_NORMAL_EXIT; | 1198 return content::RESULT_CODE_NORMAL_EXIT; |
1211 | 1199 |
1212 #if defined(ENABLE_BACKGROUND) | 1200 #if defined(ENABLE_BACKGROUND) |
1213 // Autoload any profiles which are running background apps. | 1201 // Autoload any profiles which are running background apps. |
1214 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1202 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
1215 browser_process_->profile_manager()->AutoloadProfiles(); | 1203 browser_process_->profile_manager()->AutoloadProfiles(); |
1216 #endif | 1204 #endif |
1217 // Post-profile init --------------------------------------------------------- | 1205 // Post-profile init --------------------------------------------------------- |
1218 | 1206 |
1219 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
1220 // Importing other browser settings is done in a browser-like process | |
1221 // that exits when this task has finished. | |
1222 // TODO(port): Port the Mac's IPC-based implementation to other platforms to | |
1223 // replace this implementation. http://crbug.com/22142 | |
1224 if (ProfileManager::IsImportProcess(parsed_command_line())) { | |
1225 return first_run::ImportNow(profile_, parsed_command_line()); | |
1226 } | |
1227 #endif | |
1228 | |
1229 #if defined(OS_WIN) | 1207 #if defined(OS_WIN) |
1230 // Do the tasks if chrome has been upgraded while it was last running. | 1208 // Do the tasks if chrome has been upgraded while it was last running. |
1231 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) | 1209 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) |
1232 return content::RESULT_CODE_NORMAL_EXIT; | 1210 return content::RESULT_CODE_NORMAL_EXIT; |
1233 | 1211 |
1234 // Check if there is any machine level Chrome installed on the current | 1212 // Check if there is any machine level Chrome installed on the current |
1235 // machine. If yes and the current Chrome process is user level, we do not | 1213 // machine. If yes and the current Chrome process is user level, we do not |
1236 // allow the user level Chrome to run. So we notify the user and uninstall | 1214 // allow the user level Chrome to run. So we notify the user and uninstall |
1237 // user level Chrome. | 1215 // user level Chrome. |
1238 // Note this check should only happen here, after all the checks above | 1216 // Note this check should only happen here, after all the checks above |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1274 #if !defined(OS_ANDROID) | 1252 #if !defined(OS_ANDROID) |
1275 // Show the First Run UI if this is the first time Chrome has been run on | 1253 // Show the First Run UI if this is the first time Chrome has been run on |
1276 // this computer, or we're being compelled to do so by a command line flag. | 1254 // this computer, or we're being compelled to do so by a command line flag. |
1277 // Note that this be done _after_ the PrefService is initialized and all | 1255 // Note that this be done _after_ the PrefService is initialized and all |
1278 // preferences are registered, since some of the code that the importer | 1256 // preferences are registered, since some of the code that the importer |
1279 // touches reads preferences. | 1257 // touches reads preferences. |
1280 if (do_first_run_tasks_) { | 1258 if (do_first_run_tasks_) { |
1281 first_run::AutoImport(profile_, | 1259 first_run::AutoImport(profile_, |
1282 master_prefs_->homepage_defined, | 1260 master_prefs_->homepage_defined, |
1283 master_prefs_->do_import_items, | 1261 master_prefs_->do_import_items, |
1284 master_prefs_->dont_import_items); | 1262 master_prefs_->dont_import_items, |
| 1263 master_prefs_->import_bookmarks_path); |
| 1264 |
1285 // Note: this can pop the first run consent dialog on linux. | 1265 // Note: this can pop the first run consent dialog on linux. |
1286 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); | 1266 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); |
1287 | 1267 |
1288 browser_process_->profile_manager()->OnImportFinished(profile_); | 1268 browser_process_->profile_manager()->OnImportFinished(profile_); |
1289 | 1269 |
1290 if (!master_prefs_->suppress_first_run_default_browser_prompt) { | 1270 if (!master_prefs_->suppress_first_run_default_browser_prompt) { |
1291 browser_creator_->set_show_main_browser_window( | 1271 browser_creator_->set_show_main_browser_window( |
1292 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); | 1272 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); |
1293 } else { | 1273 } else { |
1294 browser_creator_->set_is_default_browser_dialog_suppressed(true); | 1274 browser_creator_->set_is_default_browser_dialog_suppressed(true); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1727 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1748 uma_name += "_XP"; | 1728 uma_name += "_XP"; |
1749 | 1729 |
1750 uma_name += "_PreRead_"; | 1730 uma_name += "_PreRead_"; |
1751 uma_name += pre_read_percentage; | 1731 uma_name += pre_read_percentage; |
1752 AddPreReadHistogramTime(uma_name.c_str(), time); | 1732 AddPreReadHistogramTime(uma_name.c_str(), time); |
1753 } | 1733 } |
1754 #endif | 1734 #endif |
1755 #endif | 1735 #endif |
1756 } | 1736 } |
OLD | NEW |