Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: chrome/browser/chrome_browser_main.cc

Issue 10885023: Use ChromeBrowserMainPartsAndroid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 671
672 void ChromeBrowserMainParts::PostMainMessageLoopStart() { 672 void ChromeBrowserMainParts::PostMainMessageLoopStart() {
673 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 673 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
674 chrome_extra_parts_[i]->PostMainMessageLoopStart(); 674 chrome_extra_parts_[i]->PostMainMessageLoopStart();
675 } 675 }
676 676
677 int ChromeBrowserMainParts::PreCreateThreads() { 677 int ChromeBrowserMainParts::PreCreateThreads() {
678 result_code_ = PreCreateThreadsImpl(); 678 result_code_ = PreCreateThreadsImpl();
679 // These members must be initialized before returning from this function. 679 // These members must be initialized before returning from this function.
680 DCHECK(master_prefs_.get()); 680 DCHECK(master_prefs_.get());
681 #if !defined(OS_ANDROID)
681 DCHECK(browser_creator_.get()); 682 DCHECK(browser_creator_.get());
683 #endif
682 return result_code_; 684 return result_code_;
683 } 685 }
684 686
685 int ChromeBrowserMainParts::PreCreateThreadsImpl() { 687 int ChromeBrowserMainParts::PreCreateThreadsImpl() {
686 run_message_loop_ = false; 688 run_message_loop_ = false;
687 #if defined(OS_WIN) 689 #if defined(OS_WIN)
688 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_); 690 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_);
689 #else 691 #else
690 // Getting the user data dir can fail if the directory isn't 692 // Getting the user data dir can fail if the directory isn't
691 // creatable, for example; on Windows in code below we bring up a 693 // creatable, for example; on Windows in code below we bring up a
692 // dialog prompting the user to pick a different directory. 694 // dialog prompting the user to pick a different directory.
693 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux, 695 // However, ProcessSingleton needs a real user_data_dir on Mac/Linux,
694 // so it's better to fail here than fail mysteriously elsewhere. 696 // so it's better to fail here than fail mysteriously elsewhere.
695 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_)) 697 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir_))
696 << "Must be able to get user data directory!"; 698 << "Must be able to get user data directory!";
697 #endif 699 #endif
698 700
701 // Android's first run is done in Java instead of native.
702 #if !defined(OS_ANDROID)
699 process_singleton_.reset(new ProcessSingleton(user_data_dir_)); 703 process_singleton_.reset(new ProcessSingleton(user_data_dir_));
700 // Ensure ProcessSingleton won't process messages too early. It will be 704 // Ensure ProcessSingleton won't process messages too early. It will be
701 // unlocked in PostBrowserStart(). 705 // unlocked in PostBrowserStart().
702 process_singleton_->Lock(NULL); 706 process_singleton_->Lock(NULL);
703 707
704 is_first_run_ = 708 is_first_run_ =
705 (first_run::IsChromeFirstRun() || 709 (first_run::IsChromeFirstRun() ||
706 parsed_command_line().HasSwitch(switches::kFirstRun)) && 710 parsed_command_line().HasSwitch(switches::kFirstRun)) &&
707 !HasImportSwitch(parsed_command_line()); 711 !HasImportSwitch(parsed_command_line());
712 #endif
708 browser_process_.reset(new BrowserProcessImpl(parsed_command_line())); 713 browser_process_.reset(new BrowserProcessImpl(parsed_command_line()));
709 714
710 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) { 715 if (parsed_command_line().HasSwitch(switches::kEnableProfiling)) {
711 // User wants to override default tracking status. 716 // User wants to override default tracking status.
712 std::string flag = 717 std::string flag =
713 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling); 718 parsed_command_line().GetSwitchValueASCII(switches::kEnableProfiling);
714 // Default to basic profiling (no parent child support). 719 // Default to basic profiling (no parent child support).
715 tracked_objects::ThreadData::Status status = 720 tracked_objects::ThreadData::Status status =
716 tracked_objects::ThreadData::PROFILING_ACTIVE; 721 tracked_objects::ThreadData::PROFILING_ACTIVE;
717 if (flag.compare("0") != 0) 722 if (flag.compare("0") != 0)
718 status = tracked_objects::ThreadData::DEACTIVATED; 723 status = tracked_objects::ThreadData::DEACTIVATED;
719 else if (flag.compare("child") != 0) 724 else if (flag.compare("child") != 0)
720 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE; 725 status = tracked_objects::ThreadData::PROFILING_CHILDREN_ACTIVE;
721 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); 726 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status);
722 } 727 }
723 728
724 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) { 729 if (parsed_command_line().HasSwitch(switches::kProfilingOutputFile)) {
725 tracking_objects_.set_output_file_path( 730 tracking_objects_.set_output_file_path(
726 parsed_command_line().GetSwitchValuePath( 731 parsed_command_line().GetSwitchValuePath(
727 switches::kProfilingOutputFile)); 732 switches::kProfilingOutputFile));
728 } 733 }
729 734
730 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_); 735 local_state_ = InitializeLocalState(parsed_command_line(), is_first_run_);
731 736
732 // These members must be initialized before returning from this function. 737 // These members must be initialized before returning from this function.
733 master_prefs_.reset(new first_run::MasterPrefs); 738 master_prefs_.reset(new first_run::MasterPrefs);
739
740 #if !defined(OS_ANDROID)
741 // Android doesn't use StartupBrowserCreator.
734 browser_creator_.reset(new StartupBrowserCreator); 742 browser_creator_.reset(new StartupBrowserCreator);
743 // TODO(yfriedman): Refactor Android to re-use UMABrowsingActivityObserver
735 chrome::UMABrowsingActivityObserver::Init(); 744 chrome::UMABrowsingActivityObserver::Init();
745 #endif
736 746
737 // Convert active labs into switches. This needs to be done before 747 // Convert active labs into switches. This needs to be done before
738 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are 748 // ResourceBundle::InitSharedInstanceWithLocale as some loaded resources are
739 // affected by experiment flags (--touch-optimized-ui in particular). Not 749 // affected by experiment flags (--touch-optimized-ui in particular). Not
740 // needed on Android as there aren't experimental flags. 750 // needed on Android as there aren't experimental flags.
741 about_flags::ConvertFlagsToSwitches(local_state_, 751 about_flags::ConvertFlagsToSwitches(local_state_,
742 CommandLine::ForCurrentProcess()); 752 CommandLine::ForCurrentProcess());
743 local_state_->UpdateCommandLinePrefStore(CommandLine::ForCurrentProcess()); 753 local_state_->UpdateCommandLinePrefStore(CommandLine::ForCurrentProcess());
744 754
745 // Reset the command line in the crash report details, since we may have 755 // Reset the command line in the crash report details, since we may have
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 if (ShellIntegration::CanSetAsDefaultBrowser() == 818 if (ShellIntegration::CanSetAsDefaultBrowser() ==
809 ShellIntegration::SET_DEFAULT_UNATTENDED) 819 ShellIntegration::SET_DEFAULT_UNATTENDED)
810 ShellIntegration::SetAsDefaultBrowser(); 820 ShellIntegration::SetAsDefaultBrowser();
811 } 821 }
812 #else 822 #else
813 // We don't support retention experiments on Mac or Linux. 823 // We don't support retention experiments on Mac or Linux.
814 return content::RESULT_CODE_NORMAL_EXIT; 824 return content::RESULT_CODE_NORMAL_EXIT;
815 #endif // defined(OS_WIN) 825 #endif // defined(OS_WIN)
816 } 826 }
817 827
828 // Android does first run in Java instead of native.
829 #if !defined(OS_ANDROID)
818 // On first run, we need to process the predictor preferences before the 830 // On first run, we need to process the predictor preferences before the
819 // browser's profile_manager object is created, but after ResourceBundle 831 // browser's profile_manager object is created, but after ResourceBundle
820 // is initialized. 832 // is initialized.
821 first_run_ui_bypass_ = false; // True to skip first run UI. 833 first_run_ui_bypass_ = false; // True to skip first run UI.
822 if (is_first_run_) { 834 if (is_first_run_) {
823 first_run_ui_bypass_ = !first_run::ProcessMasterPreferences( 835 first_run_ui_bypass_ = !first_run::ProcessMasterPreferences(
824 user_data_dir_, master_prefs_.get()); 836 user_data_dir_, master_prefs_.get());
825 AddFirstRunNewTabs(browser_creator_.get(), master_prefs_->new_tabs); 837 AddFirstRunNewTabs(browser_creator_.get(), master_prefs_->new_tabs);
826 838
827 // If we are running in App mode, we do not want to show the importer 839 // If we are running in App mode, we do not want to show the importer
828 // (first run) UI. 840 // (first run) UI.
829 if (!first_run_ui_bypass_ && 841 if (!first_run_ui_bypass_ &&
830 (parsed_command_line().HasSwitch(switches::kApp) || 842 (parsed_command_line().HasSwitch(switches::kApp) ||
831 parsed_command_line().HasSwitch(switches::kAppId) || 843 parsed_command_line().HasSwitch(switches::kAppId) ||
832 parsed_command_line().HasSwitch(switches::kNoFirstRun))) 844 parsed_command_line().HasSwitch(switches::kNoFirstRun)))
833 first_run_ui_bypass_ = true; 845 first_run_ui_bypass_ = true;
834 846
835 // Create Sentinel if no-first-run argument is passed in. 847 // Create Sentinel if no-first-run argument is passed in.
836 if (parsed_command_line().HasSwitch(switches::kNoFirstRun)) 848 if (parsed_command_line().HasSwitch(switches::kNoFirstRun))
837 first_run::CreateSentinel(); 849 first_run::CreateSentinel();
838 } 850 }
851 #endif
839 852
840 // TODO(viettrungluu): why don't we run this earlier? 853 // TODO(viettrungluu): why don't we run this earlier?
841 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs)) 854 if (!parsed_command_line().HasSwitch(switches::kNoErrorDialogs))
842 WarnAboutMinimumSystemRequirements(); 855 WarnAboutMinimumSystemRequirements();
843 856
844 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX) 857 #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_MACOSX)
845 // Set the product channel for crash reports. 858 // Set the product channel for crash reports.
846 child_process_logging::SetChannel( 859 child_process_logging::SetChannel(
847 chrome::VersionInfo::GetVersionStringModifier()); 860 chrome::VersionInfo::GetVersionStringModifier());
848 #endif 861 #endif
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 928 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
916 chrome_extra_parts_[i]->PreBrowserStart(); 929 chrome_extra_parts_[i]->PreBrowserStart();
917 } 930 }
918 931
919 void ChromeBrowserMainParts::PostBrowserStart() { 932 void ChromeBrowserMainParts::PostBrowserStart() {
920 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kVisitURLs)) 933 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kVisitURLs))
921 RunPageCycler(); 934 RunPageCycler();
922 935
923 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) 936 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
924 chrome_extra_parts_[i]->PostBrowserStart(); 937 chrome_extra_parts_[i]->PostBrowserStart();
938 #if !defined(OS_ANDROID)
925 // Allow ProcessSingleton to process messages. 939 // Allow ProcessSingleton to process messages.
926 process_singleton_->Unlock(); 940 process_singleton_->Unlock();
941 #endif
927 } 942 }
928 943
929 void ChromeBrowserMainParts::RunPageCycler() { 944 void ChromeBrowserMainParts::RunPageCycler() {
Lei Zhang 2012/08/29 19:23:57 #ifdef out the method definition as well? Then you
Yaron 2012/08/29 20:48:33 Was trying to minimize if-defs but sure it's more
945 #if !defined(OS_ANDROID)
930 CommandLine* command_line = CommandLine::ForCurrentProcess(); 946 CommandLine* command_line = CommandLine::ForCurrentProcess();
931 // We assume a native desktop for tests, but we will need to find a way to 947 // We assume a native desktop for tests, but we will need to find a way to
932 // get the proper host desktop type once we start running these tests in ASH. 948 // get the proper host desktop type once we start running these tests in ASH.
933 Browser* browser = browser::FindBrowserWithProfile( 949 Browser* browser = browser::FindBrowserWithProfile(
934 profile_, chrome::HOST_DESKTOP_TYPE_NATIVE); 950 profile_, chrome::HOST_DESKTOP_TYPE_NATIVE);
935 DCHECK(browser); 951 DCHECK(browser);
936 PageCycler* page_cycler = NULL; 952 PageCycler* page_cycler = NULL;
937 FilePath input_file = 953 FilePath input_file =
938 command_line->GetSwitchValuePath(switches::kVisitURLs); 954 command_line->GetSwitchValuePath(switches::kVisitURLs);
939 page_cycler = new PageCycler(browser, input_file); 955 page_cycler = new PageCycler(browser, input_file);
940 page_cycler->set_errors_file( 956 page_cycler->set_errors_file(
941 input_file.AddExtension(FILE_PATH_LITERAL(".errors"))); 957 input_file.AddExtension(FILE_PATH_LITERAL(".errors")));
942 if (command_line->HasSwitch(switches::kRecordStats)) { 958 if (command_line->HasSwitch(switches::kRecordStats)) {
943 page_cycler->set_stats_file( 959 page_cycler->set_stats_file(
944 command_line->GetSwitchValuePath(switches::kRecordStats)); 960 command_line->GetSwitchValuePath(switches::kRecordStats));
945 } 961 }
946 page_cycler->Run(); 962 page_cycler->Run();
963 #endif // !defined(OS_ANDROID)
947 } 964 }
948 965
949 void ChromeBrowserMainParts::SetupPlatformFieldTrials() { 966 void ChromeBrowserMainParts::SetupPlatformFieldTrials() {
950 // Base class implementation of this does nothing. 967 // Base class implementation of this does nothing.
951 } 968 }
952 969
953 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { 970 int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
971 // Android updates the metrics service dynamically depending on whether the
972 // application is in the foreground or not. Do not start here.
973 #if !defined(OS_ANDROID)
954 // Now that the file thread has been started, start recording. 974 // Now that the file thread has been started, start recording.
955 StartMetricsRecording(); 975 StartMetricsRecording();
976 #endif
956 977
957 // Create watchdog thread after creating all other threads because it will 978 // Create watchdog thread after creating all other threads because it will
958 // watch the other threads and they must be running. 979 // watch the other threads and they must be running.
959 browser_process_->watchdog_thread(); 980 browser_process_->watchdog_thread();
960 981
961 // Do any initializating in the browser process that requires all threads 982 // Do any initializating in the browser process that requires all threads
962 // running. 983 // running.
963 browser_process_->PreMainMessageLoopRun(); 984 browser_process_->PreMainMessageLoopRun();
964 985
965 // Record last shutdown time into a histogram. 986 // Record last shutdown time into a histogram.
(...skipping 17 matching lines...) Expand all
983 parsed_command_line_); 1004 parsed_command_line_);
984 } 1005 }
985 #endif 1006 #endif
986 1007
987 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) { 1008 if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) {
988 return ShellIntegration::SetAsDefaultBrowser() ? 1009 return ShellIntegration::SetAsDefaultBrowser() ?
989 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) : 1010 static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) :
990 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED); 1011 static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
991 } 1012 }
992 1013
1014 // Android doesn't support extensions and doesn't implement ProcessSingleton.
1015 #if !defined(OS_ANDROID)
993 // If the command line specifies --pack-extension, attempt the pack extension 1016 // If the command line specifies --pack-extension, attempt the pack extension
994 // startup action and exit. 1017 // startup action and exit.
995 if (parsed_command_line().HasSwitch(switches::kPackExtension)) { 1018 if (parsed_command_line().HasSwitch(switches::kPackExtension)) {
996 extensions::StartupHelper extension_startup_helper; 1019 extensions::StartupHelper extension_startup_helper;
997 if (extension_startup_helper.PackExtension(parsed_command_line())) 1020 if (extension_startup_helper.PackExtension(parsed_command_line()))
998 return content::RESULT_CODE_NORMAL_EXIT; 1021 return content::RESULT_CODE_NORMAL_EXIT;
999 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR; 1022 return chrome::RESULT_CODE_PACK_EXTENSION_ERROR;
1000 } 1023 }
1001 1024
1002 bool pass_command_line = true; 1025 bool pass_command_line = true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 "directory. This means that running multiple instances " 1064 "directory. This means that running multiple instances "
1042 "would start multiple browser processes rather than " 1065 "would start multiple browser processes rather than "
1043 "opening a new window in the existing process. Aborting " 1066 "opening a new window in the existing process. Aborting "
1044 "now to avoid profile corruption."; 1067 "now to avoid profile corruption.";
1045 return chrome::RESULT_CODE_PROFILE_IN_USE; 1068 return chrome::RESULT_CODE_PROFILE_IN_USE;
1046 1069
1047 default: 1070 default:
1048 NOTREACHED(); 1071 NOTREACHED();
1049 } 1072 }
1050 } 1073 }
1074 #endif // !defined(OS_ANDROID)
1051 1075
1052 #if defined(USE_X11) 1076 #if defined(USE_X11)
1053 SetBrowserX11ErrorHandlers(); 1077 SetBrowserX11ErrorHandlers();
1054 #endif 1078 #endif
1055 1079
1056 // Desktop construction occurs here, (required before profile creation). 1080 // Desktop construction occurs here, (required before profile creation).
1057 PreProfileInit(); 1081 PreProfileInit();
1058 1082
1059 // Profile creation ---------------------------------------------------------- 1083 // Profile creation ----------------------------------------------------------
1060 1084
1061 if (is_first_run_) { 1085 if (is_first_run_) {
1062 // Warn the ProfileManager that an import process will run, possibly 1086 // Warn the ProfileManager that an import process will run, possibly
1063 // locking the WebDataService directory of the next Profile created. 1087 // locking the WebDataService directory of the next Profile created.
1064 browser_process_->profile_manager()->SetWillImport(); 1088 browser_process_->profile_manager()->SetWillImport();
1065 } 1089 }
1066 1090
1067 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line()); 1091 profile_ = CreateProfile(parameters(), user_data_dir_, parsed_command_line());
1068 if (!profile_) 1092 if (!profile_)
1069 return content::RESULT_CODE_NORMAL_EXIT; 1093 return content::RESULT_CODE_NORMAL_EXIT;
1070 1094
1095 #if defined(ENABLE_BACKGROUND)
1071 // Autoload any profiles which are running background apps. 1096 // Autoload any profiles which are running background apps.
1072 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075. 1097 // TODO(rlp): Do this on a separate thread. See http://crbug.com/99075.
1073 browser_process_->profile_manager()->AutoloadProfiles(); 1098 browser_process_->profile_manager()->AutoloadProfiles();
1074 1099 #endif
1075 // Post-profile init --------------------------------------------------------- 1100 // Post-profile init ---------------------------------------------------------
1076 1101
1077 #if !defined(OS_MACOSX) 1102 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
1078 // Importing other browser settings is done in a browser-like process 1103 // Importing other browser settings is done in a browser-like process
1079 // that exits when this task has finished. 1104 // that exits when this task has finished.
1080 // TODO(port): Port the Mac's IPC-based implementation to other platforms to 1105 // TODO(port): Port the Mac's IPC-based implementation to other platforms to
1081 // replace this implementation. http://crbug.com/22142 1106 // replace this implementation. http://crbug.com/22142
1082 if (HasImportSwitch(parsed_command_line())) { 1107 if (HasImportSwitch(parsed_command_line())) {
1083 return first_run::ImportNow(profile_, parsed_command_line()); 1108 return first_run::ImportNow(profile_, parsed_command_line());
1084 } 1109 }
1085 #endif 1110 #endif
1086 1111
1087 #if defined(OS_WIN) 1112 #if defined(OS_WIN)
1088 // Do the tasks if chrome has been upgraded while it was last running. 1113 // Do the tasks if chrome has been upgraded while it was last running.
1089 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line())) 1114 if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line()))
1090 return content::RESULT_CODE_NORMAL_EXIT; 1115 return content::RESULT_CODE_NORMAL_EXIT;
1091 1116
1092 // Check if there is any machine level Chrome installed on the current 1117 // Check if there is any machine level Chrome installed on the current
1093 // machine. If yes and the current Chrome process is user level, we do not 1118 // machine. If yes and the current Chrome process is user level, we do not
1094 // allow the user level Chrome to run. So we notify the user and uninstall 1119 // allow the user level Chrome to run. So we notify the user and uninstall
1095 // user level Chrome. 1120 // user level Chrome.
1096 // Note this check should only happen here, after all the checks above 1121 // Note this check should only happen here, after all the checks above
1097 // (uninstall, resource bundle initialization, other chrome browser 1122 // (uninstall, resource bundle initialization, other chrome browser
1098 // processes etc). 1123 // processes etc).
1099 // Do not allow this to occur for Chrome Frame user-to-system handoffs. 1124 // Do not allow this to occur for Chrome Frame user-to-system handoffs.
1100 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) && 1125 if (!parsed_command_line().HasSwitch(switches::kChromeFrame) &&
1101 ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) { 1126 ChromeBrowserMainPartsWin::CheckMachineLevelInstall()) {
1102 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS; 1127 return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS;
1103 } 1128 }
1104 #endif 1129 #endif
1105 1130
1131 #if !defined(OS_ANDROID)
1106 // Create the TranslateManager singleton. 1132 // Create the TranslateManager singleton.
1107 translate_manager_ = TranslateManager::GetInstance(); 1133 translate_manager_ = TranslateManager::GetInstance();
1108 DCHECK(translate_manager_ != NULL); 1134 DCHECK(translate_manager_ != NULL);
1109 1135
1110 // Initialize Managed Mode. 1136 // Initialize Managed Mode.
1111 ManagedMode::Init(profile_); 1137 ManagedMode::Init(profile_);
1138 #endif
1112 1139
1113 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts. 1140 // TODO(stevenjb): Move WIN and MACOSX specific code to appropriate Parts.
1114 // (requires supporting early exit). 1141 // (requires supporting early exit).
1115 PostProfileInit(); 1142 PostProfileInit();
1116 1143
1144 #if !defined(OS_ANDROID)
1117 // Show the First Run UI if this is the first time Chrome has been run on 1145 // Show the First Run UI if this is the first time Chrome has been run on
1118 // this computer, or we're being compelled to do so by a command line flag. 1146 // this computer, or we're being compelled to do so by a command line flag.
1119 // Note that this be done _after_ the PrefService is initialized and all 1147 // Note that this be done _after_ the PrefService is initialized and all
1120 // preferences are registered, since some of the code that the importer 1148 // preferences are registered, since some of the code that the importer
1121 // touches reads preferences. 1149 // touches reads preferences.
1122 if (is_first_run_) { 1150 if (is_first_run_) {
1123 if (!first_run_ui_bypass_) { 1151 if (!first_run_ui_bypass_) {
1124 first_run::AutoImport(profile_, 1152 first_run::AutoImport(profile_,
1125 master_prefs_->homepage_defined, 1153 master_prefs_->homepage_defined,
1126 master_prefs_->do_import_items, 1154 master_prefs_->do_import_items,
(...skipping 14 matching lines...) Expand all
1141 chrome::SetNewHomePagePrefs(profile_->GetPrefs()); 1169 chrome::SetNewHomePagePrefs(profile_->GetPrefs());
1142 browser_process_->profile_manager()->OnImportFinished(profile_); 1170 browser_process_->profile_manager()->OnImportFinished(profile_);
1143 1171
1144 if (!master_prefs_->suppress_first_run_default_browser_prompt) { 1172 if (!master_prefs_->suppress_first_run_default_browser_prompt) {
1145 browser_creator_->set_show_main_browser_window( 1173 browser_creator_->set_show_main_browser_window(
1146 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); 1174 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_));
1147 } else { 1175 } else {
1148 browser_creator_->set_is_default_browser_dialog_suppressed(true); 1176 browser_creator_->set_is_default_browser_dialog_suppressed(true);
1149 } 1177 }
1150 } // if (is_first_run_) 1178 } // if (is_first_run_)
1179 #endif // !defined(OS_ANDROID)
1151 1180
1152 #if defined(OS_WIN) 1181 #if defined(OS_WIN)
1153 // Sets things up so that if we crash from this point on, a dialog will 1182 // Sets things up so that if we crash from this point on, a dialog will
1154 // popup asking the user to restart chrome. It is done this late to avoid 1183 // popup asking the user to restart chrome. It is done this late to avoid
1155 // testing against a bunch of special cases that are taken care early on. 1184 // testing against a bunch of special cases that are taken care early on.
1156 ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment( 1185 ChromeBrowserMainPartsWin::PrepareRestartOnCrashEnviroment(
1157 parsed_command_line()); 1186 parsed_command_line());
1158 1187
1159 // Registers Chrome with the Windows Restart Manager, which will restore the 1188 // Registers Chrome with the Windows Restart Manager, which will restore the
1160 // Chrome session when the computer is restarted after a system update. 1189 // Chrome session when the computer is restarted after a system update.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 #endif 1344 #endif
1316 1345
1317 PreBrowserStart(); 1346 PreBrowserStart();
1318 1347
1319 // Instantiate the notification UI manager, as this triggers a perf timer 1348 // Instantiate the notification UI manager, as this triggers a perf timer
1320 // used to measure startup time. TODO(stevenjb): Figure out what is actually 1349 // used to measure startup time. TODO(stevenjb): Figure out what is actually
1321 // triggering the timer and call that explicitly in the approprate place. 1350 // triggering the timer and call that explicitly in the approprate place.
1322 // http://crbug.com/105065. 1351 // http://crbug.com/105065.
1323 browser_process_->notification_ui_manager(); 1352 browser_process_->notification_ui_manager();
1324 1353
1354 #if !defined(OS_ANDROID)
1325 // Most general initialization is behind us, but opening a 1355 // Most general initialization is behind us, but opening a
1326 // tab and/or session restore and such is still to be done. 1356 // tab and/or session restore and such is still to be done.
1327 base::TimeTicks browser_open_start = base::TimeTicks::Now(); 1357 base::TimeTicks browser_open_start = base::TimeTicks::Now();
1328 1358
1329 // We are in regular browser boot sequence. Open initial tabs and enter the 1359 // We are in regular browser boot sequence. Open initial tabs and enter the
1330 // main message loop. 1360 // main message loop.
1331 int result_code; 1361 int result_code;
1332 #if defined(OS_CHROMEOS) 1362 #if defined(OS_CHROMEOS)
1333 // On ChromeOS multiple profiles doesn't apply, and will break if we load 1363 // On ChromeOS multiple profiles doesn't apply, and will break if we load
1334 // them this early as the cryptohome hasn't yet been mounted (which happens 1364 // them this early as the cryptohome hasn't yet been mounted (which happens
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 profile_->GetPrefs()); 1415 profile_->GetPrefs());
1386 } 1416 }
1387 } 1417 }
1388 #endif 1418 #endif
1389 1419
1390 run_message_loop_ = true; 1420 run_message_loop_ = true;
1391 } else { 1421 } else {
1392 run_message_loop_ = false; 1422 run_message_loop_ = false;
1393 } 1423 }
1394 browser_creator_.reset(); 1424 browser_creator_.reset();
1425 #endif // !defined(OS_ANDROID)
1395 1426
1396 PostBrowserStart(); 1427 PostBrowserStart();
1397 1428
1398 if (parameters().ui_task) { 1429 if (parameters().ui_task) {
1399 // We end the startup timer here if we have parameters to run, because we 1430 // We end the startup timer here if we have parameters to run, because we
1400 // never start to run the main loop (where we normally stop the timer). 1431 // never start to run the main loop (where we normally stop the timer).
1401 startup_timer_->SignalStartupComplete( 1432 startup_timer_->SignalStartupComplete(
1402 performance_monitor::StartupTimer::STARTUP_TEST); 1433 performance_monitor::StartupTimer::STARTUP_TEST);
1403 parameters().ui_task->Run(); 1434 parameters().ui_task->Run();
1404 delete parameters().ui_task; 1435 delete parameters().ui_task;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 ThreadWatcherList::StopWatchingAll(); 1525 ThreadWatcherList::StopWatchingAll();
1495 1526
1496 browser_process_->metrics_service()->Stop(); 1527 browser_process_->metrics_service()->Stop();
1497 1528
1498 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop(); 1529 restart_last_session_ = browser_shutdown::ShutdownPreThreadsStop();
1499 browser_process_->StartTearDown(); 1530 browser_process_->StartTearDown();
1500 #endif 1531 #endif
1501 } 1532 }
1502 1533
1503 void ChromeBrowserMainParts::PostDestroyThreads() { 1534 void ChromeBrowserMainParts::PostDestroyThreads() {
1535 #if defined(OS_ANDROID)
1536 // On Android, there is no quit/exit. So the browser's main message loop will
1537 // not finish.
1538 NOTREACHED();
1539 #else
1504 browser_process_->PostDestroyThreads(); 1540 browser_process_->PostDestroyThreads();
1505 // browser_shutdown takes care of deleting browser_process, so we need to 1541 // browser_shutdown takes care of deleting browser_process, so we need to
1506 // release it. 1542 // release it.
1507 ignore_result(browser_process_.release()); 1543 ignore_result(browser_process_.release());
1508 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_); 1544 browser_shutdown::ShutdownPostThreadsStop(restart_last_session_);
1509 master_prefs_.reset(); 1545 master_prefs_.reset();
1510 process_singleton_.reset(); 1546 process_singleton_.reset();
1511 1547
1512 // We need to do this check as late as possible, but due to modularity, this 1548 // We need to do this check as late as possible, but due to modularity, this
1513 // may be the last point in Chrome. This would be more effective if done at 1549 // may be the last point in Chrome. This would be more effective if done at
1514 // a higher level on the stack, so that it is impossible for an early return 1550 // a higher level on the stack, so that it is impossible for an early return
1515 // to bypass this code. Perhaps we need a *final* hook that is called on all 1551 // to bypass this code. Perhaps we need a *final* hook that is called on all
1516 // paths from content/browser/browser_main. 1552 // paths from content/browser/browser_main.
1517 CHECK(MetricsService::UmaMetricsProperlyShutdown()); 1553 CHECK(MetricsService::UmaMetricsProperlyShutdown());
1554 #endif
1518 } 1555 }
1519 1556
1520 // Public members: 1557 // Public members:
1521 1558
1522 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 1559 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
1523 chrome_extra_parts_.push_back(parts); 1560 chrome_extra_parts_.push_back(parts);
1524 } 1561 }
1525 1562
1526 // Misc ------------------------------------------------------------------------ 1563 // Misc ------------------------------------------------------------------------
1527 1564
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 if (base::win::GetVersion() <= base::win::VERSION_XP) 1600 if (base::win::GetVersion() <= base::win::VERSION_XP)
1564 uma_name += "_XP"; 1601 uma_name += "_XP";
1565 1602
1566 uma_name += "_PreRead_"; 1603 uma_name += "_PreRead_";
1567 uma_name += pre_read_percentage; 1604 uma_name += pre_read_percentage;
1568 AddPreReadHistogramTime(uma_name.c_str(), time); 1605 AddPreReadHistogramTime(uma_name.c_str(), time);
1569 } 1606 }
1570 #endif 1607 #endif
1571 #endif 1608 #endif
1572 } 1609 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698