diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 15:42:50 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-22 15:42:50 +0000 |
commit | 21a118609070d5d32df0aa01ce9b4b6a75d53dfb (patch) | |
tree | 151842dc196a0b893493ce2e825ecd512b258886 | |
parent | fa6a910e5401983a7faa0489e7a26643fd7a2c0a (diff) | |
download | chromium_src-21a118609070d5d32df0aa01ce9b4b6a75d53dfb.zip chromium_src-21a118609070d5d32df0aa01ce9b4b6a75d53dfb.tar.gz chromium_src-21a118609070d5d32df0aa01ce9b4b6a75d53dfb.tar.bz2 |
Disable content settings UI for managed default content settings (View).
BUG=63178
TEST=none
Review URL: http://codereview.chromium.org/5137010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66955 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 74 insertions, 6 deletions
diff --git a/chrome/browser/ui/views/options/content_filter_page_view.cc b/chrome/browser/ui/views/options/content_filter_page_view.cc index 6b0c220..320611d 100644 --- a/chrome/browser/ui/views/options/content_filter_page_view.cc +++ b/chrome/browser/ui/views/options/content_filter_page_view.cc @@ -15,6 +15,9 @@ #include "chrome/browser/views/options/exceptions_view.h" #include "chrome/browser/views/options/simple_content_exceptions_view.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/notification_details.h" +#include "chrome/common/notification_service.h" +#include "chrome/common/notification_type.h" #include "grit/generated_resources.h" #include "views/controls/button/radio_button.h" #include "views/grid_layout.h" @@ -138,7 +141,24 @@ void ContentFilterPageView::InitControlLayout() { layout->AddView(block_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + 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); + + UpdateView(); + + registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, + NotificationService::AllSources()); +} + +/////////////////////////////////////////////////////////////////////////////// +// ContentFilterPageView, +void ContentFilterPageView::UpdateView() { ContentSetting default_setting; + bool is_content_type_managed = false; if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) { default_setting = profile()->GetGeolocationContentSettingsMap()-> GetDefaultContentSetting(); @@ -148,6 +168,8 @@ void ContentFilterPageView::InitControlLayout() { } else { default_setting = profile()->GetHostContentSettingsMap()-> GetDefaultContentSetting(content_type_); + is_content_type_managed = profile()->GetHostContentSettingsMap()-> + IsDefaultContentSettingManaged(content_type_); } // Now that these have been added to the view hierarchy, it's safe to call // SetChecked() on them. @@ -161,12 +183,12 @@ void ContentFilterPageView::InitControlLayout() { block_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); + // Set enable state of the buttons. + allow_radio_->SetEnabled(!is_content_type_managed); + if (ask_radio_) + ask_radio_->SetEnabled(!is_content_type_managed); + block_radio_->SetEnabled(!is_content_type_managed); + exceptions_button_->SetEnabled(!is_content_type_managed); } /////////////////////////////////////////////////////////////////////////////// @@ -229,3 +251,23 @@ void ContentFilterPageView::ButtonPressed(views::Button* sender, content_type_, default_setting); } } + +void ContentFilterPageView::NotifyContentSettingsChanged( + const HostContentSettingsMap::ContentSettingsDetails *details) { + if (details->type() == CONTENT_SETTINGS_TYPE_DEFAULT || + details->type() == content_type_) { + UpdateView(); + } +} + +void ContentFilterPageView::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + if (type == NotificationType::CONTENT_SETTINGS_CHANGED) { + NotifyContentSettingsChanged( + Details<HostContentSettingsMap::ContentSettingsDetails> + (details).ptr()); + } else { + OptionsPageBase::Observe(type, source, details); + } +} diff --git a/chrome/browser/ui/views/options/content_filter_page_view.h b/chrome/browser/ui/views/options/content_filter_page_view.h index baa96d10..dd4629e 100644 --- a/chrome/browser/ui/views/options/content_filter_page_view.h +++ b/chrome/browser/ui/views/options/content_filter_page_view.h @@ -6,8 +6,10 @@ #define CHROME_BROWSER_UI_VIEWS_OPTIONS_CONTENT_FILTER_PAGE_VIEW_H_ #pragma once +#include "chrome/browser/host_content_settings_map.h" #include "chrome/browser/views/options/options_page_view.h" #include "chrome/common/content_settings_types.h" +#include "chrome/common/notification_registrar.h" #include "views/controls/button/button.h" namespace views { @@ -27,7 +29,18 @@ class ContentFilterPageView : public OptionsPageView, ContentFilterPageView(Profile* profile, ContentSettingsType content_type); virtual ~ContentFilterPageView(); + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); protected: + // Updates the state of the UI. UpdateView is called when the content filter + // page is initialized and after the content setting changed (either the + // value or the is managed state). + virtual void UpdateView(); + + virtual void NotifyContentSettingsChanged( + const HostContentSettingsMap::ContentSettingsDetails *details); + // OptionsPageView implementation: virtual void InitControlLayout(); @@ -43,6 +56,8 @@ class ContentFilterPageView : public OptionsPageView, views::RadioButton* block_radio_; views::NativeButton* exceptions_button_; + NotificationRegistrar registrar_; + DISALLOW_IMPLICIT_CONSTRUCTORS(ContentFilterPageView); }; diff --git a/chrome/browser/ui/views/options/cookie_filter_page_view.cc b/chrome/browser/ui/views/options/cookie_filter_page_view.cc index d8ab81b..6cfeab7 100644 --- a/chrome/browser/ui/views/options/cookie_filter_page_view.cc +++ b/chrome/browser/ui/views/options/cookie_filter_page_view.cc @@ -23,6 +23,8 @@ CookieFilterPageView::CookieFilterPageView(Profile* profile) show_cookies_button_(NULL) { clear_site_data_on_exit_.Init(prefs::kClearSiteDataOnExit, profile->GetPrefs(), NULL); + block_third_party_cookies_.Init(prefs::kBlockThirdPartyCookies, + profile->GetPrefs(), this); } CookieFilterPageView::~CookieFilterPageView() { @@ -87,6 +89,12 @@ void CookieFilterPageView::NotifyPrefChanged(const std::string* pref_name) { clear_on_close_check_->SetChecked( clear_site_data_on_exit_.GetValue()); } + if (!pref_name || *pref_name == prefs::kBlockThirdPartyCookies) { + block_3rdparty_check_->SetChecked( + block_third_party_cookies_.GetValue()); + block_3rdparty_check_->SetEnabled( + !block_third_party_cookies_.IsManaged()); + } } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/ui/views/options/cookie_filter_page_view.h b/chrome/browser/ui/views/options/cookie_filter_page_view.h index 68c494f..4a03723 100644 --- a/chrome/browser/ui/views/options/cookie_filter_page_view.h +++ b/chrome/browser/ui/views/options/cookie_filter_page_view.h @@ -45,6 +45,9 @@ class CookieFilterPageView : public ContentFilterPageView, // Clear locally stored site data on exit pref. BooleanPrefMember clear_site_data_on_exit_; + // Block all third party cookies. + BooleanPrefMember block_third_party_cookies_; + DISALLOW_IMPLICIT_CONSTRUCTORS(CookieFilterPageView); }; |