summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/options
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 19:30:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 19:30:19 +0000
commit6a3ec231b4a982787a4a1a5fd672bb974ce98bca (patch)
treea63406d0cb3012ed4ab677598d4f2de9329e9f5a /chrome/browser/ui/options
parent1ffacfd8a743eb9d375080db95d900166758551c (diff)
downloadchromium_src-6a3ec231b4a982787a4a1a5fd672bb974ce98bca.zip
chromium_src-6a3ec231b4a982787a4a1a5fd672bb974ce98bca.tar.gz
chromium_src-6a3ec231b4a982787a4a1a5fd672bb974ce98bca.tar.bz2
Move:
tab_menu_model->ui/tabs tab_contents_wrapper->ui/tab_contents view_ids.h->ui status_bubble.h->ui options*->ui/options show_options_url*->ui/options location_bar*->ui/omnibox input_window*->ui browser_uitests->ui/tests BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/5582002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/options')
-rw-r--r--chrome/browser/ui/options/options_page_base.cc36
-rw-r--r--chrome/browser/ui/options/options_page_base.h62
-rw-r--r--chrome/browser/ui/options/options_util.cc132
-rw-r--r--chrome/browser/ui/options/options_util.h26
-rw-r--r--chrome/browser/ui/options/options_window.h40
-rw-r--r--chrome/browser/ui/options/show_options_url.cc21
-rw-r--r--chrome/browser/ui/options/show_options_url.h20
7 files changed, 337 insertions, 0 deletions
diff --git a/chrome/browser/ui/options/options_page_base.cc b/chrome/browser/ui/options/options_page_base.cc
new file mode 100644
index 0000000..601e485
--- /dev/null
+++ b/chrome/browser/ui/options/options_page_base.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2010 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/ui/options/options_page_base.h"
+
+#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/common/notification_service.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsPageBase
+
+OptionsPageBase::OptionsPageBase(Profile* profile)
+ : profile_(profile) {
+}
+
+OptionsPageBase::~OptionsPageBase() {
+}
+
+void OptionsPageBase::UserMetricsRecordAction(const UserMetricsAction& action,
+ PrefService* prefs) {
+ UserMetrics::RecordAction(action, profile());
+ if (prefs)
+ prefs->ScheduleSavePersistentPrefs();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsPageBase, NotificationObserver implementation:
+
+void OptionsPageBase::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::PREF_CHANGED)
+ NotifyPrefChanged(Details<std::string>(details).ptr());
+}
diff --git a/chrome/browser/ui/options/options_page_base.h b/chrome/browser/ui/options/options_page_base.h
new file mode 100644
index 0000000..695df1cf
--- /dev/null
+++ b/chrome/browser/ui/options/options_page_base.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 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_UI_OPTIONS_OPTIONS_PAGE_BASE_H_
+#define CHROME_BROWSER_UI_OPTIONS_OPTIONS_PAGE_BASE_H_
+#pragma once
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/ui/options/options_window.h"
+#include "chrome/common/notification_observer.h"
+
+class PrefService;
+class Profile;
+struct UserMetricsAction;
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsPageBase
+//
+// A base class for Options dialog pages that handles observing preferences
+//
+class OptionsPageBase : public NotificationObserver {
+ public:
+ virtual ~OptionsPageBase();
+
+ // Highlights the specified group to attract the user's attention.
+ virtual void HighlightGroup(OptionsGroup highlight_group) { }
+
+ // Overridden from NotificationObserver:
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ protected:
+ // This class cannot be instantiated directly, but its constructor must be
+ // called by derived classes.
+ explicit OptionsPageBase(Profile* profile);
+
+ // Returns the Profile associated with this page.
+ Profile* profile() const { return profile_; }
+
+ // Records a user action and schedules the prefs file to be saved.
+ void UserMetricsRecordAction(const UserMetricsAction &action,
+ PrefService* prefs);
+
+ // Allows the UI to update when a preference value changes. The parameter is
+ // the specific pref that changed, or NULL if all pref UI should be
+ // validated. This should be called during setup, but with NULL as the
+ // parameter to allow initial state to be set.
+ virtual void NotifyPrefChanged(const std::string* pref_name) {}
+
+ private:
+ // The Profile associated with this page.
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(OptionsPageBase);
+};
+
+#endif // CHROME_BROWSER_UI_OPTIONS_OPTIONS_PAGE_BASE_H_
diff --git a/chrome/browser/ui/options/options_util.cc b/chrome/browser/ui/options/options_util.cc
new file mode 100644
index 0000000..465df98
--- /dev/null
+++ b/chrome/browser/ui/options/options_util.cc
@@ -0,0 +1,132 @@
+// Copyright (c) 2010 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/ui/options/options_util.h"
+
+#include "base/thread_restrictions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/download/download_manager.h"
+#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
+#include "chrome/browser/host_zoom_map.h"
+#include "chrome/browser/metrics/metrics_service.h"
+#include "chrome/browser/notifications/desktop_notification_service.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/installer/util/google_update_settings.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 char* kUserPrefs[] = {
+ prefs::kAcceptLanguages,
+ prefs::kAlternateErrorPagesEnabled,
+ prefs::kClearSiteDataOnExit,
+ prefs::kCookieBehavior,
+ prefs::kDefaultCharset,
+ prefs::kDefaultZoomLevel,
+ prefs::kDeleteBrowsingHistory,
+ prefs::kDeleteCache,
+ prefs::kDeleteCookies,
+ prefs::kDeleteDownloadHistory,
+ prefs::kDeleteFormData,
+ prefs::kDeletePasswords,
+ prefs::kDnsPrefetchingEnabled,
+#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
+ prefs::kCertRevocationCheckingEnabled,
+ prefs::kSSL3Enabled,
+ prefs::kTLS1Enabled,
+#endif
+#if defined(OS_CHROMEOS)
+ prefs::kTapToClickEnabled,
+ prefs::kTouchpadSensitivity,
+#endif
+ prefs::kDownloadDefaultDirectory,
+ prefs::kDownloadExtensionsToOpen,
+ prefs::kSavingBrowserHistoryDisabled,
+ prefs::kEnableSpellCheck,
+ prefs::kEnableTranslate,
+ prefs::kAutoFillEnabled,
+ prefs::kAutoFillAuxiliaryProfilesEnabled,
+ prefs::kHomePage,
+ prefs::kHomePageIsNewTabPage,
+ prefs::kPromptForDownload,
+ prefs::kPasswordManagerEnabled,
+ prefs::kRestoreOnStartup,
+ prefs::kSafeBrowsingEnabled,
+ prefs::kSafeBrowsingReportingEnabled,
+ 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,
+ prefs::kWebKitMinimumFontSize,
+ prefs::kWebKitMinimumLogicalFontSize,
+ prefs::kWebkitTabsToLinks,
+ };
+ profile->GetDownloadManager()->download_prefs()->ResetToDefaults();
+ profile->GetHostContentSettingsMap()->ResetToDefaults();
+ profile->GetGeolocationContentSettingsMap()->ResetToDefault();
+ profile->GetHostZoomMap()->ResetToDefaults();
+ profile->GetDesktopNotificationService()->ResetToDefaultContentSetting();
+ 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 char* kLocalStatePrefs[] = {
+ prefs::kApplicationLocale,
+ };
+ for (size_t i = 0; i < arraysize(kLocalStatePrefs); ++i)
+ local_state->ClearPref(kLocalStatePrefs[i]);
+}
+
+// static
+bool OptionsUtil::ResolveMetricsReportingEnabled(bool enabled) {
+ // GoogleUpdateSettings touches the disk from the UI thread. MetricsService
+ // also calls GoogleUpdateSettings below. http://crbug/62626
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+
+ GoogleUpdateSettings::SetCollectStatsConsent(enabled);
+ bool update_pref = GoogleUpdateSettings::GetCollectStatsConsent();
+
+ if (enabled != update_pref) {
+ DVLOG(1) << "OptionsUtil: Unable to set crash report status to " << enabled;
+ }
+
+ // Only change the pref if GoogleUpdateSettings::GetCollectStatsConsent
+ // succeeds.
+ enabled = update_pref;
+
+ MetricsService* metrics = g_browser_process->metrics_service();
+ DCHECK(metrics);
+ if (metrics) {
+ metrics->SetUserPermitsUpload(enabled);
+ if (enabled)
+ metrics->Start();
+ else
+ metrics->Stop();
+ }
+
+ return enabled;
+}
diff --git a/chrome/browser/ui/options/options_util.h b/chrome/browser/ui/options/options_util.h
new file mode 100644
index 0000000..5280051
--- /dev/null
+++ b/chrome/browser/ui/options/options_util.h
@@ -0,0 +1,26 @@
+// 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_UI_OPTIONS_OPTIONS_UTIL_H_
+#define CHROME_BROWSER_UI_OPTIONS_OPTIONS_UTIL_H_
+#pragma once
+
+#include "base/basictypes.h"
+
+class Profile;
+
+class OptionsUtil {
+ public:
+ // Resets all prefs to their default values.
+ static void ResetToDefaults(Profile* profile);
+
+ // Try to make the the crash stats consent and the metrics upload
+ // permission match |enabled|, returns the actual enabled setting.
+ static bool ResolveMetricsReportingEnabled(bool enabled);
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(OptionsUtil);
+};
+
+#endif // CHROME_BROWSER_UI_OPTIONS_OPTIONS_UTIL_H_
diff --git a/chrome/browser/ui/options/options_window.h b/chrome/browser/ui/options/options_window.h
new file mode 100644
index 0000000..f088f1a
--- /dev/null
+++ b/chrome/browser/ui/options/options_window.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2008 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_UI_OPTIONS_OPTIONS_WINDOW_H_
+#define CHROME_BROWSER_UI_OPTIONS_OPTIONS_WINDOW_H_
+#pragma once
+
+class Profile;
+
+// An identifier for a Options Tab page. These are treated as indices into
+// the list of available tabs to be displayed. PAGE_DEFAULT means select the
+// last tab viewed when the Options window was opened, or PAGE_GENERAL if the
+// Options was never opened.
+enum OptionsPage {
+ OPTIONS_PAGE_DEFAULT = -1,
+#if defined(OS_CHROMEOS)
+ OPTIONS_PAGE_SYSTEM,
+ OPTIONS_PAGE_INTERNET,
+#endif
+ OPTIONS_PAGE_GENERAL,
+ OPTIONS_PAGE_CONTENT,
+ OPTIONS_PAGE_ADVANCED,
+ OPTIONS_PAGE_COUNT
+};
+
+// These are some well known groups within the Options dialog box that we may
+// wish to highlight to attract the user's attention to.
+enum OptionsGroup {
+ OPTIONS_GROUP_NONE,
+ OPTIONS_GROUP_DEFAULT_SEARCH
+};
+
+// Show the Options window selecting the specified page. If an Options window
+// is currently open, this just activates it instead of opening a new one.
+void ShowOptionsWindow(OptionsPage page,
+ OptionsGroup highlight_group,
+ Profile* profile);
+
+#endif // CHROME_BROWSER_UI_OPTIONS_OPTIONS_WINDOW_H_
diff --git a/chrome/browser/ui/options/show_options_url.cc b/chrome/browser/ui/options/show_options_url.cc
new file mode 100644
index 0000000..46e2dac
--- /dev/null
+++ b/chrome/browser/ui/options/show_options_url.cc
@@ -0,0 +1,21 @@
+// Copyright (c) 2010 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/ui/options/show_options_url.h"
+
+#include "chrome/browser/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
+
+namespace browser {
+
+void ShowOptionsURL(Profile* profile, const GURL& url) {
+ // We open a new browser window so the Options dialog doesn't get lost behind
+ // other windows.
+ Browser* browser = Browser::Create(profile);
+ browser->AddSelectedTabWithURL(url, PageTransition::LINK);
+ browser->window()->Show();
+}
+
+} // namespace browser
diff --git a/chrome/browser/ui/options/show_options_url.h b/chrome/browser/ui/options/show_options_url.h
new file mode 100644
index 0000000..e849169
--- /dev/null
+++ b/chrome/browser/ui/options/show_options_url.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2010 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_UI_OPTIONS_SHOW_OPTIONS_URL_H_
+#define CHROME_BROWSER_UI_OPTIONS_SHOW_OPTIONS_URL_H_
+#pragma once
+
+class GURL;
+class Profile;
+
+namespace browser {
+
+// Opens a tab showing the specified url. This is intended for use any place
+// we show a URL in the options dialogs.
+void ShowOptionsURL(Profile* profile, const GURL& url);
+
+} // namespace browser
+
+#endif // CHROME_BROWSER_UI_OPTIONS_SHOW_OPTIONS_URL_H_