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