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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 #if !defined(OS_ANDROID) | 776 #if !defined(OS_ANDROID) |
777 process_singleton_.reset(new ChromeProcessSingleton( | 777 process_singleton_.reset(new ChromeProcessSingleton( |
778 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 778 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); |
779 | 779 |
780 bool force_first_run = | 780 bool force_first_run = |
781 parsed_command_line().HasSwitch(switches::kForceFirstRun); | 781 parsed_command_line().HasSwitch(switches::kForceFirstRun); |
782 bool force_skip_first_run_tasks = | 782 bool force_skip_first_run_tasks = |
783 (!force_first_run && | 783 (!force_first_run && |
784 parsed_command_line().HasSwitch(switches::kNoFirstRun)); | 784 parsed_command_line().HasSwitch(switches::kNoFirstRun)); |
785 | 785 |
786 is_first_run = | 786 is_first_run = force_first_run || first_run::IsChromeFirstRun(); |
787 (force_first_run || first_run::IsChromeFirstRun()) && | |
788 !ProfileManager::IsImportProcess(parsed_command_line()); | |
789 #endif | 787 #endif |
790 | 788 |
791 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = | 789 scoped_refptr<base::SequencedTaskRunner> local_state_task_runner = |
792 JsonPrefStore::GetTaskRunnerForFile( | 790 JsonPrefStore::GetTaskRunnerForFile( |
793 base::FilePath(chrome::kLocalStorePoolName), | 791 base::FilePath(chrome::kLocalStorePoolName), |
794 BrowserThread::GetBlockingPool()); | 792 BrowserThread::GetBlockingPool()); |
795 | 793 |
796 { | 794 { |
797 TRACE_EVENT0("startup", | 795 TRACE_EVENT0("startup", |
798 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); | 796 "ChromeBrowserMainParts::PreCreateThreadsImpl:InitBrowswerProcessImpl"); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 #if !defined(OS_ANDROID) | 1149 #if !defined(OS_ANDROID) |
1152 // If the command line specifies --pack-extension, attempt the pack extension | 1150 // If the command line specifies --pack-extension, attempt the pack extension |
1153 // startup action and exit. | 1151 // startup action and exit. |
1154 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { | 1152 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { |
1155 extensions::StartupHelper extension_startup_helper; | 1153 extensions::StartupHelper extension_startup_helper; |
1156 if (extension_startup_helper.PackExtension(parsed_command_line())) | 1154 if (extension_startup_helper.PackExtension(parsed_command_line())) |
1157 return content::RESULT_CODE_NORMAL_EXIT; | 1155 return content::RESULT_CODE_NORMAL_EXIT; |
1158 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; | 1156 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; |
1159 } | 1157 } |
1160 | 1158 |
1161 bool pass_command_line = true; | |
1162 | |
1163 #if !defined(OS_MACOSX) | |
1164 // In environments other than Mac OS X we support import of settings | |
1165 // from other browsers. In case this process is a short-lived "import" | |
1166 // process that another browser runs just to import the settings, we | |
1167 // don't want to be checking for another browser process, by design. | |
1168 pass_command_line = !ProfileManager::IsImportProcess(parsed_command_line()); | |
1169 #endif | |
1170 | |
1171 // If we're being launched just to check the connector policy, we are | 1159 // If we're being launched just to check the connector policy, we are |
1172 // short-lived and don't want to be passing that switch off. | 1160 // short-lived and don't want to be passing that switch off. |
1173 pass_command_line = pass_command_line && !parsed_command_line().HasSwitch( | 1161 bool pass_command_line = !parsed_command_line().HasSwitch( |
1174 switches::kCheckCloudPrintConnectorPolicy); | 1162 switches::kCheckCloudPrintConnectorPolicy); |
1175 | 1163 |
1176 if (pass_command_line) { | 1164 if (pass_command_line) { |
1177 // When another process is running, use that process instead of starting a | 1165 // When another process is running, use that process instead of starting a |
1178 // new one. NotifyOtherProcess will currently give the other process up to | 1166 // new one. NotifyOtherProcess will currently give the other process up to |
1179 // 20 seconds to respond. Note that this needs to be done before we attempt | 1167 // 20 seconds to respond. Note that this needs to be done before we attempt |
1180 // to read the profile. | 1168 // to read the profile. |
1181 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); | 1169 notify_result_ = process_singleton_->NotifyOtherProcessOrCreate(); |
1182 UMA_HISTOGRAM_ENUMERATION("NotifyOtherProcessOrCreate.Result", | 1170 UMA_HISTOGRAM_ENUMERATION("NotifyOtherProcessOrCreate.Result", |
1183 notify_result_, | 1171 notify_result_, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 if (!profile_) | 1255 if (!profile_) |
1268 return content::RESULT_CODE_NORMAL_EXIT; | 1256 return content::RESULT_CODE_NORMAL_EXIT; |
1269 | 1257 |
1270 #if defined(ENABLE_BACKGROUND) | 1258 #if defined(ENABLE_BACKGROUND) |
1271 // Autoload any profiles which are running background apps. | 1259 // Autoload any profiles which are running background apps. |
1272 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. | 1260 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. |
1273 browser_process_->profile_manager()->AutoloadProfiles(); | 1261 browser_process_->profile_manager()->AutoloadProfiles(); |
1274 #endif | 1262 #endif |
1275 // Post-profile init --------------------------------------------------------- | 1263 // Post-profile init --------------------------------------------------------- |
1276 | 1264 |
1277 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
1278 // Importing other browser settings is done in a browser-like process | |
1279 // that exits when this task has finished. | |
1280 // TODO(port): Port the Mac's IPC-based implementation to other platforms to | |
1281 // replace this implementation. http://crbug.com/22142 | |
1282 if (ProfileManager::IsImportProcess(parsed_command_line())) { | |
1283 return first_run::ImportNow(profile_, parsed_command_line()); | |
1284 } | |
1285 #endif | |
1286 | |
1287 #if defined(OS_WIN) | 1265 #if defined(OS_WIN) |
1288 // Do the tasks if chrome has been upgraded while it was last running. | 1266 // Do the tasks if chrome has been upgraded while it was last running. |
1289 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) | 1267 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) |
1290 return content::RESULT_CODE_NORMAL_EXIT; | 1268 return content::RESULT_CODE_NORMAL_EXIT; |
1291 | 1269 |
1292 // Check if there is any machine level Chrome installed on the current | 1270 // Check if there is any machine level Chrome installed on the current |
1293 // machine. If yes and the current Chrome process is user level, we do not | 1271 // machine. If yes and the current Chrome process is user level, we do not |
1294 // allow the user level Chrome to run. So we notify the user and uninstall | 1272 // allow the user level Chrome to run. So we notify the user and uninstall |
1295 // user level Chrome. | 1273 // user level Chrome. |
1296 // Note this check should only happen here, after all the checks above | 1274 // 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... |
1332 #if !defined(OS_ANDROID) | 1310 #if !defined(OS_ANDROID) |
1333 // Show the First Run UI if this is the first time Chrome has been run on | 1311 // Show the First Run UI if this is the first time Chrome has been run on |
1334 // this computer, or we're being compelled to do so by a command line flag. | 1312 // this computer, or we're being compelled to do so by a command line flag. |
1335 // Note that this be done _after_ the PrefService is initialized and all | 1313 // Note that this be done _after_ the PrefService is initialized and all |
1336 // preferences are registered, since some of the code that the importer | 1314 // preferences are registered, since some of the code that the importer |
1337 // touches reads preferences. | 1315 // touches reads preferences. |
1338 if (do_first_run_tasks_) { | 1316 if (do_first_run_tasks_) { |
1339 first_run::AutoImport(profile_, | 1317 first_run::AutoImport(profile_, |
1340 master_prefs_->homepage_defined, | 1318 master_prefs_->homepage_defined, |
1341 master_prefs_->do_import_items, | 1319 master_prefs_->do_import_items, |
1342 master_prefs_->dont_import_items); | 1320 master_prefs_->dont_import_items, |
| 1321 master_prefs_->import_bookmarks_path); |
| 1322 |
1343 // Note: this can pop the first run consent dialog on linux. | 1323 // Note: this can pop the first run consent dialog on linux. |
1344 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); | 1324 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); |
1345 | 1325 |
1346 browser_process_->profile_manager()->OnImportFinished(profile_); | 1326 browser_process_->profile_manager()->OnImportFinished(profile_); |
1347 | 1327 |
1348 if (!master_prefs_->suppress_first_run_default_browser_prompt) { | 1328 if (!master_prefs_->suppress_first_run_default_browser_prompt) { |
1349 browser_creator_->set_show_main_browser_window( | 1329 browser_creator_->set_show_main_browser_window( |
1350 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); | 1330 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); |
1351 } else { | 1331 } else { |
1352 browser_creator_->set_is_default_browser_dialog_suppressed(true); | 1332 browser_creator_->set_is_default_browser_dialog_suppressed(true); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1788 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1809 uma_name += "_XP"; | 1789 uma_name += "_XP"; |
1810 | 1790 |
1811 uma_name += "_PreRead_"; | 1791 uma_name += "_PreRead_"; |
1812 uma_name += pre_read_percentage; | 1792 uma_name += pre_read_percentage; |
1813 AddPreReadHistogramTime(uma_name.c_str(), time); | 1793 AddPreReadHistogramTime(uma_name.c_str(), time); |
1814 } | 1794 } |
1815 #endif | 1795 #endif |
1816 #endif | 1796 #endif |
1817 } | 1797 } |
OLD | NEW |