| 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 int ChromeBrowserMainParts::PreCreateThreadsImpl() { | 741 int ChromeBrowserMainParts::PreCreateThreadsImpl() { |
| 742 run_message_loop_ = false; | 742 run_message_loop_ = false; |
| 743 user_data_dir_ = chrome::GetUserDataDir(parameters()); | 743 user_data_dir_ = chrome::GetUserDataDir(parameters()); |
| 744 | 744 |
| 745 // Whether this is First Run. |do_first_run_tasks_| should be prefered to this | 745 // Whether this is First Run. |do_first_run_tasks_| should be prefered to this |
| 746 // unless the desire is actually to know whether this is really First Run | 746 // unless the desire is actually to know whether this is really First Run |
| 747 // (i.e., even if --no-first-run is passed). | 747 // (i.e., even if --no-first-run is passed). |
| 748 bool is_first_run = false; | 748 bool is_first_run = false; |
| 749 // Android's first run is done in Java instead of native. | 749 // Android's first run is done in Java instead of native. |
| 750 #if !defined(OS_ANDROID) | 750 #if !defined(OS_ANDROID) |
| 751 | 751 process_singleton_.reset(new ChromeProcessSingleton( |
| 752 process_singleton_.reset(new ProcessSingleton( | |
| 753 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 752 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); |
| 754 // Ensure ProcessSingleton won't process messages too early. It will be | |
| 755 // unlocked in PostBrowserStart(). | |
| 756 process_singleton_->Lock(NULL); | |
| 757 | 753 |
| 758 bool force_first_run = | 754 bool force_first_run = |
| 759 parsed_command_line().HasSwitch(switches::kForceFirstRun); | 755 parsed_command_line().HasSwitch(switches::kForceFirstRun); |
| 760 bool force_skip_first_run_tasks = | 756 bool force_skip_first_run_tasks = |
| 761 (!force_first_run && | 757 (!force_first_run && |
| 762 parsed_command_line().HasSwitch(switches::kNoFirstRun)); | 758 parsed_command_line().HasSwitch(switches::kNoFirstRun)); |
| 763 | 759 |
| 764 is_first_run = | 760 is_first_run = |
| 765 (force_first_run || first_run::IsChromeFirstRun()) && | 761 (force_first_run || first_run::IsChromeFirstRun()) && |
| 766 !ProfileManager::IsImportProcess(parsed_command_line()); | 762 !ProfileManager::IsImportProcess(parsed_command_line()); |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 std::string try_chrome = | 1163 std::string try_chrome = |
| 1168 parsed_command_line().GetSwitchValueASCII(switches::kTryChromeAgain); | 1164 parsed_command_line().GetSwitchValueASCII(switches::kTryChromeAgain); |
| 1169 if (!try_chrome.empty()) { | 1165 if (!try_chrome.empty()) { |
| 1170 #if defined(OS_WIN) | 1166 #if defined(OS_WIN) |
| 1171 // Setup.exe has determined that we need to run a retention experiment | 1167 // Setup.exe has determined that we need to run a retention experiment |
| 1172 // and has lauched chrome to show the experiment UI. It is guaranteed that | 1168 // and has lauched chrome to show the experiment UI. It is guaranteed that |
| 1173 // no other Chrome is currently running as the process singleton was | 1169 // no other Chrome is currently running as the process singleton was |
| 1174 // sucessfully grabbed above. | 1170 // sucessfully grabbed above. |
| 1175 int try_chrome_int; | 1171 int try_chrome_int; |
| 1176 base::StringToInt(try_chrome, &try_chrome_int); | 1172 base::StringToInt(try_chrome, &try_chrome_int); |
| 1177 TryChromeDialogView::Result answer = | 1173 TryChromeDialogView::Result answer = TryChromeDialogView::Show( |
| 1178 TryChromeDialogView::Show(try_chrome_int, process_singleton_.get()); | 1174 try_chrome_int, |
| 1175 base::Bind(&ChromeProcessSingleton::SetActiveModalDialog, |
| 1176 base::Unretained(process_singleton_.get()))); |
| 1179 if (answer == TryChromeDialogView::NOT_NOW) | 1177 if (answer == TryChromeDialogView::NOT_NOW) |
| 1180 return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL; | 1178 return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL; |
| 1181 if (answer == TryChromeDialogView::UNINSTALL_CHROME) | 1179 if (answer == TryChromeDialogView::UNINSTALL_CHROME) |
| 1182 return chrome::RESULT_CODE_NORMAL_EXIT_EXP2; | 1180 return chrome::RESULT_CODE_NORMAL_EXIT_EXP2; |
| 1183 // At this point the user is willing to try chrome again. | 1181 // At this point the user is willing to try chrome again. |
| 1184 if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) { | 1182 if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) { |
| 1185 // Only set in the unattended case, the interactive case is Windows 8. | 1183 // Only set in the unattended case, the interactive case is Windows 8. |
| 1186 if (ShellIntegration::CanSetAsDefaultBrowser() == | 1184 if (ShellIntegration::CanSetAsDefaultBrowser() == |
| 1187 ShellIntegration::SET_DEFAULT_UNATTENDED) | 1185 ShellIntegration::SET_DEFAULT_UNATTENDED) |
| 1188 ShellIntegration::SetAsDefaultBrowser(); | 1186 ShellIntegration::SetAsDefaultBrowser(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 #if !defined(OS_ANDROID) | 1268 #if !defined(OS_ANDROID) |
| 1271 // Show the First Run UI if this is the first time Chrome has been run on | 1269 // Show the First Run UI if this is the first time Chrome has been run on |
| 1272 // this computer, or we're being compelled to do so by a command line flag. | 1270 // this computer, or we're being compelled to do so by a command line flag. |
| 1273 // Note that this be done _after_ the PrefService is initialized and all | 1271 // Note that this be done _after_ the PrefService is initialized and all |
| 1274 // preferences are registered, since some of the code that the importer | 1272 // preferences are registered, since some of the code that the importer |
| 1275 // touches reads preferences. | 1273 // touches reads preferences. |
| 1276 if (do_first_run_tasks_) { | 1274 if (do_first_run_tasks_) { |
| 1277 first_run::AutoImport(profile_, | 1275 first_run::AutoImport(profile_, |
| 1278 master_prefs_->homepage_defined, | 1276 master_prefs_->homepage_defined, |
| 1279 master_prefs_->do_import_items, | 1277 master_prefs_->do_import_items, |
| 1280 master_prefs_->dont_import_items, | 1278 master_prefs_->dont_import_items); |
| 1281 process_singleton_.get()); | |
| 1282 // Note: this can pop the first run consent dialog on linux. | 1279 // Note: this can pop the first run consent dialog on linux. |
| 1283 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); | 1280 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); |
| 1284 | 1281 |
| 1285 browser_process_->profile_manager()->OnImportFinished(profile_); | 1282 browser_process_->profile_manager()->OnImportFinished(profile_); |
| 1286 | 1283 |
| 1287 if (!master_prefs_->suppress_first_run_default_browser_prompt) { | 1284 if (!master_prefs_->suppress_first_run_default_browser_prompt) { |
| 1288 browser_creator_->set_show_main_browser_window( | 1285 browser_creator_->set_show_main_browser_window( |
| 1289 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); | 1286 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); |
| 1290 } else { | 1287 } else { |
| 1291 browser_creator_->set_is_default_browser_dialog_suppressed(true); | 1288 browser_creator_->set_is_default_browser_dialog_suppressed(true); |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1732 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1736 uma_name += "_XP"; | 1733 uma_name += "_XP"; |
| 1737 | 1734 |
| 1738 uma_name += "_PreRead_"; | 1735 uma_name += "_PreRead_"; |
| 1739 uma_name += pre_read_percentage; | 1736 uma_name += pre_read_percentage; |
| 1740 AddPreReadHistogramTime(uma_name.c_str(), time); | 1737 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1741 } | 1738 } |
| 1742 #endif | 1739 #endif |
| 1743 #endif | 1740 #endif |
| 1744 } | 1741 } |
| OLD | NEW |