summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 18:26:12 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 18:26:12 +0000
commita33f62b19e7be82d6784df99ce7cfc5321910a07 (patch)
tree439f5e9376d1cde395f52994399822e982a734b9
parentdaccbce9086a33e84f1eaec42b9781e7f137fa8a (diff)
downloadchromium_src-a33f62b19e7be82d6784df99ce7cfc5321910a07.zip
chromium_src-a33f62b19e7be82d6784df99ce7cfc5321910a07.tar.gz
chromium_src-a33f62b19e7be82d6784df99ce7cfc5321910a07.tar.bz2
move the ResetToDefault function for prefs to chrome/browser/options_util
BUG=11507 Review URL: http://codereview.chromium.org/147190 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19390 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/options_util.cc65
-rw-r--r--chrome/browser/options_util.h20
-rw-r--r--chrome/browser/views/options/advanced_page_view.cc56
-rw-r--r--chrome/chrome.gyp2
4 files changed, 89 insertions, 54 deletions
diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc
new file mode 100644
index 0000000..eb19af0
--- /dev/null
+++ b/chrome/browser/options_util.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2009 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 "chrome/browser/options_util.h"
+
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
+
+// static
+void OptionsUtil::ResetToDefaults(Profile* profile) {
+ // TODO(tc): It would be nice if we could generate this list automatically so
+ // changes to any of the options pages doesn't require updating this list
+ // manually.
+ PrefService* prefs = profile->GetPrefs();
+ const wchar_t* kUserPrefs[] = {
+ prefs::kAcceptLanguages,
+ prefs::kAlternateErrorPagesEnabled,
+ prefs::kCookieBehavior,
+ prefs::kDefaultCharset,
+ prefs::kDnsPrefetchingEnabled,
+ prefs::kDownloadDefaultDirectory,
+ prefs::kDownloadExtensionsToOpen,
+ prefs::kFormAutofillEnabled,
+ prefs::kHomePage,
+ prefs::kHomePageIsNewTabPage,
+ prefs::kMixedContentFiltering,
+ prefs::kPromptForDownload,
+ prefs::kPasswordManagerEnabled,
+ prefs::kRestoreOnStartup,
+ prefs::kSafeBrowsingEnabled,
+ prefs::kSearchSuggestEnabled,
+ prefs::kShowHomeButton,
+ prefs::kSpellCheckDictionary,
+ prefs::kURLsToRestoreOnStartup,
+ prefs::kWebKitDefaultFixedFontSize,
+ prefs::kWebKitDefaultFontSize,
+ prefs::kWebKitFixedFontFamily,
+ prefs::kWebKitJavaEnabled,
+ prefs::kWebKitJavascriptEnabled,
+ prefs::kWebKitLoadsImagesAutomatically,
+ prefs::kWebKitPluginsEnabled,
+ prefs::kWebKitSansSerifFontFamily,
+ prefs::kWebKitSerifFontFamily,
+ };
+ for (size_t i = 0; i < arraysize(kUserPrefs); ++i)
+ prefs->ClearPref(kUserPrefs[i]);
+
+ PrefService* local_state = g_browser_process->local_state();
+ // Note that we don't reset the kMetricsReportingEnabled preference here
+ // because the reset will reset it to the default setting specified in Chrome
+ // source, not the default setting selected by the user on the web page where
+ // they downloaded Chrome. This means that if the user ever resets their
+ // settings they'll either inadvertedly enable this logging or disable it.
+ // One is undesirable for them, one is undesirable for us. For now, we just
+ // don't reset it.
+ const wchar_t* kLocalStatePrefs[] = {
+ prefs::kApplicationLocale,
+ prefs::kOptionsWindowLastTabIndex,
+ };
+ for (size_t i = 0; i < arraysize(kLocalStatePrefs); ++i)
+ local_state->ClearPref(kLocalStatePrefs[i]);
+}
diff --git a/chrome/browser/options_util.h b/chrome/browser/options_util.h
new file mode 100644
index 0000000..2d9f827
--- /dev/null
+++ b/chrome/browser/options_util.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHROME_BROWSER_OPTIONS_UTIL_H_
+#define CHROME_BROWSER_OPTIONS_UTIL_H_
+
+#include "base/basictypes.h"
+
+class Profile;
+
+class OptionsUtil {
+ public:
+ // Resets all prefs to their default values.
+ static void ResetToDefaults(Profile* profile);
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(OptionsUtil);
+};
+
+#endif // CHROME_BROWSER_OPTIONS_UTIL_H_
diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc
index 4d4ccad..f5136342 100644
--- a/chrome/browser/views/options/advanced_page_view.cc
+++ b/chrome/browser/views/options/advanced_page_view.cc
@@ -8,11 +8,9 @@
#include "app/message_box_flags.h"
#include "base/string_util.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
+#include "chrome/browser/options_util.h"
#include "chrome/browser/views/options/advanced_contents_view.h"
#include "chrome/common/chrome_constants.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/pref_service.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -98,57 +96,7 @@ AdvancedPageView::~AdvancedPageView() {
}
void AdvancedPageView::ResetToDefaults() {
- // TODO(tc): It would be nice if we could generate this list automatically so
- // changes to any of the options pages doesn't require updating this list
- // manually.
- PrefService* prefs = profile()->GetPrefs();
- const wchar_t* kUserPrefs[] = {
- prefs::kAcceptLanguages,
- prefs::kAlternateErrorPagesEnabled,
- prefs::kCookieBehavior,
- prefs::kDefaultCharset,
- prefs::kDnsPrefetchingEnabled,
- prefs::kDownloadDefaultDirectory,
- prefs::kDownloadExtensionsToOpen,
- prefs::kFormAutofillEnabled,
- prefs::kHomePage,
- prefs::kHomePageIsNewTabPage,
- prefs::kMixedContentFiltering,
- prefs::kPromptForDownload,
- prefs::kPasswordManagerEnabled,
- prefs::kRestoreOnStartup,
- prefs::kSafeBrowsingEnabled,
- prefs::kSearchSuggestEnabled,
- prefs::kShowHomeButton,
- prefs::kSpellCheckDictionary,
- prefs::kURLsToRestoreOnStartup,
- prefs::kWebKitDefaultFixedFontSize,
- prefs::kWebKitDefaultFontSize,
- prefs::kWebKitFixedFontFamily,
- prefs::kWebKitJavaEnabled,
- prefs::kWebKitJavascriptEnabled,
- prefs::kWebKitLoadsImagesAutomatically,
- prefs::kWebKitPluginsEnabled,
- prefs::kWebKitSansSerifFontFamily,
- prefs::kWebKitSerifFontFamily,
- };
- for (int i = 0; i < arraysize(kUserPrefs); ++i)
- prefs->ClearPref(kUserPrefs[i]);
-
- PrefService* local_state = g_browser_process->local_state();
- // Note that we don't reset the kMetricsReportingEnabled preference here
- // because the reset will reset it to the default setting specified in Chrome
- // source, not the default setting selected by the user on the web page where
- // they downloaded Chrome. This means that if the user ever resets their
- // settings they'll either inadvertedly enable this logging or disable it.
- // One is undesirable for them, one is undesirable for us. For now, we just
- // don't reset it.
- const wchar_t* kLocalStatePrefs[] = {
- prefs::kApplicationLocale,
- prefs::kOptionsWindowLastTabIndex,
- };
- for (int i = 0; i < arraysize(kLocalStatePrefs); ++i)
- local_state->ClearPref(kLocalStatePrefs[i]);
+ OptionsUtil::ResetToDefaults(profile());
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 78ec127..6f90dac 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -1186,6 +1186,8 @@
'browser/net/url_fixer_upper.h',
'browser/options_page_base.cc',
'browser/options_page_base.h',
+ 'browser/options_util.cc',
+ 'browser/options_util.h',
'browser/options_window.h',
'browser/page_info_window.cc',
'browser/page_info_window.h',