#include "chrome/browser/chrome_browser_main.h"
-#if defined(TOOLKIT_GTK)
-#include <gtk/gtk.h>
-#endif
-
#include <set>
#include <string>
#include <vector>
#include "base/debug/crash_logging.h"
#include "base/debug/debugger.h"
#include "base/debug/trace_event.h"
-#include "base/file_util.h"
#include "base/files/file_path.h"
+#include "base/files/file_util.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "base/prefs/pref_value_store.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/process/process_info.h"
+#include "base/profiler/scoped_tracker.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "chrome/browser/browser_process_platform_part.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"
-#include "chrome/browser/component_updater/component_updater_service.h"
+#include "chrome/browser/component_updater/cld_component_installer.h"
+#include "chrome/browser/component_updater/ev_whitelist_component_installer.h"
#include "chrome/browser/component_updater/flash_component_installer.h"
-#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
#include "chrome/browser/component_updater/recovery_component_installer.h"
#include "chrome/browser/component_updater/swiftshader_component_installer.h"
#include "chrome/browser/component_updater/widevine_cdm_component_installer.h"
#include "chrome/browser/defaults.h"
-#include "chrome/browser/extensions/extension_protocols.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/startup_helper.h"
-#include "chrome/browser/feedback/feedback_profile_observer.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/first_run/upgrade_util.h"
#include "chrome/browser/google/google_search_counter.h"
-#include "chrome/browser/google/google_util.h"
#include "chrome/browser/gpu/gl_string_manager.h"
-#include "chrome/browser/jankometer.h"
+#include "chrome/browser/gpu/three_d_api_observer.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/metrics/field_trial_synchronizer.h"
-#include "chrome/browser/metrics/metrics_log.h"
-#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/metrics/thread_watcher.h"
-#include "chrome/browser/metrics/tracking_synchronizer.h"
-#include "chrome/browser/metrics/variations/variations_http_header_provider.h"
#include "chrome/browser/metrics/variations/variations_service.h"
#include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
#include "chrome/browser/net/chrome_net_log.h"
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/desktop_notification_service_factory.h"
#include "chrome/browser/performance_monitor/performance_monitor.h"
-#include "chrome/browser/performance_monitor/startup_timer.h"
#include "chrome/browser/plugins/plugin_prefs.h"
+#include "chrome/browser/power/process_power_collector.h"
#include "chrome/browser/pref_service_flags_storage.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include "chrome/browser/prefs/command_line_pref_store.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/shell_integration.h"
-#include "chrome/browser/three_d_api_observer.h"
#include "chrome/browser/translate/translate_service.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_version_info.h"
#include "chrome/common/crash_keys.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/net/net_resource_provider.h"
#include "chrome/common/pref_names.h"
-#include "chrome/common/profile_management_switches.h"
#include "chrome/common/profiling.h"
+#include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h"
+#include "components/component_updater/component_updater_service.h"
+#include "components/google/core/browser/google_util.h"
#include "components/language_usage_metrics/language_usage_metrics.h"
+#include "components/metrics/metrics_service.h"
+#include "components/metrics/profiler/tracking_synchronizer.h"
#include "components/nacl/browser/nacl_browser.h"
-#include "components/nacl/browser/nacl_process_host.h"
#include "components/rappor/rappor_service.h"
+#include "components/signin/core/common/profile_management_switches.h"
#include "components/startup_metric_utils/startup_metric_utils.h"
+#include "components/translate/content/common/cld_data_source.h"
#include "components/translate/core/browser/translate_download_manager.h"
+#include "components/variations/net/variations_http_header_provider.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
-#include "extensions/browser/extension_system.h"
-#include "grit/app_locale_settings.h"
-#include "grit/browser_resources.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
#include "grit/platform_locale_settings.h"
#include "net/base/net_module.h"
#include "net/base/sdch_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/strings/grit/app_locale_settings.h"
+
+#if defined(OS_ANDROID)
+#include "chrome/browser/metrics/thread_watcher_android.h"
+#else
+#include "chrome/browser/feedback/feedback_profile_observer.h"
+#endif
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
#include "chrome/browser/first_run/upgrade_util_linux.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_util_win.h"
#include "chrome/browser/chrome_browser_main_win.h"
+#include "chrome/browser/chrome_select_file_dialog_factory_win.h"
+#include "chrome/browser/component_updater/sw_reporter_installer_win.h"
#include "chrome/browser/first_run/try_chrome_dialog_view.h"
#include "chrome/browser/first_run/upgrade_util_win.h"
#include "chrome/browser/ui/network_profile_bubble.h"
-#include "chrome/common/net/url_fixer_upper.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/shell_util.h"
#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/gfx/win/dpi.h"
+#include "ui/shell_dialogs/select_file_dialog.h"
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
#include "chrome/browser/mac/keystone_glue.h"
#endif
-#if defined(ENABLE_FULL_PRINTING) && !defined(OFFICIAL_BUILD)
+#if !defined(OS_IOS)
+#include "chrome/browser/ui/app_modal_dialogs/chrome_javascript_native_dialog_factory.h"
+#endif
+
+#if !defined(DISABLE_NACL)
+#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
+#include "components/nacl/browser/nacl_process_host.h"
+#endif
+
+#if defined(ENABLE_EXTENSIONS)
+#include "chrome/browser/extensions/startup_helper.h"
+#include "extensions/browser/extension_protocols.h"
+#include "extensions/components/javascript_dialog_extensions_client/javascript_dialog_extension_client_impl.h"
+#endif
+
+#if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
#include "printing/printed_document.h"
#endif
#else
base::FilePath profile_path =
GetStartupProfilePath(user_data_dir, parsed_command_line);
+
+ // Without NewAvatarMenu, replace guest with any existing profile.
+ if (!switches::IsNewAvatarMenu() &&
+ profile_path == ProfileManager::GetGuestProfilePath()) {
+ profile_path = g_browser_process->profile_manager()->GetProfileInfoCache().
+ GetPathOfProfileAtIndex(0);
+ }
profile = g_browser_process->profile_manager()->GetProfile(
profile_path);
}
#endif
-void RegisterComponentsForUpdate(const CommandLine& command_line) {
+void RegisterComponentsForUpdate() {
component_updater::ComponentUpdateService* cus =
g_browser_process->component_updater();
RegisterRecoveryComponent(cus, g_browser_process->local_state());
RegisterPepperFlashComponent(cus);
RegisterSwiftShaderComponent(cus);
+ RegisterWidevineCdmComponent(cus);
#endif
-#if !defined(OS_ANDROID)
- g_browser_process->pnacl_component_installer()->RegisterPnaclComponent(
- cus, command_line);
+#if !defined(DISABLE_NACL) && !defined(OS_ANDROID)
+#if defined(OS_CHROMEOS)
+ // PNaCl on Chrome OS is on rootfs and there is no need to download it. But
+ // Chrome4ChromeOS on Linux doesn't contain PNaCl so enable component
+ // installer when ruining on Linux. See crbug.com/422121 for more details.
+ if (!base::SysInfo::IsRunningOnChromeOS())
+#endif
+ g_browser_process->pnacl_component_installer()->RegisterPnaclComponent(cus);
#endif
-#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
- RegisterWidevineCdmComponent(cus);
+ if (translate::CldDataSource::ShouldRegisterForComponentUpdates()) {
+ RegisterCldComponent(cus);
+ }
+
+ base::FilePath path;
+ if (PathService::Get(chrome::DIR_USER_DATA, &path)) {
+#if defined(OS_ANDROID)
+ // The CRLSet component was enabled for some releases. This code attempts to
+ // delete it from the local disk of those how may have downloaded it.
+ g_browser_process->crl_set_fetcher()->DeleteFromDisk(path);
+#elif !defined(OS_CHROMEOS)
+ // CRLSetFetcher attempts to load a CRL set from either the local disk or
+ // network.
+ // For Chrome OS this registration is delayed until user login.
+ g_browser_process->crl_set_fetcher()->StartInitialLoad(cus, path);
#endif
+ }
-#if !defined(OS_CHROMEOS)
- // CRLSetFetcher attempts to load a CRL set from either the local disk or
- // network.
- if (!command_line.HasSwitch(switches::kDisableCRLSets))
- g_browser_process->crl_set_fetcher()->StartInitialLoad(cus);
+#if !defined(OS_ANDROID)
+ // Android does not currently have the EV indicator. No need to get the
+ // EV certs whitelist on Android, then.
+ RegisterEVWhitelistComponent(cus);
+#endif
+
+#if defined(OS_WIN)
+ RegisterSwReporterComponent(cus, g_browser_process->local_state());
#endif
cus->Start();
g_browser_process->platform_part()->PlatformSpecificCommandLineProcessing(
command_line);
- // TODO(erikwright): Consider removing this - AFAIK it is no longer used.
- // Handle the --uninstall-extension startup action. This needs to done here in
- // the process that is running with the target profile, otherwise the
- // uninstall will fail to unload and remove all components.
- if (command_line.HasSwitch(switches::kUninstallExtension)) {
- // The uninstall extension switch can't be combined with the profile
- // directory switch.
- DCHECK(!command_line.HasSwitch(switches::kProfileDirectory));
-
- Profile* profile = ProfileManager::GetLastUsedProfile();
- if (!profile) {
- // We should never be called before the profile has been created.
- NOTREACHED();
- return true;
- }
-
- extensions::StartupHelper extension_startup_helper;
- extension_startup_helper.UninstallExtension(command_line, profile);
- return true;
- }
-
base::FilePath user_data_dir =
g_browser_process->profile_manager()->user_data_dir();
base::FilePath startup_profile_dir =
std::string port_str =
command_line.GetSwitchValueASCII(::switches::kRemoteDebuggingPort);
int port;
- if (base::StringToInt(port_str, &port) && port > 0 && port < 65535) {
+ if (base::StringToInt(port_str, &port) && port >= 0 && port < 65535) {
g_browser_process->CreateDevToolsHttpProtocolHandler(
chrome::HOST_DESKTOP_TYPE_NATIVE,
"127.0.0.1",
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::NotificationService::AllSources());
}
- virtual ~LoadCompleteListener() {}
+ ~LoadCompleteListener() override {}
// content::NotificationObserver implementation.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE {
+ void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) override {
DCHECK_EQ(content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, type);
startup_metric_utils::OnInitialPageLoadComplete();
delete this;
const char kMissingLocaleDataTitle[] = "Missing File Error";
#endif
-#if defined(OS_WIN) || defined(TOOLKIT_GTK)
+#if defined(OS_WIN)
// TODO(port) This should be used on Linux Aura as well. http://crbug.com/338969
const char kMissingLocaleDataMessage[] =
"Unable to find locale data files. Please reinstall.";
result_code_(content::RESULT_CODE_NORMAL_EXIT),
startup_watcher_(new StartupTimeBomb()),
shutdown_watcher_(new ShutdownWatcherHelper()),
- startup_timer_(new performance_monitor::StartupTimer()),
browser_field_trials_(parameters.command_line),
profile_(NULL),
run_message_loop_(true),
// Must initialize metrics after labs have been converted into switches,
// but before field trials are set up (so that client ID is available for
// one-time randomized field trials).
-#if defined(ARCH_CPU_64_BITS)
- MetricsLog::set_version_extension("-64");
-#endif // defined(ARCH_CPU_64_BITS)
// Initialize FieldTrialList to support FieldTrials that use one-time
// randomization.
- MetricsService* metrics = browser_process_->metrics_service();
- MetricsService::ReportingState reporting_state =
- IsMetricsReportingEnabled() ? MetricsService::REPORTING_ENABLED :
- MetricsService::REPORTING_DISABLED;
- if (reporting_state == MetricsService::REPORTING_ENABLED)
- metrics->ForceClientIdCreation(); // Needed below.
+ metrics::MetricsService* metrics = browser_process_->metrics_service();
field_trial_list_.reset(
- new base::FieldTrialList(
- metrics->CreateEntropyProvider(reporting_state).release()));
+ new base::FieldTrialList(metrics->CreateEntropyProvider().release()));
const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableBenchmarking))
base::FieldTrial::EnableBenchmarking();
// Ensure any field trials specified on the command line are initialized.
- // Also stop the metrics service so that we don't pollute UMA.
if (command_line->HasSwitch(switches::kForceFieldTrials)) {
std::set<std::string> unforceable_field_trials;
#if defined(OFFICIAL_BUILD)
if (command_line->HasSwitch(switches::kForceVariationIds)) {
// Create default variation ids which will always be included in the
// X-Client-Data request header.
- chrome_variations::VariationsHttpHeaderProvider* provider =
- chrome_variations::VariationsHttpHeaderProvider::GetInstance();
+ variations::VariationsHttpHeaderProvider* provider =
+ variations::VariationsHttpHeaderProvider::GetInstance();
bool result = provider->SetDefaultVariationIds(
command_line->GetSwitchValueASCII(switches::kForceVariationIds));
CHECK(result) << "Invalid --" << switches::kForceVariationIds
<< " list specified.";
+ metrics->AddSyntheticTrialObserver(provider);
}
chrome_variations::VariationsService* variations_service =
browser_process_->variations_service();
if (variations_service)
variations_service->CreateTrialsFromSeed();
- // This must be called after the local state is initialized.
- browser_field_trials_.SetupFieldTrials(local_state_);
+ // This must be called after |local_state_| is initialized.
+ browser_field_trials_.SetupFieldTrials(
+ base::Time::FromTimeT(metrics->GetInstallDate()), local_state_);
// Initialize FieldTrialSynchronizer system. This is a singleton and is used
// for posting tasks via base::Bind. Its deleted when it goes out of scope.
field_trial_synchronizer_ = new FieldTrialSynchronizer();
// Now that field trials have been created, initializes metrics recording.
- metrics->InitializeMetricsRecordingState(reporting_state);
+ metrics->InitializeMetricsRecordingState();
+
+ // Enable profiler instrumentation depending on the channel.
+ switch (chrome::VersionInfo::GetChannel()) {
+ case chrome::VersionInfo::CHANNEL_UNKNOWN:
+ case chrome::VersionInfo::CHANNEL_CANARY:
+ tracked_objects::ScopedTracker::Enable();
+ break;
+
+ case chrome::VersionInfo::CHANNEL_DEV:
+ case chrome::VersionInfo::CHANNEL_BETA:
+ case chrome::VersionInfo::CHANNEL_STABLE:
+ // Don't enable instrumentation.
+ break;
+ }
}
// ChromeBrowserMainParts: |SetupMetricsAndFieldTrials()| related --------------
void ChromeBrowserMainParts::StartMetricsRecording() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::StartMetricsRecording");
- MetricsService* metrics = g_browser_process->metrics_service();
+ metrics::MetricsService* metrics = g_browser_process->metrics_service();
const bool only_do_metrics_recording =
parsed_command_line_.HasSwitch(switches::kMetricsRecordingOnly) ||
return;
}
- metrics->CheckForClonedInstall();
-
- if (IsMetricsReportingEnabled())
- metrics->Start();
-}
-
-bool ChromeBrowserMainParts::IsMetricsReportingEnabled() {
- // If the user permits metrics reporting with the checkbox in the
- // prefs, we turn on recording. We disable metrics completely for
- // non-official builds. This can be forced with a flag.
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kEnableMetricsReportingForTesting))
- return true;
-
- bool enabled = false;
- // The debug build doesn't send UMA logs when FieldTrials are forced.
- if (command_line->HasSwitch(switches::kForceFieldTrials))
- return false;
-
-#if defined(GOOGLE_CHROME_BUILD)
-#if defined(OS_CHROMEOS)
- chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref,
- &enabled);
-#else
- enabled = local_state_->GetBoolean(prefs::kMetricsReportingEnabled);
-#endif // #if defined(OS_CHROMEOS)
-#endif // defined(GOOGLE_CHROME_BUILD)
- return enabled;
+ metrics->CheckForClonedInstall(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+ const bool metrics_enabled = metrics->StartIfMetricsReportingEnabled();
+ // TODO(asvitkine): Since this function is not run on Android, RAPPOR is
+ // currently disabled there. http://crbug.com/370041
+ browser_process_->rappor_service()->Start(
+ browser_process_->system_request_context(),
+ metrics_enabled);
}
void ChromeBrowserMainParts::RecordBrowserStartupTime() {
TRACE_EVENT_BEGIN0("startup",
"ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle");
const std::string loaded_locale =
- ResourceBundle::InitSharedInstanceWithLocale(locale, NULL);
+ ui::ResourceBundle::InitSharedInstanceWithLocale(
+ locale, NULL, ui::ResourceBundle::LOAD_COMMON_RESOURCES);
TRACE_EVENT_END0("startup",
"ChromeBrowserMainParts::PreCreateThreadsImpl:InitResourceBundle");
}
#endif // defined(OS_MACOSX)
-#if defined(TOOLKIT_GTK)
- g_set_application_name(l10n_util::GetStringUTF8(IDS_PRODUCT_NAME).c_str());
-#endif
-
// Android does first run in Java instead of native.
// Chrome OS has its own out-of-box-experience code.
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
// TODO(macourteau): refactor preferences that are copied from
// master_preferences into local_state, as a "local_state" section in
- // master preferences. If possible, a generic solution would be prefered
+ // master preferences. If possible, a generic solution would be preferred
// over a copy one-by-one of specific preferences. Also see related TODO
// in first_run.h.
#endif
// Initialize tracking synchronizer system.
- tracking_synchronizer_ = new chrome_browser_metrics::TrackingSynchronizer();
-
- // Now that all preferences have been registered, set the install date
- // for the uninstall metrics if this is our first run. This only actually
- // gets used if the user has metrics reporting enabled at uninstall time.
- int64 install_date = local_state_->GetInt64(prefs::kInstallDate);
- if (install_date == 0)
- local_state_->SetInt64(prefs::kInstallDate, base::Time::Now().ToTimeT());
+ tracking_synchronizer_ = new metrics::TrackingSynchronizer();
#if defined(OS_MACOSX)
// Get the Keychain API to register for distributed notifications on the main
void ChromeBrowserMainParts::PreProfileInit() {
TRACE_EVENT0("startup", "ChromeBrowserMainParts::PreProfileInit");
- // Initialize the feedback uploader so it can setup notifications for profile
- // creation.
- feedback::FeedbackProfileObserver::Initialize();
-
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PreProfileInit();
#if !defined(OS_ANDROID)
+ // Initialize the feedback uploader so it can setup notifications for profile
+ // creation.
+ feedback::FeedbackProfileObserver::Initialize();
+
ProfileManager* profile_manager = g_browser_process->profile_manager();
// First check if any ephemeral profiles are left behind because of browser
ProfileInfoCache& profile_cache = profile_manager->GetProfileInfoCache();
size_t profiles_count = profile_cache.GetNumberOfProfiles();
std::vector<base::FilePath> profiles_to_delete;
- for (size_t i = 0;i < profiles_count; ++i) {
+ for (size_t i = 0; i < profiles_count; ++i) {
if (profile_cache.ProfileIsEphemeralAtIndex(i))
profiles_to_delete.push_back(profile_cache.GetPathOfProfileAtIndex(i));
}
if (profiles_to_delete.size()) {
- for (size_t i = 0;i < profiles_to_delete.size(); ++i) {
+ for (size_t i = 0; i < profiles_to_delete.size(); ++i) {
profile_manager->ScheduleProfileForDeletion(
profiles_to_delete[i], ProfileManager::CreateCallback());
}
base::Bind(&ProfileManager::CleanUpStaleProfiles, profiles_to_delete));
}
#endif // OS_ANDROID
+
+#if defined(ENABLE_EXTENSIONS)
+ InstallJavaScriptDialogExtensionsClient();
+#endif
+
+#if !defined(OS_IOS)
+ InstallChromeJavaScriptNativeDialogFactory();
+#endif
}
void ChromeBrowserMainParts::PostProfileInit() {
StartMetricsRecording();
#endif
- if (IsMetricsReportingEnabled()) {
- browser_process_->rappor_service()->Start(
- browser_process_->local_state(),
- browser_process_->system_request_context());
+ if (!base::debug::BeingDebugged()) {
+ // Create watchdog thread after creating all other threads because it will
+ // watch the other threads and they must be running.
+ browser_process_->watchdog_thread();
}
- // Create watchdog thread after creating all other threads because it will
- // watch the other threads and they must be running.
- browser_process_->watchdog_thread();
-
// Do any initializating in the browser process that requires all threads
// running.
browser_process_->PreMainMessageLoopRun();
return ChromeBrowserMainPartsWin::HandleIconsCommands(
parsed_command_line_);
}
+
+ ui::SelectFileDialog::SetFactory(new ChromeSelectFileDialogFactory(
+ BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
#endif
if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) {
}
#if defined(USE_AURA)
- // Env creates the compositor. Aura widgets need the compositor to be created
- // before they can be initialized by the browser.
- aura::Env::CreateInstance();
+ // Make sure aura::Env has been initialized.
+ CHECK(aura::Env::GetInstance());
#endif
// Android doesn't support extensions and doesn't implement ProcessSingleton.
// Profile creation ----------------------------------------------------------
- MetricsService::SetExecutionPhase(MetricsService::CREATE_PROFILE);
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::CREATE_PROFILE,
+ g_browser_process->local_state());
profile_ = CreatePrimaryProfile(parameters(),
user_data_dir_,
parsed_command_line());
// NaClBrowserDelegateImpl is accessed inside PostProfileInit().
// So make sure to create it before that.
#if !defined(DISABLE_NACL)
- NaClBrowserDelegateImpl* delegate = new NaClBrowserDelegateImpl(
- extensions::ExtensionSystem::Get(profile_)->info_map());
+ NaClBrowserDelegateImpl* delegate =
+ new NaClBrowserDelegateImpl(browser_process_->profile_manager());
nacl::NaClBrowser::SetDelegate(delegate);
#endif
// Verify that the profile is not on a network share and if so prepare to show
// notification to the user.
if (NetworkProfileBubble::ShouldCheckNetworkProfile(profile_)) {
- content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
+ BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
base::Bind(&NetworkProfileBubble::CheckNetworkProfile,
profile_->GetPath()));
}
browser_process_->intranet_redirect_detector();
GoogleSearchCounter::RegisterForNotifications();
- if (parsed_command_line().HasSwitch(switches::kEnableSdchOverHttps)) {
- net::SdchManager::EnableSecureSchemeSupport(true);
+ // Check SDCH field trial. Default is now that everything is enabled,
+ // so provide options for disabling HTTPS or all of SDCH.
+ const char kSdchFieldTrialName[] = "SDCH";
+ const char kEnabledHttpOnlyGroupName[] = "EnabledHttpOnly";
+ const char kDisabledAllGroupName[] = "DisabledAll";
+
+ // Store in a string on return to keep underlying storage for
+ // StringPiece stable.
+ std::string sdch_trial_group_string =
+ base::FieldTrialList::FindFullName(kSdchFieldTrialName);
+ base::StringPiece sdch_trial_group(sdch_trial_group_string);
+ if (sdch_trial_group.starts_with(kEnabledHttpOnlyGroupName)) {
+ net::SdchManager::EnableSdchSupport(true);
+ net::SdchManager::EnableSecureSchemeSupport(false);
+ } else if (sdch_trial_group.starts_with(kDisabledAllGroupName)) {
+ net::SdchManager::EnableSdchSupport(false);
}
- if (parsed_command_line().HasSwitch(switches::kEnableWatchdog))
- InstallJankometer(parsed_command_line());
-
-#if defined(ENABLE_FULL_PRINTING) && !defined(OFFICIAL_BUILD)
+#if defined(ENABLE_PRINT_PREVIEW) && !defined(OFFICIAL_BUILD)
if (parsed_command_line().HasSwitch(switches::kDebugPrint)) {
base::FilePath path =
parsed_command_line().GetSwitchValuePath(switches::kDebugPrint);
language_usage_metrics::LanguageUsageMetrics::RecordApplicationLanguage(
browser_process_->GetApplicationLocale());
- // The extension service may be available at this point. If the command line
- // specifies --uninstall-extension, attempt the uninstall extension startup
- // action.
- if (parsed_command_line().HasSwitch(switches::kUninstallExtension)) {
- extensions::StartupHelper extension_startup_helper;
- if (extension_startup_helper.UninstallExtension(
- parsed_command_line(), profile_))
- return content::RESULT_CODE_NORMAL_EXIT;
- return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR;
- }
-
// Start watching for hangs during startup. We disarm this hang detector when
// ThreadWatcher takes over or when browser is shutdown or when
// startup_watcher_ is deleted.
- MetricsService::SetExecutionPhase(MetricsService::STARTUP_TIMEBOMB_ARM);
- startup_watcher_->Arm(base::TimeDelta::FromSeconds(300));
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::STARTUP_TIMEBOMB_ARM,
+ g_browser_process->local_state());
+ startup_watcher_->Arm(base::TimeDelta::FromSeconds(600));
// On mobile, need for clean shutdown arises only when the application comes
// to foreground (i.e. MetricsService::OnAppEnterForeground is called).
// http://crbug.com/179143
#if !defined(OS_ANDROID)
// Start watching for a hang.
- MetricsService::LogNeedForCleanShutdown();
+ browser_process_->metrics_service()->LogNeedForCleanShutdown();
#endif
-#if defined(ENABLE_FULL_PRINTING)
+#if defined(ENABLE_PRINT_PREVIEW)
// Create the instance of the cloud print proxy service so that it can launch
// the service process if needed. This is needed because the service process
// might have shutdown because an update was available.
#endif
// Start watching all browser threads for responsiveness.
- MetricsService::SetExecutionPhase(MetricsService::THREAD_WATCHER_START);
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::THREAD_WATCHER_START,
+ g_browser_process->local_state());
ThreadWatcherList::StartWatchingAll(parsed_command_line());
+#if defined(OS_ANDROID)
+ ThreadWatcherAndroid::RegisterApplicationStatusListener();
+#endif
+
#if !defined(DISABLE_NACL)
- content::BrowserThread::PostTask(
- content::BrowserThread::IO,
+ BrowserThread::PostTask(
+ BrowserThread::IO,
FROM_HERE,
base::Bind(nacl::NaClProcessHost::EarlyStartup));
#endif
browser_process_->notification_ui_manager();
if (!parsed_command_line().HasSwitch(switches::kDisableComponentUpdate))
- RegisterComponentsForUpdate(parsed_command_line());
+ RegisterComponentsForUpdate();
#if defined(OS_ANDROID)
chrome_variations::VariationsService* variations_service =
variations_service->set_policy_pref_service(profile_->GetPrefs());
variations_service->StartRepeatedVariationsSeedFetch();
}
- TranslateDownloadManager::RequestLanguageList(profile_->GetPrefs());
+ translate::TranslateDownloadManager::RequestLanguageList(
+ profile_->GetPrefs());
#else
// Most general initialization is behind us, but opening a
#endif
}
- TranslateDownloadManager::RequestLanguageList(profile_->GetPrefs());
+ translate::TranslateDownloadManager::RequestLanguageList(
+ profile_->GetPrefs());
}
run_message_loop_ = true;
run_message_loop_ = false;
}
browser_creator_.reset();
-#endif // !defined(OS_ANDROID)
- performance_monitor::PerformanceMonitor::GetInstance()->Initialize();
+ process_power_collector_.reset(new ProcessPowerCollector);
+ process_power_collector_->Initialize();
+#endif // !defined(OS_ANDROID)
PostBrowserStart();
- chrome_prefs::SchedulePrefHashStoresUpdateCheck(profile_->GetPath());
-
if (parameters().ui_task) {
- // We end the startup timer here if we have parameters to run, because we
- // never start to run the main loop (where we normally stop the timer).
- startup_timer_->SignalStartupComplete(
- performance_monitor::StartupTimer::STARTUP_TEST);
parameters().ui_task->Run();
delete parameters().ui_task;
run_message_loop_ = false;
// UI thread message loop as possible to get a stable measurement
// across versions.
RecordBrowserStartupTime();
- startup_timer_->SignalStartupComplete(
- performance_monitor::StartupTimer::STARTUP_NORMAL);
DCHECK(base::MessageLoopForUI::IsCurrent());
base::RunLoop run_loop;
performance_monitor::PerformanceMonitor::GetInstance()->StartGatherCycle();
- MetricsService::SetExecutionPhase(MetricsService::MAIN_MESSAGE_LOOP_RUN);
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::MAIN_MESSAGE_LOOP_RUN,
+ g_browser_process->local_state());
run_loop.Run();
return true;
// Start watching for jank during shutdown. It gets disarmed when
// |shutdown_watcher_| object is destructed.
- MetricsService::SetExecutionPhase(MetricsService::SHUTDOWN_TIMEBOMB_ARM);
+ metrics::MetricsService::SetExecutionPhase(
+ metrics::MetricsService::SHUTDOWN_TIMEBOMB_ARM,
+ g_browser_process->local_state());
shutdown_watcher_->Arm(base::TimeDelta::FromSeconds(300));
// Disarm the startup hang detector time bomb if it is still Arm'ed.
startup_watcher_->Disarm();
+ // Remove observers attached to D-Bus clients before DbusThreadManager is
+ // shut down.
+ process_power_collector_.reset();
+
for (size_t i = 0; i < chrome_extra_parts_.size(); ++i)
chrome_extra_parts_[i]->PostMainMessageLoopRun();
// a higher level on the stack, so that it is impossible for an early return
// to bypass this code. Perhaps we need a *final* hook that is called on all
// paths from content/browser/browser_main.
- CHECK(MetricsService::UmaMetricsProperlyShutdown());
+ CHECK(metrics::MetricsService::UmaMetricsProperlyShutdown());
#if defined(OS_CHROMEOS)
chromeos::CrosSettings::Shutdown();