| 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 13 matching lines...) Expand all Loading... |
| 24 #include "base/prefs/json_pref_store.h" | 24 #include "base/prefs/json_pref_store.h" |
| 25 #include "base/process_info.h" | 25 #include "base/process_info.h" |
| 26 #include "base/process_util.h" | 26 #include "base/process_util.h" |
| 27 #include "base/run_loop.h" | 27 #include "base/run_loop.h" |
| 28 #include "base/string_number_conversions.h" | 28 #include "base/string_number_conversions.h" |
| 29 #include "base/string_piece.h" | 29 #include "base/string_piece.h" |
| 30 #include "base/string_split.h" | 30 #include "base/string_split.h" |
| 31 #include "base/sys_info.h" | 31 #include "base/sys_info.h" |
| 32 #include "base/sys_string_conversions.h" | 32 #include "base/sys_string_conversions.h" |
| 33 #include "base/threading/platform_thread.h" | 33 #include "base/threading/platform_thread.h" |
| 34 #include "base/threading/sequenced_worker_pool.h" | |
| 35 #include "base/time.h" | 34 #include "base/time.h" |
| 36 #include "base/utf_string_conversions.h" | 35 #include "base/utf_string_conversions.h" |
| 37 #include "base/values.h" | 36 #include "base/values.h" |
| 38 #include "build/build_config.h" | 37 #include "build/build_config.h" |
| 39 #include "chrome/browser/about_flags.h" | 38 #include "chrome/browser/about_flags.h" |
| 40 #include "chrome/browser/browser_process.h" | 39 #include "chrome/browser/browser_process.h" |
| 41 #include "chrome/browser/browser_process_impl.h" | 40 #include "chrome/browser/browser_process_impl.h" |
| 42 #include "chrome/browser/browser_shutdown.h" | 41 #include "chrome/browser/browser_shutdown.h" |
| 43 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 42 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
| 44 #include "chrome/browser/chrome_gpu_util.h" | 43 #include "chrome/browser/chrome_gpu_util.h" |
| (...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 chrome_extra_parts_[i]->PreMainMessageLoopRun(); | 939 chrome_extra_parts_[i]->PreMainMessageLoopRun(); |
| 941 } | 940 } |
| 942 | 941 |
| 943 // PreMainMessageLoopRun calls these extra stages in the following order: | 942 // PreMainMessageLoopRun calls these extra stages in the following order: |
| 944 // PreMainMessageLoopRunImpl() | 943 // PreMainMessageLoopRunImpl() |
| 945 // ... initial setup, including browser_process_ setup. | 944 // ... initial setup, including browser_process_ setup. |
| 946 // PreProfileInit() | 945 // PreProfileInit() |
| 947 // ... additional setup, including CreateProfile() | 946 // ... additional setup, including CreateProfile() |
| 948 // PostProfileInit() | 947 // PostProfileInit() |
| 949 // ... additional setup | 948 // ... additional setup |
| 949 // PreInteractiveFirstRunInit() |
| 950 // ... first_run::AutoImport() |
| 951 // PostInteractiveFirstRunInit() |
| 952 // ... additional setup |
| 950 // PreBrowserStart() | 953 // PreBrowserStart() |
| 951 // ... browser_creator_->Start (OR parameters().ui_task->Run()) | 954 // ... browser_creator_->Start (OR parameters().ui_task->Run()) |
| 952 // PostBrowserStart() | 955 // PostBrowserStart() |
| 953 | 956 |
| 954 void ChromeBrowserMainParts::PreProfileInit() { | 957 void ChromeBrowserMainParts::PreProfileInit() { |
| 955 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 958 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 956 chrome_extra_parts_[i]->PreProfileInit(); | 959 chrome_extra_parts_[i]->PreProfileInit(); |
| 957 } | 960 } |
| 958 | 961 |
| 959 void ChromeBrowserMainParts::PostProfileInit() { | 962 void ChromeBrowserMainParts::PostProfileInit() { |
| 960 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 963 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 961 chrome_extra_parts_[i]->PostProfileInit(); | 964 chrome_extra_parts_[i]->PostProfileInit(); |
| 962 } | 965 } |
| 963 | 966 |
| 967 void ChromeBrowserMainParts::PreInteractiveFirstRunInit() { |
| 968 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 969 chrome_extra_parts_[i]->PreInteractiveFirstRunInit(); |
| 970 } |
| 971 |
| 972 void ChromeBrowserMainParts::PostInteractiveFirstRunInit() { |
| 973 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 974 chrome_extra_parts_[i]->PostInteractiveFirstRunInit(); |
| 975 } |
| 976 |
| 964 void ChromeBrowserMainParts::PreBrowserStart() { | 977 void ChromeBrowserMainParts::PreBrowserStart() { |
| 965 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) | 978 for (size_t i = 0; i < chrome_extra_parts_.size(); ++i) |
| 966 chrome_extra_parts_[i]->PreBrowserStart(); | 979 chrome_extra_parts_[i]->PreBrowserStart(); |
| 967 #if !defined(OS_ANDROID) | 980 #if !defined(OS_ANDROID) |
| 968 gpu_util::InstallBrowserMonitor(); | 981 gpu_util::InstallBrowserMonitor(); |
| 969 #endif | 982 #endif |
| 970 } | 983 } |
| 971 | 984 |
| 972 void ChromeBrowserMainParts::PostBrowserStart() { | 985 void ChromeBrowserMainParts::PostBrowserStart() { |
| 973 #if !defined(OS_ANDROID) | 986 #if !defined(OS_ANDROID) |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 // (requires supporting early exit). | 1202 // (requires supporting early exit). |
| 1190 PostProfileInit(); | 1203 PostProfileInit(); |
| 1191 | 1204 |
| 1192 #if !defined(OS_ANDROID) | 1205 #if !defined(OS_ANDROID) |
| 1193 // Show the First Run UI if this is the first time Chrome has been run on | 1206 // Show the First Run UI if this is the first time Chrome has been run on |
| 1194 // this computer, or we're being compelled to do so by a command line flag. | 1207 // this computer, or we're being compelled to do so by a command line flag. |
| 1195 // Note that this be done _after_ the PrefService is initialized and all | 1208 // Note that this be done _after_ the PrefService is initialized and all |
| 1196 // preferences are registered, since some of the code that the importer | 1209 // preferences are registered, since some of the code that the importer |
| 1197 // touches reads preferences. | 1210 // touches reads preferences. |
| 1198 if (is_first_run_) { | 1211 if (is_first_run_) { |
| 1199 #if defined(OS_WIN) | 1212 PreInteractiveFirstRunInit(); |
| 1200 // On Windows, trigger the Active Setup command for system-level Chromes to | 1213 |
| 1201 // finish configuring this user's install (e.g. per-user shortcuts). | |
| 1202 // Delay the task slightly to give Chrome launch I/O priority while also | |
| 1203 // making sure shortcuts are created promptly to avoid annoying the user by | |
| 1204 // re-creating shortcuts he previously deleted. | |
| 1205 // TODO(gab): Add a first run section to ChromeBrowserMainParts and remove | |
| 1206 // OS specific sections below. | |
| 1207 static const int64 kTiggerActiveSetupDelaySeconds = 5; | |
| 1208 FilePath chrome_exe; | |
| 1209 if (!PathService::Get(base::FILE_EXE, &chrome_exe)) { | |
| 1210 NOTREACHED(); | |
| 1211 } else if (!InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { | |
| 1212 BrowserThread::GetBlockingPool()->PostDelayedTask( | |
| 1213 FROM_HERE, | |
| 1214 base::Bind(&InstallUtil::TriggerActiveSetupCommand), | |
| 1215 base::TimeDelta::FromSeconds(kTiggerActiveSetupDelaySeconds)); | |
| 1216 } | |
| 1217 #endif // OS_WIN | |
| 1218 if (!first_run_ui_bypass_) { | 1214 if (!first_run_ui_bypass_) { |
| 1219 first_run::AutoImport(profile_, | 1215 first_run::AutoImport(profile_, |
| 1220 master_prefs_->homepage_defined, | 1216 master_prefs_->homepage_defined, |
| 1221 master_prefs_->do_import_items, | 1217 master_prefs_->do_import_items, |
| 1222 master_prefs_->dont_import_items, | 1218 master_prefs_->dont_import_items, |
| 1223 master_prefs_->make_chrome_default, | 1219 master_prefs_->make_chrome_default, |
| 1224 process_singleton_.get()); | 1220 process_singleton_.get()); |
| 1225 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) | 1221 #if defined(OS_POSIX) && !defined(OS_CHROMEOS) |
| 1222 // TODO(thakis): Look into moving this POSIX-specific section to |
| 1223 // ChromeBrowserMainPartsPosix::PostInteractiveFirstRunInit(). |
| 1224 |
| 1226 // On Windows, the download is tagged with enable/disable stats so there | 1225 // On Windows, the download is tagged with enable/disable stats so there |
| 1227 // is no need for this code. | 1226 // is no need for this code. |
| 1228 | 1227 |
| 1229 // If stats reporting was turned on by the first run dialog then toggle | 1228 // If stats reporting was turned on by the first run dialog then toggle |
| 1230 // the pref. | 1229 // the pref. |
| 1231 if (GoogleUpdateSettings::GetCollectStatsConsent()) | 1230 if (GoogleUpdateSettings::GetCollectStatsConsent()) |
| 1232 local_state_->SetBoolean(prefs::kMetricsReportingEnabled, true); | 1231 local_state_->SetBoolean(prefs::kMetricsReportingEnabled, true); |
| 1233 #endif // OS_POSIX && !OS_CHROMEOS | 1232 #endif // OS_POSIX && !OS_CHROMEOS |
| 1234 } // if (!first_run_ui_bypass_) | 1233 } // if (!first_run_ui_bypass_) |
| 1234 PostInteractiveFirstRunInit(); |
| 1235 | 1235 |
| 1236 browser_process_->profile_manager()->OnImportFinished(profile_); | 1236 browser_process_->profile_manager()->OnImportFinished(profile_); |
| 1237 | 1237 |
| 1238 if (!master_prefs_->suppress_first_run_default_browser_prompt) { | 1238 if (!master_prefs_->suppress_first_run_default_browser_prompt) { |
| 1239 browser_creator_->set_show_main_browser_window( | 1239 browser_creator_->set_show_main_browser_window( |
| 1240 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); | 1240 !chrome::ShowFirstRunDefaultBrowserPrompt(profile_)); |
| 1241 } else { | 1241 } else { |
| 1242 browser_creator_->set_is_default_browser_dialog_suppressed(true); | 1242 browser_creator_->set_is_default_browser_dialog_suppressed(true); |
| 1243 } | 1243 } |
| 1244 } // if (is_first_run_) | 1244 } // if (is_first_run_) |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 if (base::win::GetVersion() <= base::win::VERSION_XP) | 1720 if (base::win::GetVersion() <= base::win::VERSION_XP) |
| 1721 uma_name += "_XP"; | 1721 uma_name += "_XP"; |
| 1722 | 1722 |
| 1723 uma_name += "_PreRead_"; | 1723 uma_name += "_PreRead_"; |
| 1724 uma_name += pre_read_percentage; | 1724 uma_name += pre_read_percentage; |
| 1725 AddPreReadHistogramTime(uma_name.c_str(), time); | 1725 AddPreReadHistogramTime(uma_name.c_str(), time); |
| 1726 } | 1726 } |
| 1727 #endif | 1727 #endif |
| 1728 #endif | 1728 #endif |
| 1729 } | 1729 } |
| OLD | NEW |