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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 // CRLSetFetcher attempts to load a CRL set from either the local disk or | 487 // CRLSetFetcher attempts to load a CRL set from either the local disk or |
488 // network. | 488 // network. |
489 if (!command_line.HasSwitch(switches::kDisableCRLSets)) | 489 if (!command_line.HasSwitch(switches::kDisableCRLSets)) |
490 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus); | 490 g_browser_process->crl_set_fetcher()->StartInitialLoad(cus); |
491 | 491 |
492 RegisterPnaclComponent(cus, command_line); | 492 RegisterPnaclComponent(cus, command_line); |
493 | 493 |
494 cus->Start(); | 494 cus->Start(); |
495 } | 495 } |
496 | 496 |
| 497 #if !defined(OS_ANDROID) |
497 bool ProcessSingletonNotificationCallback( | 498 bool ProcessSingletonNotificationCallback( |
498 const CommandLine& command_line, | 499 const CommandLine& command_line, |
499 const base::FilePath& current_directory) { | 500 const base::FilePath& current_directory) { |
500 // Drop the request if the browser process is already in shutdown path. | 501 // Drop the request if the browser process is already in shutdown path. |
501 if (!g_browser_process || g_browser_process->IsShuttingDown()) | 502 if (!g_browser_process || g_browser_process->IsShuttingDown()) |
502 return false; | 503 return false; |
503 | 504 |
504 g_browser_process->PlatformSpecificCommandLineProcessing(command_line); | 505 g_browser_process->PlatformSpecificCommandLineProcessing(command_line); |
505 | 506 |
506 // TODO(erikwright): Consider removing this - AFAIK it is no longer used. | 507 // TODO(erikwright): Consider removing this - AFAIK it is no longer used. |
(...skipping 19 matching lines...) Expand all Loading... |
526 | 527 |
527 base::FilePath user_data_dir = | 528 base::FilePath user_data_dir = |
528 g_browser_process->profile_manager()->user_data_dir(); | 529 g_browser_process->profile_manager()->user_data_dir(); |
529 base::FilePath startup_profile_dir = | 530 base::FilePath startup_profile_dir = |
530 GetStartupProfilePath(user_data_dir, command_line); | 531 GetStartupProfilePath(user_data_dir, command_line); |
531 | 532 |
532 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( | 533 StartupBrowserCreator::ProcessCommandLineAlreadyRunning( |
533 command_line, current_directory, startup_profile_dir); | 534 command_line, current_directory, startup_profile_dir); |
534 return true; | 535 return true; |
535 } | 536 } |
| 537 #endif |
536 | 538 |
537 void LaunchDevToolsHandlerIfNeeded(Profile* profile, | 539 void LaunchDevToolsHandlerIfNeeded(Profile* profile, |
538 const CommandLine& command_line) { | 540 const CommandLine& command_line) { |
539 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { | 541 if (command_line.HasSwitch(::switches::kRemoteDebuggingPort)) { |
540 std::string port_str = | 542 std::string port_str = |
541 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); | 543 command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort); |
542 int port; | 544 int port; |
543 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { | 545 if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) { |
544 std::string frontend_str; | 546 std::string frontend_str; |
545 if (command_line.HasSwitch(::switches::kRemoteDebuggingFrontend)) { | 547 if (command_line.HasSwitch(::switches::kRemoteDebuggingFrontend)) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 603 |
602 ChromeBrowserMainParts::ChromeBrowserMainParts( | 604 ChromeBrowserMainParts::ChromeBrowserMainParts( |
603 const content::MainFunctionParams& parameters) | 605 const content::MainFunctionParams& parameters) |
604 : parameters_(parameters), | 606 : parameters_(parameters), |
605 parsed_command_line_(parameters.command_line), | 607 parsed_command_line_(parameters.command_line), |
606 result_code_(content::RESULT_CODE_NORMAL_EXIT), | 608 result_code_(content::RESULT_CODE_NORMAL_EXIT), |
607 startup_watcher_(new StartupTimeBomb()), | 609 startup_watcher_(new StartupTimeBomb()), |
608 shutdown_watcher_(new ShutdownWatcherHelper()), | 610 shutdown_watcher_(new ShutdownWatcherHelper()), |
609 startup_timer_(new performance_monitor::StartupTimer()), | 611 startup_timer_(new performance_monitor::StartupTimer()), |
610 browser_field_trials_(parameters.command_line), | 612 browser_field_trials_(parameters.command_line), |
| 613 #if !defined(OS_ANDROID) |
| 614 process_singleton_lock_( |
| 615 base::Bind(&ProcessSingletonNotificationCallback)), |
| 616 modal_dialog_lock_(process_singleton_lock_.AsNotificationCallback()), |
| 617 #endif |
611 record_search_engine_(false), | 618 record_search_engine_(false), |
612 translate_manager_(NULL), | 619 translate_manager_(NULL), |
613 profile_(NULL), | 620 profile_(NULL), |
614 run_message_loop_(true), | 621 run_message_loop_(true), |
615 notify_result_(ProcessSingleton::PROCESS_NONE), | 622 notify_result_(ProcessSingleton::PROCESS_NONE), |
616 do_first_run_tasks_(false), | 623 do_first_run_tasks_(false), |
617 local_state_(NULL), | 624 local_state_(NULL), |
618 restart_last_session_(false) { | 625 restart_last_session_(false) { |
619 // If we're running tests (ui_task is non-null). | 626 // If we're running tests (ui_task is non-null). |
620 if (parameters.ui_task) { | 627 if (parameters.ui_task) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 << "Must be able to get user data directory!"; | 827 << "Must be able to get user data directory!"; |
821 #endif | 828 #endif |
822 | 829 |
823 // Whether this is First Run. |do_first_run_tasks_| should be prefered to this | 830 // Whether this is First Run. |do_first_run_tasks_| should be prefered to this |
824 // unless the desire is actually to know whether this is really First Run | 831 // unless the desire is actually to know whether this is really First Run |
825 // (i.e., even if --no-first-run is passed). | 832 // (i.e., even if --no-first-run is passed). |
826 bool is_first_run = false; | 833 bool is_first_run = false; |
827 // Android's first run is done in Java instead of native. | 834 // Android's first run is done in Java instead of native. |
828 #if !defined(OS_ANDROID) | 835 #if !defined(OS_ANDROID) |
829 | 836 |
| 837 // Pass command-line invocations through modal_dialog_lock_ and |
| 838 // process_singleton_lock_ before handling them ourselves. |
830 process_singleton_.reset(new ProcessSingleton( | 839 process_singleton_.reset(new ProcessSingleton( |
831 user_data_dir_, base::Bind(&ProcessSingletonNotificationCallback))); | 840 user_data_dir_, modal_dialog_lock_.AsNotificationCallback())); |
832 // Ensure ProcessSingleton won't process messages too early. It will be | |
833 // unlocked in PostBrowserStart(). | |
834 process_singleton_->Lock(NULL); | |
835 | 841 |
836 bool force_first_run = | 842 bool force_first_run = |
837 parsed_command_line().HasSwitch(switches::kForceFirstRun); | 843 parsed_command_line().HasSwitch(switches::kForceFirstRun); |
838 bool force_skip_first_run_tasks = | 844 bool force_skip_first_run_tasks = |
839 (!force_first_run && | 845 (!force_first_run && |
840 parsed_command_line().HasSwitch(switches::kNoFirstRun)); | 846 parsed_command_line().HasSwitch(switches::kNoFirstRun)); |
841 | 847 |
842 is_first_run = | 848 is_first_run = |
843 (force_first_run || first_run::IsChromeFirstRun()) && | 849 (force_first_run || first_run::IsChromeFirstRun()) && |
844 !ProfileManager::IsImportProcess(parsed_command_line()); | 850 !ProfileManager::IsImportProcess(parsed_command_line()); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 void ChromeBrowserMainParts::PostBrowserStart() { | 1068 void ChromeBrowserMainParts::PostBrowserStart() { |
1063 #if !defined(OS_ANDROID) | 1069 #if !defined(OS_ANDROID) |
1064 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kVisitURLs)) | 1070 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kVisitURLs)) |
1065 RunPageCycler(); | 1071 RunPageCycler(); |
1066 #endif | 1072 #endif |
1067 | 1073 |
1068 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 1074 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
1069 chrome_extra_parts_[i]->PostBrowserStart(); | 1075 chrome_extra_parts_[i]->PostBrowserStart(); |
1070 #if !defined(OS_ANDROID) | 1076 #if !defined(OS_ANDROID) |
1071 // Allow ProcessSingleton to process messages. | 1077 // Allow ProcessSingleton to process messages. |
1072 process_singleton_->Unlock(); | 1078 process_singleton_lock_.Unlock(); |
1073 #endif | 1079 #endif |
1074 } | 1080 } |
1075 | 1081 |
1076 #if !defined(OS_ANDROID) | 1082 #if !defined(OS_ANDROID) |
1077 void ChromeBrowserMainParts::RunPageCycler() { | 1083 void ChromeBrowserMainParts::RunPageCycler() { |
1078 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1084 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1079 // We assume a native desktop for tests, but we will need to find a way to | 1085 // We assume a native desktop for tests, but we will need to find a way to |
1080 // get the proper host desktop type once we start running these tests in ASH. | 1086 // get the proper host desktop type once we start running these tests in ASH. |
1081 Browser* browser = chrome::FindBrowserWithProfile( | 1087 Browser* browser = chrome::FindBrowserWithProfile( |
1082 profile_, chrome::HOST_DESKTOP_TYPE_NATIVE); | 1088 profile_, chrome::HOST_DESKTOP_TYPE_NATIVE); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 std::string try_chrome = | 1243 std::string try_chrome = |
1238 parsed_command_line().GetSwitchValueASCII(switches::kTryChromeAgain); | 1244 parsed_command_line().GetSwitchValueASCII(switches::kTryChromeAgain); |
1239 if (!try_chrome.empty()) { | 1245 if (!try_chrome.empty()) { |
1240 #if defined(OS_WIN) | 1246 #if defined(OS_WIN) |
1241 // Setup.exe has determined that we need to run a retention experiment | 1247 // Setup.exe has determined that we need to run a retention experiment |
1242 // and has lauched chrome to show the experiment UI. It is guaranteed that | 1248 // and has lauched chrome to show the experiment UI. It is guaranteed that |
1243 // no other Chrome is currently running as the process singleton was | 1249 // no other Chrome is currently running as the process singleton was |
1244 // sucessfully grabbed above. | 1250 // sucessfully grabbed above. |
1245 int try_chrome_int; | 1251 int try_chrome_int; |
1246 base::StringToInt(try_chrome, &try_chrome_int); | 1252 base::StringToInt(try_chrome, &try_chrome_int); |
1247 TryChromeDialogView::Result answer = | 1253 TryChromeDialogView::Result answer = TryChromeDialogView::Show( |
1248 TryChromeDialogView::Show(try_chrome_int, process_singleton_.get()); | 1254 try_chrome_int, |
| 1255 base::Bind( |
| 1256 &ModalDialogLock::SetActiveModalDialog, |
| 1257 base::Unretained(&modal_dialog_lock_))); |
1249 if (answer == TryChromeDialogView::NOT_NOW) | 1258 if (answer == TryChromeDialogView::NOT_NOW) |
1250 return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL; | 1259 return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL; |
1251 if (answer == TryChromeDialogView::UNINSTALL_CHROME) | 1260 if (answer == TryChromeDialogView::UNINSTALL_CHROME) |
1252 return chrome::RESULT_CODE_NORMAL_EXIT_EXP2; | 1261 return chrome::RESULT_CODE_NORMAL_EXIT_EXP2; |
1253 // At this point the user is willing to try chrome again. | 1262 // At this point the user is willing to try chrome again. |
1254 if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) { | 1263 if (answer == TryChromeDialogView::TRY_CHROME_AS_DEFAULT) { |
1255 // Only set in the unattended case, the interactive case is Windows 8. | 1264 // Only set in the unattended case, the interactive case is Windows 8. |
1256 if (ShellIntegration::CanSetAsDefaultBrowser() == | 1265 if (ShellIntegration::CanSetAsDefaultBrowser() == |
1257 ShellIntegration::SET_DEFAULT_UNATTENDED) | 1266 ShellIntegration::SET_DEFAULT_UNATTENDED) |
1258 ShellIntegration::SetAsDefaultBrowser(); | 1267 ShellIntegration::SetAsDefaultBrowser(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1337 // Create an instance of GpuModeManager to watch gpu mode pref change. | 1346 // Create an instance of GpuModeManager to watch gpu mode pref change. |
1338 g_browser_process->gpu_mode_manager(); | 1347 g_browser_process->gpu_mode_manager(); |
1339 | 1348 |
1340 #if !defined(OS_ANDROID) | 1349 #if !defined(OS_ANDROID) |
1341 // Show the First Run UI if this is the first time Chrome has been run on | 1350 // Show the First Run UI if this is the first time Chrome has been run on |
1342 // this computer, or we're being compelled to do so by a command line flag. | 1351 // this computer, or we're being compelled to do so by a command line flag. |
1343 // Note that this be done _after_ the PrefService is initialized and all | 1352 // Note that this be done _after_ the PrefService is initialized and all |
1344 // preferences are registered, since some of the code that the importer | 1353 // preferences are registered, since some of the code that the importer |
1345 // touches reads preferences. | 1354 // touches reads preferences. |
1346 if (do_first_run_tasks_) { | 1355 if (do_first_run_tasks_) { |
| 1356 DCHECK(process_singleton_lock_.locked()); |
1347 first_run::AutoImport(profile_, | 1357 first_run::AutoImport(profile_, |
1348 master_prefs_->homepage_defined, | 1358 master_prefs_->homepage_defined, |
1349 master_prefs_->do_import_items, | 1359 master_prefs_->do_import_items, |
1350 master_prefs_->dont_import_items, | 1360 master_prefs_->dont_import_items); |
1351 process_singleton_.get()); | |
1352 // Note: this can pop the first run consent dialog on linux. | 1361 // Note: this can pop the first run consent dialog on linux. |
1353 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); | 1362 first_run::DoPostImportTasks(profile_, master_prefs_->make_chrome_default); |
1354 | 1363 |
1355 browser_process_->profile_manager()->OnImportFinished(profile_); | 1364 browser_process_->profile_manager()->OnImportFinished(profile_); |
1356 | 1365 |
1357 if (!master_prefs_->suppress_first_run_default_browser_prompt) { | 1366 if (!master_prefs_->suppress_first_run_default_browser_prompt) { |
1358 browser_creator_->set_show_main_browser_window( | 1367 browser_creator_->set_show_main_browser_window( |
1359 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); | 1368 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); |
1360 } else { | 1369 } else { |
1361 browser_creator_->set_is_default_browser_dialog_suppressed(true); | 1370 browser_creator_->set_is_default_browser_dialog_suppressed(true); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1814 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1823 if (base::win::GetVersion() <= base::win::VERSION_XP) |
1815 uma_name += "_XP"; | 1824 uma_name += "_XP"; |
1816 | 1825 |
1817 uma_name += "_PreRead_"; | 1826 uma_name += "_PreRead_"; |
1818 uma_name += pre_read_percentage; | 1827 uma_name += pre_read_percentage; |
1819 AddPreReadHistogramTime(uma_name.c_str(), time); | 1828 AddPreReadHistogramTime(uma_name.c_str(), time); |
1820 } | 1829 } |
1821 #endif | 1830 #endif |
1822 #endif | 1831 #endif |
1823 } | 1832 } |
OLD | NEW |