summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 10:02:16 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 10:02:16 +0000
commitceb98432ad0891542fb213193dd8312aed41e3c6 (patch)
tree9372263ed8c7e045ad7226f44f28079a75661a46 /chrome
parentf85f070f8fca83ca373929584218d7185ff89220 (diff)
downloadchromium_src-ceb98432ad0891542fb213193dd8312aed41e3c6.zip
chromium_src-ceb98432ad0891542fb213193dd8312aed41e3c6.tar.gz
chromium_src-ceb98432ad0891542fb213193dd8312aed41e3c6.tar.bz2
Hook up some of the content settings UI to the actual settings map object. This also rewrites the affected UI bits to make it easier to do this, get rid of unnecessary code, and be more consistent with the blocked content bubble code.
BUG=32719 TEST=Content settings windows now have radio buttons that work, and remember their settings. The Flash link works too. Review URL: http://codereview.chromium.org/558060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/resources/locale_settings.grd2
-rw-r--r--chrome/browser/host_content_settings_map.cc45
-rw-r--r--chrome/browser/host_content_settings_map.h9
-rw-r--r--chrome/browser/host_content_settings_map_unittest.cc27
-rw-r--r--chrome/browser/views/content_blocked_bubble_contents.cc12
-rw-r--r--chrome/browser/views/content_blocked_bubble_contents.h6
-rw-r--r--chrome/browser/views/location_bar_view.cc26
-rw-r--r--chrome/browser/views/location_bar_view.h6
-rw-r--r--chrome/browser/views/options/content_filter_page_view.cc161
-rw-r--r--chrome/browser/views/options/content_filter_page_view.h33
-rw-r--r--chrome/browser/views/options/content_settings_window_view.cc24
-rw-r--r--chrome/browser/views/options/cookie_filter_page_view.cc250
-rw-r--r--chrome/browser/views/options/cookie_filter_page_view.h36
-rw-r--r--chrome/common/content_settings.h6
-rw-r--r--chrome/common/content_settings_types.h3
-rw-r--r--chrome/common/pref_names.cc6
-rw-r--r--chrome/common/pref_names.h1
17 files changed, 317 insertions, 336 deletions
diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd
index e30d00d..2c595ff 100644
--- a/chrome/app/resources/locale_settings.grd
+++ b/chrome/app/resources/locale_settings.grd
@@ -280,7 +280,7 @@
<!-- The height of the Content Settings dialog box, in lines (line height = character -->
<!-- height for default dialog box font) -->
<message name="IDS_CONTENT_SETTINGS_DIALOG_HEIGHT_LINES" use_name_for_id="true">
- 23
+ 22
</message>
<!-- The width and height of the URL picker dialog box in characters and lines -->
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc
index 848a4da..849e204 100644
--- a/chrome/browser/host_content_settings_map.cc
+++ b/chrome/browser/host_content_settings_map.cc
@@ -32,6 +32,7 @@ HostContentSettingsMap::HostContentSettingsMap(Profile* profile)
GetSettingsFromDictionary(default_settings_dictionary,
&default_content_settings_);
}
+ ForceDefaultsToBeExplicit();
const DictionaryValue* all_settings_dictionary =
profile_->GetPrefs()->GetDictionary(prefs::kPerHostContentSettings);
@@ -50,15 +51,15 @@ HostContentSettingsMap::HostContentSettingsMap(Profile* profile)
}
}
- // TODO(darin): init third-party cookie pref
+ block_third_party_cookies_ =
+ profile_->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies);
}
// static
void HostContentSettingsMap::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterDictionaryPref(prefs::kDefaultContentSettings);
prefs->RegisterDictionaryPref(prefs::kPerHostContentSettings);
-
- // TODO(darin): register third-party cookie pref
+ prefs->RegisterBooleanPref(prefs::kBlockThirdPartyCookies, false);
}
ContentSetting HostContentSettingsMap::GetDefaultContentSetting(
@@ -84,13 +85,10 @@ ContentSettings HostContentSettingsMap::GetContentSettings(
if (i == host_content_settings_.end())
return default_content_settings_;
- ContentSettings output;
+ ContentSettings output = i->second;
for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) {
- if (i->second.settings[j] == CONTENT_SETTING_DEFAULT) {
+ if (output.settings[j] == CONTENT_SETTING_DEFAULT)
output.settings[j] = default_content_settings_.settings[j];
- } else {
- output.settings[j] = i->second.settings[j];
- }
}
return output;
}
@@ -169,19 +167,32 @@ void HostContentSettingsMap::SetContentSetting(const std::string& host,
Value::CreateIntegerValue(setting));
}
+void HostContentSettingsMap::SetBlockThirdPartyCookies(bool block) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ {
+ AutoLock auto_lock(lock_);
+ block_third_party_cookies_ = block;
+ }
+
+ profile_->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies,
+ block_third_party_cookies_);
+}
+
void HostContentSettingsMap::ResetToDefaults() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
{
AutoLock auto_lock(lock_);
default_content_settings_ = ContentSettings();
+ ForceDefaultsToBeExplicit();
host_content_settings_.clear();
+ block_third_party_cookies_ = false;
}
profile_->GetPrefs()->ClearPref(prefs::kDefaultContentSettings);
profile_->GetPrefs()->ClearPref(prefs::kPerHostContentSettings);
-
- // TODO(darin): clear third-party cookie pref
+ profile_->GetPrefs()->ClearPref(prefs::kBlockThirdPartyCookies);
}
HostContentSettingsMap::~HostContentSettingsMap() {
@@ -205,3 +216,17 @@ void HostContentSettingsMap::GetSettingsFromDictionary(
}
}
}
+
+void HostContentSettingsMap::ForceDefaultsToBeExplicit() {
+ static const ContentSetting kDefaultSettings[CONTENT_SETTINGS_NUM_TYPES] = {
+ CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_COOKIES
+ CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_IMAGES
+ CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_JAVASCRIPT
+ CONTENT_SETTING_ALLOW, // CONTENT_SETTINGS_TYPE_PLUGINS
+ CONTENT_SETTING_BLOCK, // CONTENT_SETTINGS_TYPE_POPUPS
+ };
+ for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
+ if (default_content_settings_.settings[i] == CONTENT_SETTING_DEFAULT)
+ default_content_settings_.settings[i] = kDefaultSettings[i];
+ }
+}
diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h
index a4183d9..e068b06 100644
--- a/chrome/browser/host_content_settings_map.h
+++ b/chrome/browser/host_content_settings_map.h
@@ -72,6 +72,11 @@ class HostContentSettingsMap
// This setting trumps any host-specific settings.
bool BlockThirdPartyCookies() const { return block_third_party_cookies_; }
+ // Sets whether we block all third-party cookies.
+ //
+ // This should only be called on the UI thread.
+ void SetBlockThirdPartyCookies(bool block);
+
// Resets all settings levels.
//
// This should only be called on the UI thread.
@@ -91,6 +96,10 @@ class HostContentSettingsMap
void GetSettingsFromDictionary(const DictionaryValue* dictionary,
ContentSettings* settings);
+ // Forces the default settings to be explicitly set instead of themselves
+ // being CONTENT_SETTING_DEFAULT.
+ void ForceDefaultsToBeExplicit();
+
// The profile we're associated with.
Profile* profile_;
diff --git a/chrome/browser/host_content_settings_map_unittest.cc b/chrome/browser/host_content_settings_map_unittest.cc
index b509129..eaaa9ce 100644
--- a/chrome/browser/host_content_settings_map_unittest.cc
+++ b/chrome/browser/host_content_settings_map_unittest.cc
@@ -12,8 +12,7 @@ namespace {
bool SettingsEqual(const ContentSettings& settings1,
const ContentSettings& settings2) {
- for (int i = CONTENT_SETTINGS_FIRST_TYPE; i < CONTENT_SETTINGS_NUM_TYPES;
- ++i) {
+ for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
if (settings1.settings[i] != settings2.settings[i])
return false;
}
@@ -36,7 +35,7 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
profile.GetHostContentSettingsMap();
// Check setting defaults.
- EXPECT_EQ(CONTENT_SETTING_DEFAULT,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_JAVASCRIPT));
host_content_settings_map->SetDefaultContentSetting(
@@ -55,18 +54,18 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
host_content_settings_map->GetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_POPUPS));
host_content_settings_map->ResetToDefaults();
- EXPECT_EQ(CONTENT_SETTING_DEFAULT,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetDefaultContentSetting(
- CONTENT_SETTINGS_TYPE_POPUPS));
+ CONTENT_SETTINGS_TYPE_PLUGINS));
// Check returning individual settings.
std::string host("example.com");
- EXPECT_EQ(CONTENT_SETTING_DEFAULT,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
host, CONTENT_SETTINGS_TYPE_IMAGES));
host_content_settings_map->SetContentSetting(host,
CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_DEFAULT);
- EXPECT_EQ(CONTENT_SETTING_DEFAULT,
+ EXPECT_EQ(CONTENT_SETTING_ALLOW,
host_content_settings_map->GetContentSetting(
host, CONTENT_SETTINGS_TYPE_IMAGES));
host_content_settings_map->SetContentSetting(host,
@@ -77,16 +76,22 @@ TEST_F(HostContentSettingsMapTest, DefaultValues) {
// Check returning all settings for a host.
ContentSettings desired_settings;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES] =
+ CONTENT_SETTING_ALLOW;
host_content_settings_map->SetContentSetting(host,
CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_DEFAULT);
- host_content_settings_map->SetContentSetting(host,
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW);
- desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] =
CONTENT_SETTING_ALLOW;
host_content_settings_map->SetContentSetting(host,
- CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_ALLOW);
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK);
desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] =
+ CONTENT_SETTING_BLOCK;
+ host_content_settings_map->SetContentSetting(host,
+ CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ALLOW);
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] =
CONTENT_SETTING_ALLOW;
+ desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] =
+ CONTENT_SETTING_BLOCK;
ContentSettings settings =
host_content_settings_map->GetContentSettings(host);
EXPECT_TRUE(SettingsEqual(desired_settings, settings));
diff --git a/chrome/browser/views/content_blocked_bubble_contents.cc b/chrome/browser/views/content_blocked_bubble_contents.cc
index 8d53c5a..4ba0b34 100644
--- a/chrome/browser/views/content_blocked_bubble_contents.cc
+++ b/chrome/browser/views/content_blocked_bubble_contents.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/views/content_blocked_bubble_contents.h"
#include "app/l10n_util.h"
+#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/views/info_bubble.h"
#include "grit/generated_resources.h"
#include "views/controls/button/native_button.h"
@@ -20,10 +22,12 @@
ContentBlockedBubbleContents::ContentBlockedBubbleContents(
ContentSettingsType content_type,
- const std::wstring& host,
+ const std::string& host,
+ const std::wstring& display_host,
Profile* profile)
: content_type_(content_type),
host_(host),
+ display_host_(display_host),
profile_(profile),
info_bubble_(NULL),
allow_radio_(NULL),
@@ -49,7 +53,9 @@ void ContentBlockedBubbleContents::ButtonPressed(views::Button* sender,
return;
}
- // TODO(pkasting): Set block state for this host and content type.
+ DCHECK((sender == allow_radio_) || (sender == block_radio_));
+ profile_->GetHostContentSettingsMap()->SetContentSetting(host_, content_type_,
+ allow_radio_->checked() ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
}
void ContentBlockedBubbleContents::LinkActivated(views::Link* source,
@@ -124,7 +130,7 @@ void ContentBlockedBubbleContents::InitControlLayout() {
static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES));
const int radio_button_group = 0;
allow_radio_ = new views::RadioButton(
- l10n_util::GetStringF(kAllowIDs[content_type_], host_),
+ l10n_util::GetStringF(kAllowIDs[content_type_], display_host_),
radio_button_group);
allow_radio_->set_listener(this);
diff --git a/chrome/browser/views/content_blocked_bubble_contents.h b/chrome/browser/views/content_blocked_bubble_contents.h
index 8d03196..7b7c434 100644
--- a/chrome/browser/views/content_blocked_bubble_contents.h
+++ b/chrome/browser/views/content_blocked_bubble_contents.h
@@ -34,7 +34,8 @@ class ContentBlockedBubbleContents : public views::View,
public views::LinkController {
public:
ContentBlockedBubbleContents(ContentSettingsType content_type,
- const std::wstring& host,
+ const std::string& host,
+ const std::wstring& display_host,
Profile* profile);
virtual ~ContentBlockedBubbleContents();
@@ -59,7 +60,8 @@ class ContentBlockedBubbleContents : public views::View,
ContentSettingsType content_type_;
// The hostname affected.
- std::wstring host_;
+ std::string host_;
+ std::wstring display_host_;
// The active profile.
Profile* profile_;
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index 6b67077..846ef73 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -221,8 +221,7 @@ void LocationBarView::Init() {
security_image_view_.SetVisible(false);
security_image_view_.set_parent_owned(false);
- for (int i = CONTENT_SETTINGS_FIRST_TYPE; i < CONTENT_SETTINGS_NUM_TYPES;
- ++i) {
+ for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
ContentBlockedImageView* content_blocked_view =
new ContentBlockedImageView(static_cast<ContentSettingsType>(i), this,
profile_, bubble_positioner_);
@@ -347,16 +346,9 @@ void LocationBarView::SetProfile(Profile* profile) {
}
}
-std::wstring LocationBarView::GetHost() const {
+GURL LocationBarView::GetURL() const {
const TabContents* tab_contents = delegate_->GetTabContents();
- if (!tab_contents)
- return std::wstring();
-
- std::wstring host;
- net::AppendFormattedHost(tab_contents->GetURL(),
- profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &host, NULL,
- NULL);
- return host;
+ return tab_contents ? tab_contents->GetURL() : GURL();
}
void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction *page_action,
@@ -1340,7 +1332,7 @@ LocationBarView::ContentBlockedImageView::ContentBlockedImageView(
profile_(profile),
info_bubble_(NULL),
bubble_positioner_(bubble_positioner) {
- if (!icons_[CONTENT_SETTINGS_FIRST_TYPE]) {
+ if (!icons_[CONTENT_SETTINGS_TYPE_COOKIES]) {
static const int kIconIDs[] = {
IDR_BLOCKED_COOKIES,
IDR_BLOCKED_IMAGES,
@@ -1351,8 +1343,7 @@ LocationBarView::ContentBlockedImageView::ContentBlockedImageView(
DCHECK_EQ(arraysize(kIconIDs),
static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES));
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- for (int i = CONTENT_SETTINGS_FIRST_TYPE; i < CONTENT_SETTINGS_NUM_TYPES;
- ++i)
+ for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
icons_[i] = rb.GetBitmapNamed(kIconIDs[i]);
}
SetImage(icons_[content_type_]);
@@ -1382,8 +1373,13 @@ bool LocationBarView::ContentBlockedImageView::OnMousePressed(
bounds.set_x(location.x());
bounds.set_width(width());
+ GURL url = parent_->GetURL();
+ std::wstring display_host;
+ net::AppendFormattedHost(url,
+ profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), &display_host,
+ NULL, NULL);
ContentBlockedBubbleContents* bubble_contents =
- new ContentBlockedBubbleContents(content_type_, parent_->GetHost(),
+ new ContentBlockedBubbleContents(content_type_, url.host(), display_host,
profile_);
DCHECK(!info_bubble_);
info_bubble_ = InfoBubble::Show(GetWindow(), bounds, bubble_contents, this);
diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h
index fedee9d..4b405c3 100644
--- a/chrome/browser/views/location_bar_view.h
+++ b/chrome/browser/views/location_bar_view.h
@@ -102,9 +102,9 @@ class LocationBarView : public LocationBar,
void SetProfile(Profile* profile);
Profile* profile() { return profile_; }
- // Returns the display-formatted hostname for the current page. This should
- // only be used by the ContentBlockedImageView.
- std::wstring GetHost() const;
+ // Returns the URL for the current page. This should only be used by the
+ // ContentBlockedImageView.
+ GURL GetURL() const;
// Sets |preview_enabled| for the PageAction View associated with this
// |page_action|. If |preview_enabled| is true, the view will display the
diff --git a/chrome/browser/views/options/content_filter_page_view.cc b/chrome/browser/views/options/content_filter_page_view.cc
index 09a0f09..bb61d7c 100644
--- a/chrome/browser/views/options/content_filter_page_view.cc
+++ b/chrome/browser/views/options/content_filter_page_view.cc
@@ -8,6 +8,8 @@
#include "app/gfx/native_theme_win.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/profile.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -17,108 +19,121 @@
#include "views/widget/widget.h"
#include "views/window/window.h"
-static const int kAllowRadioGroup = 1;
-
ContentFilterPageView::ContentFilterPageView(Profile* profile,
- int label_message_id,
- int allow_radio_message_id,
- int block_radio_message_id)
- : label_message_id_(label_message_id),
- allow_radio_message_id_(allow_radio_message_id),
- block_radio_message_id_(block_radio_message_id),
- caption_label_(NULL),
+ ContentSettingsType content_type)
+ : OptionsPageView(profile),
+ content_type_(content_type),
allow_radio_(NULL),
block_radio_(NULL),
- exceptions_button_(NULL),
- OptionsPageView(profile) {
+ exceptions_button_(NULL) {
}
ContentFilterPageView::~ContentFilterPageView() {
}
-///////////////////////////////////////////////////////////////////////////////
-// ContentFilterPageView, views::ButtonListener implementation:
-
-void ContentFilterPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == allow_radio_ || sender == block_radio_)
- OnAllowedChanged(allow_radio_->checked());
- else if (sender == exceptions_button_)
- OnShowExceptionsDialog();
-}
-
////////////////////////////////////////////////////////////////////////////////
// ContentFilterPageView, OptionsPageView implementation:
void ContentFilterPageView::InitControlLayout() {
// Make sure we don't leak memory by calling this more than once.
DCHECK(!exceptions_button_);
using views::GridLayout;
- using views::ColumnSet;
- exceptions_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_COOKIES_EXCEPTIONS_BUTTON));
- caption_label_ = new views::Label(
- l10n_util::GetString(label_message_id_));
- caption_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- caption_label_->SetMultiLine(true);
+ GridLayout* layout = new GridLayout(this);
+ layout->SetInsets(5, 5, 5, 5);
+ SetLayoutManager(layout);
+ const int single_column_set_id = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(single_column_set_id);
+ column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
+ column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
+ GridLayout::USE_PREF, 0, 0);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ static const int kTitleIDs[] = {
+ 0, // This dialog isn't used for cookies.
+ IDS_IMAGES_SETTING_LABEL,
+ IDS_JS_SETTING_LABEL,
+ IDS_PLUGIN_SETTING_LABEL,
+ IDS_POPUP_SETTING_LABEL,
+ };
+ DCHECK_EQ(arraysize(kTitleIDs),
+ static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES));
+ views::Label* title_label = new views::Label(
+ l10n_util::GetString(kTitleIDs[content_type_]));
+ title_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ title_label->SetMultiLine(true);
+
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(title_label);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ static const int kAllowIDs[] = {
+ 0, // This dialog isn't used for cookies.
+ IDS_IMAGES_LOAD_RADIO,
+ IDS_JS_ALLOW_RADIO,
+ IDS_PLUGIN_LOAD_RADIO,
+ IDS_POPUP_ALLOW_RADIO,
+ };
+ DCHECK_EQ(arraysize(kAllowIDs),
+ static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES));
+ const int radio_button_group = 0;
allow_radio_ = new views::RadioButton(
- l10n_util::GetString(allow_radio_message_id_),
- kAllowRadioGroup);
+ l10n_util::GetString(kAllowIDs[content_type_]), radio_button_group);
allow_radio_->set_listener(this);
allow_radio_->SetMultiLine(true);
+
+ static const int kBlockIDs[] = {
+ 0, // This dialog isn't used for cookies.
+ IDS_IMAGES_NOLOAD_RADIO,
+ IDS_JS_DONOTALLOW_RADIO,
+ IDS_PLUGIN_NOLOAD_RADIO,
+ IDS_POPUP_BLOCK_RADIO,
+ };
+ DCHECK_EQ(arraysize(kBlockIDs),
+ static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES));
block_radio_ = new views::RadioButton(
- l10n_util::GetString(block_radio_message_id_),
- kAllowRadioGroup);
+ l10n_util::GetString(kBlockIDs[content_type_]), radio_button_group);
block_radio_->set_listener(this);
block_radio_->SetMultiLine(true);
-
- GridLayout* layout = new GridLayout(this);
- layout->SetInsets(5, 5, 5, 5);
- SetLayoutManager(layout);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- const int label_view_set_id = 0;
- ColumnSet* label_column_set = layout->AddColumnSet(label_view_set_id);
- label_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- label_column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, label_view_set_id);
- layout->AddView(caption_label_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
-
- const int radio_view_set_id = 1;
- ColumnSet* radio_column_set = layout->AddColumnSet(radio_view_set_id);
- radio_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- radio_column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, radio_view_set_id);
+ layout->StartRow(0, single_column_set_id);
layout->AddView(allow_radio_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, radio_view_set_id);
+ layout->StartRow(0, single_column_set_id);
layout->AddView(block_radio_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- const int button_view_set_id = 2;
- ColumnSet* button_column_set = layout->AddColumnSet(button_view_set_id);
- button_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- button_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, button_view_set_id);
- layout->AddView(exceptions_button_);
-}
-
-void ContentFilterPageView::Layout() {
- views::View* parent = GetParent();
- if (parent && parent->width()) {
- const int width = parent->width();
- const int height = GetHeightForWidth(width);
- SetBounds(0, 0, width, height);
+ ContentSetting default_setting = profile()->GetHostContentSettingsMap()->
+ GetDefaultContentSetting(content_type_);
+ // Now that these have been added to the view hierarchy, it's safe to call
+ // SetChecked() on them.
+ if (default_setting == CONTENT_SETTING_ALLOW) {
+ allow_radio_->SetChecked(true);
} else {
- gfx::Size prefsize = GetPreferredSize();
- SetBounds(0, 0, prefsize.width(), prefsize.height());
+ DCHECK(default_setting == CONTENT_SETTING_BLOCK);
+ block_radio_->SetChecked(true);
}
- View::Layout();
+
+ exceptions_button_ = new views::NativeButton(this,
+ l10n_util::GetString(IDS_COOKIES_EXCEPTIONS_BUTTON));
+
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(exceptions_button_, 1, 1, GridLayout::LEADING,
+ GridLayout::FILL);
}
+///////////////////////////////////////////////////////////////////////////////
+// ContentFilterPageView, views::ButtonListener implementation:
+
+void ContentFilterPageView::ButtonPressed(views::Button* sender,
+ const views::Event& event) {
+ if (sender == exceptions_button_) {
+ // TODO(pkasting): Show exceptions dialog
+ return;
+ }
+
+ DCHECK((sender == allow_radio_) || (sender == block_radio_));
+ profile()->GetHostContentSettingsMap()->SetDefaultContentSetting(
+ content_type_,
+ allow_radio_->checked() ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
+}
diff --git a/chrome/browser/views/options/content_filter_page_view.h b/chrome/browser/views/options/content_filter_page_view.h
index 862b796..1370b77 100644
--- a/chrome/browser/views/options/content_filter_page_view.h
+++ b/chrome/browser/views/options/content_filter_page_view.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_FILTER_PAGE_VIEW_H_
#include "chrome/browser/views/options/options_page_view.h"
+#include "chrome/common/content_settings_types.h"
#include "chrome/common/pref_member.h"
#include "views/controls/button/button.h"
#include "views/view.h"
@@ -18,49 +19,31 @@ class RadioButton;
class PrefService;
////////////////////////////////////////////////////////////////////////////////
-// ContentFilterPageView class is used to render Images, JavaScript and
-// Plug-ins page in Content Settings dialog
+// The ContentFilterPageView class is used to render the Images, JavaScript,
+// Plug-ins and Pop-ups pages in the Content Settings window.
class ContentFilterPageView : public OptionsPageView,
public views::ButtonListener {
public:
- ContentFilterPageView(Profile* profile,
- int label_message_id,
- int allow_radio_message_id,
- int block_radio_message_id);
+ ContentFilterPageView(Profile* profile, ContentSettingsType content_type);
virtual ~ContentFilterPageView();
protected:
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
// OptionsPageView implementation:
virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::wstring* pref_name) {}
-
- // views::View overrides:
- virtual void Layout();
-
- // Signals that allowed radio button state has changed.
- virtual void OnAllowedChanged(bool allowed) {}
- // Signals that exceptions dialog should be shown.
- virtual void OnShowExceptionsDialog() {}
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
private:
+ ContentSettingsType content_type_;
+
// Controls for the content filter tab page.
- views::Label* caption_label_;
views::RadioButton* allow_radio_;
views::RadioButton* block_radio_;
views::NativeButton* exceptions_button_;
- // Message ids for above UI controls.
- int label_message_id_;
- int allow_radio_message_id_;
- int block_radio_message_id_;
-
DISALLOW_COPY_AND_ASSIGN(ContentFilterPageView);
};
#endif // CHROME_BROWSER_VIEWS_OPTIONS_CONTENT_FILTER_PAGE_VIEW_H_
-
diff --git a/chrome/browser/views/options/content_settings_window_view.cc b/chrome/browser/views/options/content_settings_window_view.cc
index 80f129a..2759e40 100644
--- a/chrome/browser/views/options/content_settings_window_view.cc
+++ b/chrome/browser/views/options/content_settings_window_view.cc
@@ -131,37 +131,25 @@ void ContentSettingsWindowView::Init() {
cookie_page, false);
ContentFilterPageView* image_page =
- new ContentFilterPageView(profile_,
- IDS_IMAGES_SETTING_LABEL,
- IDS_IMAGES_LOAD_RADIO,
- IDS_IMAGES_NOLOAD_RADIO);
+ new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_IMAGES);
tabs_->AddTabAtIndex(tab_index++,
l10n_util::GetString(IDS_IMAGES_TAB_LABEL),
image_page, false);
ContentFilterPageView* javascript_page =
- new ContentFilterPageView(profile_,
- IDS_JS_SETTING_LABEL,
- IDS_JS_ALLOW_RADIO,
- IDS_JS_DONOTALLOW_RADIO);
+ new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_JAVASCRIPT);
tabs_->AddTabAtIndex(tab_index++,
l10n_util::GetString(IDS_JAVASCRIPT_TAB_LABEL),
javascript_page, false);
ContentFilterPageView* plugin_page =
- new ContentFilterPageView(profile_,
- IDS_PLUGIN_SETTING_LABEL,
- IDS_PLUGIN_LOAD_RADIO,
- IDS_PLUGIN_NOLOAD_RADIO);
+ new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_PLUGINS);
tabs_->AddTabAtIndex(tab_index++,
l10n_util::GetString(IDS_PLUGIN_TAB_LABEL),
plugin_page, false);
ContentFilterPageView* popup_page =
- new ContentFilterPageView(profile_,
- IDS_POPUP_SETTING_LABEL,
- IDS_POPUP_ALLOW_RADIO,
- IDS_POPUP_BLOCK_RADIO);
+ new ContentFilterPageView(profile_, CONTENT_SETTINGS_TYPE_POPUPS);
tabs_->AddTabAtIndex(tab_index++,
l10n_util::GetString(IDS_POPUP_TAB_LABEL),
popup_page, false);
@@ -182,11 +170,11 @@ void ContentSettingsWindowView::ShowContentSettingsTab(
// Remember the last visited page from local state.
page = static_cast<ContentSettingsType>(last_selected_page_.GetValue());
if (page == CONTENT_SETTINGS_TYPE_DEFAULT)
- page = CONTENT_SETTINGS_FIRST_TYPE;
+ page = CONTENT_SETTINGS_TYPE_COOKIES;
}
// If the page number is out of bounds, reset to the first tab.
if (page < 0 || page >= tabs_->GetTabCount())
- page = CONTENT_SETTINGS_FIRST_TYPE;
+ page = CONTENT_SETTINGS_TYPE_COOKIES;
tabs_->SelectTabAt(static_cast<int>(page));
}
diff --git a/chrome/browser/views/options/cookie_filter_page_view.cc b/chrome/browser/views/options/cookie_filter_page_view.cc
index 36486c0..7abe096 100644
--- a/chrome/browser/views/options/cookie_filter_page_view.cc
+++ b/chrome/browser/views/options/cookie_filter_page_view.cc
@@ -8,6 +8,9 @@
#include "app/gfx/native_theme_win.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "chrome/browser/browser.h"
+#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/views/options/cookies_view.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
@@ -19,19 +22,14 @@
#include "views/widget/widget.h"
#include "views/window/window.h"
-static const int kAllowRadioGroup = 1;
-static const int kFilterPageInset = 5;
-
CookieFilterPageView::CookieFilterPageView(Profile* profile)
- : caption_label_(NULL),
- allow_radio_(NULL),
+ : allow_radio_(NULL),
ask_radio_(NULL),
block_radio_(NULL),
exceptions_button_(NULL),
block_3rdparty_check_(NULL),
clear_on_close_check_(NULL),
show_cookies_button_(NULL),
- flash_settings_link_(NULL),
OptionsPageView(profile) {
}
@@ -39,174 +37,154 @@ CookieFilterPageView::~CookieFilterPageView() {
}
///////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView, views::ButtonListener implementation:
-
-void CookieFilterPageView::ButtonPressed(
- views::Button* sender, const views::Event& event) {
- if (sender == allow_radio_) {
- SetAllowCookies(COOKIES_ALLOWED_ALLOW);
- } else if (sender == ask_radio_) {
- SetAllowCookies(COOKIES_ALLOWED_ASK);
- } else if (sender == block_radio_) {
- SetAllowCookies(COOKIES_ALLOWED_BLOCK);
- } else if (sender == exceptions_button_) {
- ShowCookieExceptionsDialog();
- } else if (sender == block_3rdparty_check_) {
- SetBlock3rdPartyCookies(block_3rdparty_check_->checked());
- } else if (sender == clear_on_close_check_) {
- SetBlock3rdPartyCookies(block_3rdparty_check_->checked());
- } else if (sender == show_cookies_button_) {
- ShowCookieManagerDialog();
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CookieFilterPageView, views::LinkController implementation:
-void CookieFilterPageView::LinkActivated(views::Link* source,
- int event_flags) {
- if (source == flash_settings_link_)
- OpenFlashSettingsDialog();
-}
-
-// TODO(zelidrag): Hook setters for preference settings here:
-void CookieFilterPageView::SetAllowCookies(CookiesAllowed allowed) {
-}
-
-void CookieFilterPageView::ShowCookieExceptionsDialog() {
-}
-
-void CookieFilterPageView::SetBlock3rdPartyCookies(bool block) {
-}
-
-void CookieFilterPageView::SetClearCookiesOnClose(bool clear) {
-}
-
-void CookieFilterPageView::OpenFlashSettingsDialog() {
-}
-
-void CookieFilterPageView::ShowCookieManagerDialog() {
- UserMetricsRecordAction("Options_ShowCookies", NULL);
- CookiesView::ShowCookiesWindow(profile());
-}
-
-///////////////////////////////////////////////////////////////////////////////
// CookieFilterPageView, OptionsPageView implementation:
void CookieFilterPageView::InitControlLayout() {
using views::GridLayout;
- using views::ColumnSet;
- caption_label_ = new views::Label(
+ GridLayout* layout = new GridLayout(this);
+ layout->SetInsets(5, 5, 5, 5);
+ SetLayoutManager(layout);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ const int single_column_set_id = 0;
+ views::ColumnSet* column_set = layout->AddColumnSet(single_column_set_id);
+ column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
+ column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
+ GridLayout::USE_PREF, 0, 0);
+
+ views::Label* title_label = new views::Label(
l10n_util::GetString(IDS_MODIFY_COOKIE_STORING_LABEL));
- caption_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- caption_label_->SetMultiLine(true);
+ title_label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ title_label->SetMultiLine(true);
+
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(title_label);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ const int radio_button_group = 0;
allow_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_COOKIES_ALLOW_RADIO),
- kAllowRadioGroup);
+ l10n_util::GetString(IDS_COOKIES_ALLOW_RADIO), radio_button_group);
allow_radio_->set_listener(this);
allow_radio_->SetMultiLine(true);
ask_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_COOKIES_ASK_EVERY_TIME_RADIO),
- kAllowRadioGroup);
+ radio_button_group);
ask_radio_->set_listener(this);
ask_radio_->SetMultiLine(true);
block_radio_ = new views::RadioButton(
- l10n_util::GetString(IDS_COOKIES_BLOCK_RADIO),
- kAllowRadioGroup);
+ l10n_util::GetString(IDS_COOKIES_BLOCK_RADIO), radio_button_group);
block_radio_->set_listener(this);
block_radio_->SetMultiLine(true);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(allow_radio_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(ask_radio_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(block_radio_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ const HostContentSettingsMap* settings_map =
+ profile()->GetHostContentSettingsMap();
+ ContentSetting default_setting =
+ settings_map->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES);
+ // Now that these have been added to the view hierarchy, it's safe to call
+ // SetChecked() on them.
+ if (default_setting == CONTENT_SETTING_ALLOW) {
+ allow_radio_->SetChecked(true);
+ } else if (default_setting == CONTENT_SETTING_BLOCK) {
+ block_radio_->SetChecked(true);
+ } else {
+ DCHECK(default_setting == CONTENT_SETTING_ASK);
+ ask_radio_->SetChecked(true);
+ }
+
exceptions_button_ = new views::NativeButton(this,
l10n_util::GetString(IDS_COOKIES_EXCEPTIONS_BUTTON));
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(exceptions_button_, 1, 1, GridLayout::LEADING,
+ GridLayout::FILL);
+ layout->AddPaddingRow(0, kUnrelatedControlLargeVerticalSpacing);
+
block_3rdparty_check_ = new views::Checkbox(
l10n_util::GetString(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX));
block_3rdparty_check_->set_listener(this);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(block_3rdparty_check_);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ // Now that this has been added to the view hierarchy, it's safe to call
+ // SetChecked() on it.
+ block_3rdparty_check_->SetChecked(settings_map->BlockThirdPartyCookies());
+
clear_on_close_check_ = new views::Checkbox(
l10n_util::GetString(IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX));
clear_on_close_check_->set_listener(this);
- show_cookies_button_ = new views::NativeButton(this,
- l10n_util::GetString(IDS_COOKIES_SHOW_COOKIES_BUTTON));
-
- flash_settings_link_ = new views::Link(
- l10n_util::GetString(IDS_FLASH_STORAGE_SETTINGS));
- flash_settings_link_->SetController(this);
+ // TODO(pkasting): Set clear-on-close checkbox to be checked or not.
- GridLayout* layout = new GridLayout(this);
- layout->SetInsets(kFilterPageInset, kFilterPageInset, kFilterPageInset,
- kFilterPageInset);
- SetLayoutManager(layout);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(clear_on_close_check_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- const int label_view_set_id = 0;
- ColumnSet* label_column_set = layout->AddColumnSet(label_view_set_id);
- label_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- label_column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, label_view_set_id);
- layout->AddView(caption_label_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ show_cookies_button_ = new views::NativeButton(this,
+ l10n_util::GetString(IDS_COOKIES_SHOW_COOKIES_BUTTON));
- const int radio_view_set_id = 1;
- ColumnSet* radio_column_set = layout->AddColumnSet(radio_view_set_id);
- radio_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- radio_column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, radio_view_set_id);
- layout->AddView(allow_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, radio_view_set_id);
- layout->AddView(ask_radio_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, radio_view_set_id);
- layout->AddView(block_radio_);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(show_cookies_button_, 1, 1, GridLayout::LEADING,
+ GridLayout::FILL);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- const int exceptions_button_view_set_id = 2;
- ColumnSet* button_column_set = layout->AddColumnSet(
- exceptions_button_view_set_id);
- button_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- button_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, exceptions_button_view_set_id);
- layout->AddView(exceptions_button_);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
- layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
-
- const int check_view_set_id = 3;
- ColumnSet* check_column_set = layout->AddColumnSet(check_view_set_id);
- check_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- check_column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, check_view_set_id);
- layout->AddView(block_3rdparty_check_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
- layout->StartRow(0, check_view_set_id);
- layout->AddView(clear_on_close_check_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ views::Link* flash_settings_link = new views::Link(
+ l10n_util::GetString(IDS_FLASH_STORAGE_SETTINGS));
+ flash_settings_link->SetController(this);
- const int mgr_button_view_set_id = 4;
- ColumnSet* mgr_button_column_set =
- layout->AddColumnSet(mgr_button_view_set_id);
- mgr_button_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- mgr_button_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, mgr_button_view_set_id);
- layout->AddView(show_cookies_button_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ layout->StartRow(0, single_column_set_id);
+ layout->AddView(flash_settings_link, 1, 1, GridLayout::LEADING,
+ GridLayout::FILL);
+}
- const int link_view_set_id = 5;
- ColumnSet* link_column_set = layout->AddColumnSet(link_view_set_id);
- link_column_set->AddPaddingColumn(0, kRelatedControlVerticalSpacing);
- link_column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 1,
- GridLayout::USE_PREF, 0, 0);
- layout->StartRow(0, link_view_set_id);
- layout->AddView(flash_settings_link_);
- layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+///////////////////////////////////////////////////////////////////////////////
+// CookieFilterPageView, views::ButtonListener implementation:
+
+void CookieFilterPageView::ButtonPressed(
+ views::Button* sender, const views::Event& event) {
+ HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
+ if (sender == allow_radio_) {
+ settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
+ CONTENT_SETTING_ALLOW);
+ } else if (sender == ask_radio_) {
+ settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
+ CONTENT_SETTING_ASK);
+ } else if (sender == block_radio_) {
+ settings_map->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES,
+ CONTENT_SETTING_BLOCK);
+ } else if (sender == exceptions_button_) {
+ // TODO(pkasting): Show exceptions dialog.
+ } else if (sender == block_3rdparty_check_) {
+ settings_map->SetBlockThirdPartyCookies(block_3rdparty_check_->checked());
+ } else if (sender == clear_on_close_check_) {
+ // TODO(pkasting): Set clear-on-close setting.
+ } else {
+ DCHECK_EQ(sender, show_cookies_button_);
+ UserMetricsRecordAction("Options_ShowCookies", NULL);
+ CookiesView::ShowCookiesWindow(profile());
+ }
}
+///////////////////////////////////////////////////////////////////////////////
+// CookieFilterPageView, views::LinkController implementation:
+void CookieFilterPageView::LinkActivated(views::Link* source, int event_flags) {
+ // We open a new browser window so the Options dialog doesn't get lost
+ // behind other windows.
+ Browser* browser = Browser::Create(profile());
+ browser->OpenURL(GURL(l10n_util::GetString(IDS_FLASH_STORAGE_URL)), GURL(),
+ NEW_WINDOW, PageTransition::LINK);
+}
diff --git a/chrome/browser/views/options/cookie_filter_page_view.h b/chrome/browser/views/options/cookie_filter_page_view.h
index 7bcc909..812e1dd 100644
--- a/chrome/browser/views/options/cookie_filter_page_view.h
+++ b/chrome/browser/views/options/cookie_filter_page_view.h
@@ -30,45 +30,18 @@ class CookieFilterPageView : public OptionsPageView,
explicit CookieFilterPageView(Profile* profile);
virtual ~CookieFilterPageView();
- // views::ButtonListener implementation:
- virtual void ButtonPressed(views::Button* sender, const views::Event& event);
-
- // Overridden from views::LinkController:
- virtual void LinkActivated(views::Link* source, int event_flags);
-
private:
- typedef enum {
- COOKIES_ALLOWED_DEFAULT = 0,
- COOKIES_ALLOWED_ALLOW = 0,
- COOKIES_ALLOWED_ASK,
- COOKIES_ALLOWED_BLOCK,
- } CookiesAllowed;
-
// OptionsPageView implementation:
virtual void InitControlLayout();
- virtual void NotifyPrefChanged(const std::wstring* pref_name) {}
-
- // Handles that allowed radio button state has changed.
- void SetAllowCookies(CookiesAllowed allowed);
- // Handles click on exceptions dialog.
- void ShowCookieExceptionsDialog();
-
- // Handles change in block 3rd party cookies checkbox.
- void SetBlock3rdPartyCookies(bool block);
-
- // Handles change in clean on close checkbox.
- void SetClearCookiesOnClose(bool clear);
-
- // Handles click on flash settings link.
- void OpenFlashSettingsDialog();
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
- // Opens cookie manager dialog.
- void ShowCookieManagerDialog();
+ // Overridden from views::LinkController:
+ virtual void LinkActivated(views::Link* source, int event_flags);
private:
// Controls for the cookie filter tab page view.
- views::Label* caption_label_;
views::RadioButton* allow_radio_;
views::RadioButton* ask_radio_;
views::RadioButton* block_radio_;
@@ -76,7 +49,6 @@ class CookieFilterPageView : public OptionsPageView,
views::Checkbox* block_3rdparty_check_;
views::Checkbox* clear_on_close_check_;
views::NativeButton* show_cookies_button_;
- views::Link* flash_settings_link_;
DISALLOW_COPY_AND_ASSIGN(CookieFilterPageView);
};
diff --git a/chrome/common/content_settings.h b/chrome/common/content_settings.h
index 59d58c8..3e798b3 100644
--- a/chrome/common/content_settings.h
+++ b/chrome/common/content_settings.h
@@ -10,8 +10,7 @@
// Different settings that can be assigned for a particular content type. We
// give the user the ability to set these on a global and per-host basis.
enum ContentSetting {
- CONTENT_SETTING_FIRST_SETTING = 0,
- CONTENT_SETTING_DEFAULT = CONTENT_SETTING_FIRST_SETTING,
+ CONTENT_SETTING_DEFAULT = 0,
CONTENT_SETTING_ALLOW,
CONTENT_SETTING_BLOCK,
CONTENT_SETTING_ASK,
@@ -21,8 +20,7 @@ enum ContentSetting {
// Aggregates the permissions for the different content types.
struct ContentSettings {
ContentSettings() {
- for (int i = CONTENT_SETTINGS_FIRST_TYPE; i < CONTENT_SETTINGS_NUM_TYPES;
- ++i)
+ for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i)
settings[i] = CONTENT_SETTING_DEFAULT;
}
diff --git a/chrome/common/content_settings_types.h b/chrome/common/content_settings_types.h
index 2026bac..3eb8595 100644
--- a/chrome/common/content_settings_types.h
+++ b/chrome/common/content_settings_types.h
@@ -11,8 +11,7 @@ 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_COOKIES = 0,
CONTENT_SETTINGS_TYPE_IMAGES,
CONTENT_SETTINGS_TYPE_JAVASCRIPT,
CONTENT_SETTINGS_TYPE_PLUGINS,
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index ad07566..f9d9c9c 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -295,13 +295,17 @@ const wchar_t kDesktopNotificationAllowedOrigins[] =
const wchar_t kDesktopNotificationDeniedOrigins[] =
L"profile.notification_denied_sites";
-// Bitmask of content settings applied to hosts per default.
+// Dictionary of content settings applied to all hosts by default.
const wchar_t kDefaultContentSettings[] = L"profile.default_content_settings";
// Dictionary that maps hostnames to content related settings. Default
// settings will be applied to hosts not in this pref.
const wchar_t kPerHostContentSettings[] = L"profile.per_host_content_settings";
+// Boolean that is true if we should unconditionally block third-party cookies,
+// regardless of other content settings.
+const wchar_t kBlockThirdPartyCookies[] = L"profile.block_third_party_cookies";
+
// Dictionary that maps hostnames to zoom levels. Hosts not in this pref will
// be displayed at the default zoom level.
const wchar_t kPerHostZoomLevels[] = L"profile.per_host_zoom_levels";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 2afb1e5..4e0b446 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -120,6 +120,7 @@ extern const wchar_t kDesktopNotificationAllowedOrigins[];
extern const wchar_t kDesktopNotificationDeniedOrigins[];
extern const wchar_t kDefaultContentSettings[];
extern const wchar_t kPerHostContentSettings[];
+extern const wchar_t kBlockThirdPartyCookies[];
extern const wchar_t kPerHostZoomLevels[];
extern const wchar_t kAutoFillInfoBarShown[];
extern const wchar_t kAutoFillEnabled[];