diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-28 01:44:30 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-28 01:44:30 +0000 |
commit | 7570597faa7206d113d53e71e3a5ae390b7d72d9 (patch) | |
tree | 3924732ad8d96744a8698e41ad26bb1c25f01845 /chrome | |
parent | ae16116a8f4e4f7fec88608990f6d92f846b2171 (diff) | |
download | chromium_src-7570597faa7206d113d53e71e3a5ae390b7d72d9.zip chromium_src-7570597faa7206d113d53e71e3a5ae390b7d72d9.tar.gz chromium_src-7570597faa7206d113d53e71e3a5ae390b7d72d9.tar.bz2 |
Make content settings type enum something I can use in more code than just the content settings window.
Also register the content settings last tab pref.
BUG=33314
TEST=none
Review URL: http://codereview.chromium.org/556049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37368 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_prefs.cc | 4 | ||||
-rw-r--r-- | chrome/browser/content_settings_types.h | 24 | ||||
-rw-r--r-- | chrome/browser/content_settings_window.h | 36 | ||||
-rw-r--r-- | chrome/browser/views/cookie_prompt_view.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/options/advanced_contents_view.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/options/content_settings_window_view.cc | 64 | ||||
-rw-r--r-- | chrome/browser/views/options/content_settings_window_view.h | 15 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 6 |
8 files changed, 77 insertions, 82 deletions
diff --git a/chrome/browser/browser_prefs.cc b/chrome/browser/browser_prefs.cc index bdab353..8e78310 100644 --- a/chrome/browser/browser_prefs.cc +++ b/chrome/browser/browser_prefs.cc @@ -37,6 +37,7 @@ #if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port #include "chrome/browser/views/browser_actions_container.h" #include "chrome/browser/views/frame/browser_view.h" +#include "chrome/browser/views/options/content_settings_window_view.h" #endif #if defined(TOOLKIT_GTK) @@ -97,6 +98,9 @@ void RegisterUserPrefs(PrefService* user_prefs) { Blacklist::RegisterUserPrefs(user_prefs); #if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port. BrowserActionsContainer::RegisterUserPrefs(user_prefs); +#if defined(OS_WIN) + ContentSettingsWindowView::RegisterUserPrefs(user_prefs); +#endif #endif #if defined(TOOLKIT_GTK) BrowserWindowGtk::RegisterUserPrefs(user_prefs); diff --git a/chrome/browser/content_settings_types.h b/chrome/browser/content_settings_types.h new file mode 100644 index 0000000..1532a08 --- /dev/null +++ b/chrome/browser/content_settings_types.h @@ -0,0 +1,24 @@ +// 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_CONTENT_SETTINGS_TYPES_H_ +#define CHROME_BROWSER_CONTENT_SETTINGS_TYPES_H_ + +// A particular type of content to care about. We give the user various types +// of controls over each of these. +enum ContentSettingsType { + // "DEFAULT" is only used as an argument to the Content Settings Window + // opener; there it means "whatever was last shown". + CONTENT_SETTINGS_TYPE_DEFAULT = -1, + CONTENT_SETTINGS_FIRST_TYPE = 0, + CONTENT_SETTINGS_TYPE_COOKIES = CONTENT_SETTINGS_FIRST_TYPE, + CONTENT_SETTINGS_TYPE_IMAGES, + CONTENT_SETTINGS_TYPE_JAVASCRIPT, + CONTENT_SETTINGS_TYPE_PLUGINS, + CONTENT_SETTINGS_TYPE_POPUPS, + CONTENT_SETTINGS_NUM_TYPES +}; + +#endif // CHROME_BROWSER_CONTENT_SETTINGS_TYPES_H_ + diff --git a/chrome/browser/content_settings_window.h b/chrome/browser/content_settings_window.h deleted file mode 100644 index a77a579..0000000 --- a/chrome/browser/content_settings_window.h +++ /dev/null @@ -1,36 +0,0 @@ -// 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_CONTENT_SETTINGS_WINDOW_H_ -#define CHROME_BROWSER_CONTENT_SETTINGS_WINDOW_H_ - -class PrefService; -class Profile; - -// A particular tab within the Content Settings dialog. When passed to -// ShowContentSettingsWindow(), CONTENT_SETTINGS_TAB_DEFAULT means select the -// last. -enum ContentSettingsTab { - CONTENT_SETTINGS_TAB_DEFAULT = -1, - CONTENT_SETTINGS_TAB_COOKIES, - CONTENT_SETTINGS_TAB_IMAGES, - CONTENT_SETTINGS_TAB_JAVASCRIPT, - CONTENT_SETTINGS_TAB_PLUGINS, - CONTENT_SETTINGS_PAGE_POPUPS, - CONTENT_SETTINGS_NUM_TABS -}; - -class ContentSettings { - public: - // Show the Content Settings window selecting the specified page. - // If a Content Settings window is currently open, this just activates it - // instead of opening a new one. - static void ShowContentSettingsWindow(ContentSettingsTab page, - Profile* profile); - - static void RegisterPrefs(PrefService* prefs); -}; - -#endif // CHROME_BROWSER_CONTENT_SETTINGS_WINDOW_H_ - diff --git a/chrome/browser/views/cookie_prompt_view.cc b/chrome/browser/views/cookie_prompt_view.cc index 0adf262..a7bfb31 100644 --- a/chrome/browser/views/cookie_prompt_view.cc +++ b/chrome/browser/views/cookie_prompt_view.cc @@ -13,7 +13,7 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "chrome/browser/profile.h" -#include "chrome/browser/content_settings_window.h" +#include "chrome/browser/views/options/content_settings_window_view.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "net/base/cookie_monster.h" @@ -138,8 +138,7 @@ void CookiesPromptView::LinkActivated(views::Link* source, int event_flags) { if (source == show_cookie_link_) ToggleCookieViewExpand(); else if (source == manage_cookies_link_) - ContentSettings::ShowContentSettingsWindow(CONTENT_SETTINGS_TAB_COOKIES, - profile_); + ContentSettingsWindowView::Show(CONTENT_SETTINGS_TYPE_COOKIES, profile_); else NOTREACHED(); } diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index aefb93d..dc3fde4 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -24,7 +24,6 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/content_settings_window.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/gears_integration.h" #include "chrome/browser/net/dns_global.h" @@ -34,6 +33,7 @@ #include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/shell_dialogs.h" #include "chrome/browser/views/clear_browsing_data.h" +#include "chrome/browser/views/options/content_settings_window_view.h" #include "chrome/browser/views/options/fonts_languages_window_view.h" #include "chrome/browser/views/restart_message_box.h" #include "chrome/common/pref_member.h" @@ -588,8 +588,7 @@ void PrivacySection::ButtonPressed( enable_metrics_recording_.SetValue(enabled); } else if (sender == content_settings_button_) { UserMetricsRecordAction("Options_ContentSettings", NULL); - ContentSettings::ShowContentSettingsWindow(CONTENT_SETTINGS_TAB_DEFAULT, - profile()); + ContentSettingsWindowView::Show(CONTENT_SETTINGS_TYPE_DEFAULT, profile()); } else if (sender == clear_data_button_) { UserMetricsRecordAction("Options_ClearData", NULL); views::Window::CreateChromeWindow( diff --git a/chrome/browser/views/options/content_settings_window_view.cc b/chrome/browser/views/options/content_settings_window_view.cc index 2e327df..a27b3cc 100644 --- a/chrome/browser/views/options/content_settings_window_view.cc +++ b/chrome/browser/views/options/content_settings_window_view.cc @@ -30,6 +30,27 @@ static const int kDialogPadding = 7; /////////////////////////////////////////////////////////////////////////////// // ContentSettingsWindowView, public: +// static +void ContentSettingsWindowView::Show(ContentSettingsType page, + Profile* profile) { + DCHECK(profile); + // If there's already an existing options window, activate it and switch to + // the specified page. + // TODO(beng): note this is not multi-simultaneous-profile-safe. When we care + // about this case this will have to be fixed. + if (!instance_) { + instance_ = new ContentSettingsWindowView(profile); + views::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_); + // The window is alive by itself now... + } + instance_->ShowContentSettingsTab(page); +} + +// static +void ContentSettingsWindowView::RegisterUserPrefs(PrefService* prefs) { + prefs->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, 0); +} + ContentSettingsWindowView::ContentSettingsWindowView(Profile* profile) // Always show preferences for the original profile. Most state when off // the record comes from the original profile, but we explicitly use @@ -145,17 +166,11 @@ void ContentSettingsWindowView::Init() { l10n_util::GetString(IDS_POPUP_TAB_LABEL), popup_page, false); - DCHECK(tabs_->GetTabCount() == CONTENT_SETTINGS_NUM_TABS); -} - -const OptionsPageView* - ContentSettingsWindowView::GetCurrentContentSettingsTabView() const { - return static_cast<OptionsPageView*>(tabs_->GetSelectedTab()); + DCHECK(tabs_->GetTabCount() == CONTENT_SETTINGS_NUM_TYPES); } - void ContentSettingsWindowView::ShowContentSettingsTab( - ContentSettingsTab page) { + ContentSettingsType page) { // If the window is not yet visible, we need to show it (it will become // active), otherwise just bring it to the front. if (!window()->IsVisible()) @@ -163,37 +178,20 @@ void ContentSettingsWindowView::ShowContentSettingsTab( else window()->Activate(); - if (page == CONTENT_SETTINGS_TAB_DEFAULT) { + if (page == CONTENT_SETTINGS_TYPE_DEFAULT) { // Remember the last visited page from local state. - page = static_cast<ContentSettingsTab>(last_selected_page_.GetValue()); - if (page == CONTENT_SETTINGS_TAB_DEFAULT) - page = CONTENT_SETTINGS_TAB_COOKIES; + page = static_cast<ContentSettingsType>(last_selected_page_.GetValue()); + if (page == CONTENT_SETTINGS_TYPE_DEFAULT) + page = CONTENT_SETTINGS_FIRST_TYPE; } // If the page number is out of bounds, reset to the first tab. if (page < 0 || page >= tabs_->GetTabCount()) - page = CONTENT_SETTINGS_TAB_COOKIES; + page = CONTENT_SETTINGS_FIRST_TYPE; tabs_->SelectTabAt(static_cast<int>(page)); } -/////////////////////////////////////////////////////////////////////////////// -// Factory/finder method: -void ContentSettings::ShowContentSettingsWindow(ContentSettingsTab page, - Profile* profile) { - DCHECK(profile); - // If there's already an existing options window, activate it and switch to - // the specified page. - // TODO(beng): note this is not multi-simultaneous-profile-safe. When we care - // about this case this will have to be fixed. - if (!instance_) { - instance_ = new ContentSettingsWindowView(profile); - views::Window::CreateChromeWindow(NULL, gfx::Rect(), instance_); - // The window is alive by itself now... - } - instance_->ShowContentSettingsTab(page); -} - -void ContentSettings::RegisterPrefs(PrefService* prefs) { - prefs->RegisterIntegerPref(prefs::kContentSettingsWindowLastTabIndex, 0); +const OptionsPageView* + ContentSettingsWindowView::GetCurrentContentSettingsTabView() const { + return static_cast<OptionsPageView*>(tabs_->GetSelectedTab()); } - diff --git a/chrome/browser/views/options/content_settings_window_view.h b/chrome/browser/views/options/content_settings_window_view.h index 4cd606e..7bb5ec1 100644 --- a/chrome/browser/views/options/content_settings_window_view.h +++ b/chrome/browser/views/options/content_settings_window_view.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_SETTINGS_WINDOW_VIEW_H_ #include "chrome/common/pref_member.h" -#include "chrome/browser/content_settings_window.h" +#include "chrome/browser/content_settings_types.h" #include "views/controls/tabbed_pane/tabbed_pane.h" #include "views/view.h" #include "views/window/dialog_delegate.h" @@ -24,12 +24,16 @@ class ContentSettingsWindowView : public views::View, public views::DialogDelegate, public views::TabbedPane::Listener { public: + // Show the Content Settings window selecting the specified page. + // If a Content Settings window is currently open, this just activates it + // instead of opening a new one. + static void Show(ContentSettingsType page, Profile* profile); + + static void RegisterUserPrefs(PrefService* prefs); + explicit ContentSettingsWindowView(Profile* profile); virtual ~ContentSettingsWindowView(); - // Shows the Tab corresponding to the specified Content Settings page. - void ShowContentSettingsTab(ContentSettingsTab page); - protected: // views::View overrides: virtual void Layout(); @@ -54,6 +58,9 @@ class ContentSettingsWindowView : public views::View, // Initializes the view. void Init(); + // Shows the Tab corresponding to the specified Content Settings page. + void ShowContentSettingsTab(ContentSettingsType page); + // Returns the currently selected OptionsPageView. const OptionsPageView* GetCurrentContentSettingsTabView() const; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 0e94ea3..2c237a8 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -608,7 +608,7 @@ 'browser/cocoa/window_size_autosaver.mm', 'browser/command_updater.cc', 'browser/command_updater.h', - 'browser/content_settings_window.h', + 'browser/content_settings_types.h', 'browser/cookies_tree_model.cc', 'browser/cookies_tree_model.h', 'browser/cross_site_request_manager.cc', @@ -1697,10 +1697,10 @@ 'browser/views/chrome_views_delegate.h', 'browser/views/clear_browsing_data.cc', 'browser/views/clear_browsing_data.h', - 'browser/views/constrained_window_win.cc', - 'browser/views/constrained_window_win.h', 'browser/views/confirm_message_box_dialog.cc', 'browser/views/confirm_message_box_dialog.h', + 'browser/views/constrained_window_win.cc', + 'browser/views/constrained_window_win.h', 'browser/views/cookie_info_view.cc', 'browser/views/cookie_info_view.h', 'browser/views/cookie_prompt_view.cc', |