| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/options_util.h" | |
| 6 | |
| 7 #include "base/thread_restrictions.h" | |
| 8 #include "chrome/browser/browser_process.h" | |
| 9 #include "chrome/browser/download/download_manager.h" | |
| 10 #include "chrome/browser/download/download_prefs.h" | |
| 11 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
| 12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | |
| 13 #include "chrome/browser/host_zoom_map.h" | |
| 14 #include "chrome/browser/metrics/metrics_service.h" | |
| 15 #include "chrome/browser/notifications/desktop_notification_service.h" | |
| 16 #include "chrome/browser/prefs/pref_service.h" | |
| 17 #include "chrome/browser/profile.h" | |
| 18 #include "chrome/common/pref_names.h" | |
| 19 #include "chrome/installer/util/google_update_settings.h" | |
| 20 | |
| 21 // static | |
| 22 void OptionsUtil::ResetToDefaults(Profile* profile) { | |
| 23 // TODO(tc): It would be nice if we could generate this list automatically so | |
| 24 // changes to any of the options pages doesn't require updating this list | |
| 25 // manually. | |
| 26 PrefService* prefs = profile->GetPrefs(); | |
| 27 const char* kUserPrefs[] = { | |
| 28 prefs::kAcceptLanguages, | |
| 29 prefs::kAlternateErrorPagesEnabled, | |
| 30 prefs::kClearSiteDataOnExit, | |
| 31 prefs::kCookieBehavior, | |
| 32 prefs::kDefaultCharset, | |
| 33 prefs::kDefaultZoomLevel, | |
| 34 prefs::kDeleteBrowsingHistory, | |
| 35 prefs::kDeleteCache, | |
| 36 prefs::kDeleteCookies, | |
| 37 prefs::kDeleteDownloadHistory, | |
| 38 prefs::kDeleteFormData, | |
| 39 prefs::kDeletePasswords, | |
| 40 prefs::kDnsPrefetchingEnabled, | |
| 41 #if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) | |
| 42 prefs::kCertRevocationCheckingEnabled, | |
| 43 prefs::kSSL3Enabled, | |
| 44 prefs::kTLS1Enabled, | |
| 45 #endif | |
| 46 #if defined(OS_CHROMEOS) | |
| 47 prefs::kTapToClickEnabled, | |
| 48 prefs::kTouchpadSensitivity, | |
| 49 #endif | |
| 50 prefs::kDownloadDefaultDirectory, | |
| 51 prefs::kDownloadExtensionsToOpen, | |
| 52 prefs::kSavingBrowserHistoryDisabled, | |
| 53 prefs::kEnableSpellCheck, | |
| 54 prefs::kEnableTranslate, | |
| 55 prefs::kAutoFillEnabled, | |
| 56 prefs::kAutoFillAuxiliaryProfilesEnabled, | |
| 57 prefs::kHomePage, | |
| 58 prefs::kHomePageIsNewTabPage, | |
| 59 prefs::kPromptForDownload, | |
| 60 prefs::kPasswordManagerEnabled, | |
| 61 prefs::kRestoreOnStartup, | |
| 62 prefs::kSafeBrowsingEnabled, | |
| 63 prefs::kSafeBrowsingReportingEnabled, | |
| 64 prefs::kSearchSuggestEnabled, | |
| 65 prefs::kShowHomeButton, | |
| 66 prefs::kSpellCheckDictionary, | |
| 67 prefs::kURLsToRestoreOnStartup, | |
| 68 prefs::kWebKitDefaultFixedFontSize, | |
| 69 prefs::kWebKitDefaultFontSize, | |
| 70 prefs::kWebKitFixedFontFamily, | |
| 71 prefs::kWebKitJavaEnabled, | |
| 72 prefs::kWebKitJavascriptEnabled, | |
| 73 prefs::kWebKitLoadsImagesAutomatically, | |
| 74 prefs::kWebKitPluginsEnabled, | |
| 75 prefs::kWebKitSansSerifFontFamily, | |
| 76 prefs::kWebKitSerifFontFamily, | |
| 77 prefs::kWebKitMinimumFontSize, | |
| 78 prefs::kWebKitMinimumLogicalFontSize, | |
| 79 prefs::kWebkitTabsToLinks, | |
| 80 }; | |
| 81 profile->GetDownloadManager()->download_prefs()->ResetToDefaults(); | |
| 82 profile->GetHostContentSettingsMap()->ResetToDefaults(); | |
| 83 profile->GetGeolocationContentSettingsMap()->ResetToDefault(); | |
| 84 profile->GetHostZoomMap()->ResetToDefaults(); | |
| 85 profile->GetDesktopNotificationService()->ResetToDefaultContentSetting(); | |
| 86 for (size_t i = 0; i < arraysize(kUserPrefs); ++i) | |
| 87 prefs->ClearPref(kUserPrefs[i]); | |
| 88 | |
| 89 PrefService* local_state = g_browser_process->local_state(); | |
| 90 // Note that we don't reset the kMetricsReportingEnabled preference here | |
| 91 // because the reset will reset it to the default setting specified in Chrome | |
| 92 // source, not the default setting selected by the user on the web page where | |
| 93 // they downloaded Chrome. This means that if the user ever resets their | |
| 94 // settings they'll either inadvertedly enable this logging or disable it. | |
| 95 // One is undesirable for them, one is undesirable for us. For now, we just | |
| 96 // don't reset it. | |
| 97 const char* kLocalStatePrefs[] = { | |
| 98 prefs::kApplicationLocale, | |
| 99 }; | |
| 100 for (size_t i = 0; i < arraysize(kLocalStatePrefs); ++i) | |
| 101 local_state->ClearPref(kLocalStatePrefs[i]); | |
| 102 } | |
| 103 | |
| 104 // static | |
| 105 bool OptionsUtil::ResolveMetricsReportingEnabled(bool enabled) { | |
| 106 // GoogleUpdateSettings touches the disk from the UI thread. MetricsService | |
| 107 // also calls GoogleUpdateSettings below. http://crbug/62626 | |
| 108 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 109 | |
| 110 GoogleUpdateSettings::SetCollectStatsConsent(enabled); | |
| 111 bool update_pref = GoogleUpdateSettings::GetCollectStatsConsent(); | |
| 112 | |
| 113 if (enabled != update_pref) { | |
| 114 DVLOG(1) << "OptionsUtil: Unable to set crash report status to " << enabled; | |
| 115 } | |
| 116 | |
| 117 // Only change the pref if GoogleUpdateSettings::GetCollectStatsConsent | |
| 118 // succeeds. | |
| 119 enabled = update_pref; | |
| 120 | |
| 121 MetricsService* metrics = g_browser_process->metrics_service(); | |
| 122 DCHECK(metrics); | |
| 123 if (metrics) { | |
| 124 metrics->SetUserPermitsUpload(enabled); | |
| 125 if (enabled) | |
| 126 metrics->Start(); | |
| 127 else | |
| 128 metrics->Stop(); | |
| 129 } | |
| 130 | |
| 131 return enabled; | |
| 132 } | |
| OLD | NEW |