blob: 8bb86dc4d0a0b3d03f4fbcbfdbe7976c439a1ba5 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/chrome/browser/prefs/browser_prefs.h"
#include "components/autofill/core/browser/autofill_manager.h"
#include "components/browsing_data/core/pref_names.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/flags_ui/pref_service_flags_storage.h"
#include "components/gcm_driver/gcm_channel_status_syncer.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/network_time/network_time_tracker.h"
#include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h"
#include "components/ntp_snippets/content_suggestions_service.h"
#include "components/ntp_snippets/remote/remote_suggestions_provider.h"
#include "components/ntp_tiles/most_visited_sites.h"
#include "components/ntp_tiles/popular_sites.h"
#include "components/omnibox/browser/zero_suggest_provider.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/proxy_config/pref_proxy_config_tracker_impl.h"
#include "components/rappor/rappor_service.h"
#include "components/search_engines/template_url_prepopulate_data.h"
#include "components/signin/core/common/signin_pref_names.h"
#include "components/ssl_config/ssl_config_service_manager.h"
#include "components/strings/grit/components_locale_settings.h"
#include "components/sync/base/sync_prefs.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/common/translate_pref_names.h"
#include "components/update_client/update_client.h"
#include "components/variations/service/variations_service.h"
#include "components/web_resource/web_resource_pref_names.h"
#include "ios/chrome/browser/browser_state/browser_state_info_cache.h"
#include "ios/chrome/browser/first_run/first_run.h"
#import "ios/chrome/browser/geolocation/omnibox_geolocation_local_state.h"
#import "ios/chrome/browser/memory/memory_debugger_manager.h"
#import "ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h"
#include "ios/chrome/browser/net/http_server_properties_manager_factory.h"
#include "ios/chrome/browser/notification_promo.h"
#include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/signin/signin_manager_factory.h"
#include "ios/chrome/browser/voice/voice_search_prefs_registration.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
BrowserStateInfoCache::RegisterPrefs(registry);
flags_ui::PrefServiceFlagsStorage::RegisterPrefs(registry);
gcm::GCMChannelStatusSyncer::RegisterPrefs(registry);
ios::SigninManagerFactory::RegisterPrefs(registry);
IOSChromeMetricsServiceClient::RegisterPrefs(registry);
network_time::NetworkTimeTracker::RegisterPrefs(registry);
ios::NotificationPromo::RegisterPrefs(registry);
PrefProxyConfigTrackerImpl::RegisterPrefs(registry);
rappor::RapporService::RegisterPrefs(registry);
ssl_config::SSLConfigServiceManager::RegisterPrefs(registry);
update_client::RegisterPrefs(registry);
variations::VariationsService::RegisterPrefs(registry);
// Preferences related to the browser state manager.
registry->RegisterStringPref(prefs::kBrowserStateLastUsed, std::string());
registry->RegisterIntegerPref(prefs::kBrowserStatesNumCreated, 1);
registry->RegisterListPref(prefs::kBrowserStatesLastActive);
[OmniboxGeolocationLocalState registerLocalState:registry];
[MemoryDebuggerManager registerLocalState:registry];
registry->RegisterBooleanPref(prefs::kBrowsingDataMigrationHasBeenPossible,
false);
// Preferences related to the application context.
registry->RegisterStringPref(prefs::kApplicationLocale, std::string());
registry->RegisterBooleanPref(prefs::kEulaAccepted, false);
registry->RegisterBooleanPref(metrics::prefs::kMetricsReportingEnabled,
false);
registry->RegisterBooleanPref(prefs::kLastSessionExitedCleanly, true);
registry->RegisterBooleanPref(prefs::kMetricsReportingWifiOnly, true);
}
void RegisterBrowserStatePrefs(user_prefs::PrefRegistrySyncable* registry) {
autofill::AutofillManager::RegisterProfilePrefs(registry);
dom_distiller::DistilledPagePrefs::RegisterProfilePrefs(registry);
FirstRun::RegisterProfilePrefs(registry);
gcm::GCMChannelStatusSyncer::RegisterProfilePrefs(registry);
HostContentSettingsMap::RegisterProfilePrefs(registry);
HttpServerPropertiesManagerFactory::RegisterProfilePrefs(registry);
ntp_snippets::BookmarkSuggestionsProvider::RegisterProfilePrefs(registry);
ntp_snippets::RemoteSuggestionsProvider::RegisterProfilePrefs(registry);
ntp_snippets::ContentSuggestionsService::RegisterProfilePrefs(registry);
ntp_tiles::MostVisitedSites::RegisterProfilePrefs(registry);
ntp_tiles::PopularSites::RegisterProfilePrefs(registry);
ios::NotificationPromo::RegisterProfilePrefs(registry);
password_manager::PasswordManager::RegisterProfilePrefs(registry);
PrefProxyConfigTrackerImpl::RegisterProfilePrefs(registry);
syncer::SyncPrefs::RegisterProfilePrefs(registry);
TemplateURLPrepopulateData::RegisterProfilePrefs(registry);
translate::TranslatePrefs::RegisterProfilePrefs(registry);
variations::VariationsService::RegisterProfilePrefs(registry);
ZeroSuggestProvider::RegisterProfilePrefs(registry);
RegisterVoiceSearchBrowserStatePrefs(registry);
registry->RegisterBooleanPref(prefs::kDataSaverEnabled, false);
registry->RegisterBooleanPref(
prefs::kEnableDoNotTrack, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kEnableTranslate, true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterStringPref(prefs::kAcceptLanguages,
l10n_util::GetStringUTF8(IDS_ACCEPT_LANGUAGES));
registry->RegisterStringPref(prefs::kDefaultCharset,
l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterInt64Pref(prefs::kRateThisAppDialogLastShownTime, 0,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kNetworkPredictionEnabled, true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kNetworkPredictionWifiOnly, true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterStringPref(prefs::kContextualSearchEnabled, std::string(),
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kSearchSuggestEnabled, true,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled, false);
registry->RegisterIntegerPref(prefs::kNtpShownPage, 1 << 10);
// This comes from components/bookmarks/core/browser/bookmark_model.h
// Defaults to 3, which is the id of bookmarkModel_->mobile_node()
registry->RegisterInt64Pref(prefs::kNtpShownBookmarksFolder, 3);
// Register prefs used by Clear Browsing Data UI.
browsing_data::prefs::RegisterBrowserUserPrefs(registry);
ios::GetChromeBrowserProvider()->RegisterProfilePrefs(registry);
}
// This method should be periodically pruned of year+ old migrations.
void MigrateObsoleteLocalStatePrefs(PrefService* prefs) {
}
// This method should be periodically pruned of year+ old migrations.
void MigrateObsoleteBrowserStatePrefs(PrefService* prefs) {
// Added 07/2014.
translate::TranslatePrefs::MigrateUserPrefs(prefs, prefs::kAcceptLanguages);
// Added 08/2015.
prefs->ClearPref(::prefs::kSigninSharedAuthenticationUserId);
}