diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 18:26:51 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-29 18:26:51 +0000 |
commit | bb23d41f81478e5d6b532dca3676d5415f79a5a7 (patch) | |
tree | aeb82dd3d852c33a71aaf6a69cf19ea48925e296 /chrome/browser/cocoa | |
parent | a70fb57d21815ea4a88774e4d49def1699d86046 (diff) | |
download | chromium_src-bb23d41f81478e5d6b532dca3676d5415f79a5a7.zip chromium_src-bb23d41f81478e5d6b532dca3676d5415f79a5a7.tar.gz chromium_src-bb23d41f81478e5d6b532dca3676d5415f79a5a7.tar.bz2 |
Revert 67560 - Mac: Disable UI elements in the content settings dialog if the controls are managed.
This disables the radio buttons and the exceptions button in the first 5 tabs (cookies, images, javascript, plugins, popups), and the "block 3rd party cookies" checkbox in the cookies tab.
xib change: Hook up the "enabled" bindings of the buttons / radio buttons / checkbox to the new functions. (The cookie radio group's enabled state and exceptions button's enabled state is now bound to cookieSettingsManaged with a NSNegateBoolean value transformer. Likewise for images, javascript, plugins, popups.)
BUG=63181
TEST=none
Review URL: http://codereview.chromium.org/5205008
TBR=thakis@chromium.org
Review URL: http://codereview.chromium.org/5344009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/content_settings_dialog_controller.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/content_settings_dialog_controller.mm | 91 |
2 files changed, 13 insertions, 85 deletions
diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.h b/chrome/browser/cocoa/content_settings_dialog_controller.h index 432a3dc..40e9a04 100644 --- a/chrome/browser/cocoa/content_settings_dialog_controller.h +++ b/chrome/browser/cocoa/content_settings_dialog_controller.h @@ -92,11 +92,4 @@ class Profile; @property(nonatomic) NSInteger pluginsEnabledIndex; @property(nonatomic) NSInteger geolocationSettingIndex; @property(nonatomic) NSInteger notificationsSettingIndex; - -@property(nonatomic, readonly) BOOL blockThirdPartyCookiesManaged; -@property(nonatomic, readonly) BOOL cookieSettingsManaged; -@property(nonatomic, readonly) BOOL imagesSettingsManaged; -@property(nonatomic, readonly) BOOL javaScriptSettingsManaged; -@property(nonatomic, readonly) BOOL pluginsSettingsManaged; -@property(nonatomic, readonly) BOOL popupsSettingsManaged; @end diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.mm b/chrome/browser/cocoa/content_settings_dialog_controller.mm index 6fdcf68..5503f74 100644 --- a/chrome/browser/cocoa/content_settings_dialog_controller.mm +++ b/chrome/browser/cocoa/content_settings_dialog_controller.mm @@ -46,11 +46,7 @@ ContentSettingsDialogController* g_instance = nil; // Callback when preferences are changed. |prefName| is the name of the // pref that has changed. -- (void)prefChanged:(const std::string&)prefName; - -// Callback when content settings are changed. -- (void)contentSettingsChanged: - (HostContentSettingsMap::ContentSettingsDetails*)details; +- (void)prefChanged:(std::string*)prefName; @end @@ -67,21 +63,8 @@ class PrefObserverBridge : public NotificationObserver { virtual void Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - if (disabled_) - return; - - // This is currently used by most notifications. - std::string* detail = Details<std::string>(details).ptr(); - if (type == NotificationType::PREF_CHANGED && detail != NULL) { - [controller_ prefChanged:*detail]; - } - - // This is sent when the "is managed" state changes. - // TODO(markusheintz): Move all content settings to this notification. - if (type == NotificationType::CONTENT_SETTINGS_CHANGED) { - HostContentSettingsMap::ContentSettingsDetails* details = - Details<HostContentSettingsMap::ContentSettingsDetails>(details).ptr(); - [controller_ contentSettingsChanged:details]; + if (!disabled_ && type == NotificationType::PREF_CHANGED) { + [controller_ prefChanged:Details<std::string>(details).ptr()]; } } @@ -95,7 +78,7 @@ class PrefObserverBridge : public NotificationObserver { }; // A C++ utility class to disable notifications for PrefsObserverBridge. -// The intended usage is to create this on the stack. +// The intended usage is to create on the stack. class PrefObserverDisabler { public: PrefObserverDisabler(PrefObserverBridge *bridge) : bridge_(bridge) { @@ -283,11 +266,6 @@ class PrefObserverDisabler { } } -- (BOOL)cookieSettingsManaged { - return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( - CONTENT_SETTINGS_TYPE_COOKIES); -} - - (BOOL)blockThirdPartyCookies { HostContentSettingsMap* settingsMap = profile_->GetHostContentSettingsMap(); return settingsMap->BlockThirdPartyCookies(); @@ -300,11 +278,6 @@ class PrefObserverDisabler { settingsMap->SetBlockThirdPartyCookies(value); } -- (BOOL)blockThirdPartyCookiesManaged { - HostContentSettingsMap* settingsMap = profile_->GetHostContentSettingsMap(); - return settingsMap->IsBlockThirdPartyCookiesManaged(); -} - - (BOOL)clearSiteDataOnExit { return clearSiteDataOnExit_.GetValue(); } @@ -432,11 +405,6 @@ class PrefObserverDisabler { return enabled ? kContentSettingsEnabledIndex : kContentSettingsDisabledIndex; } -- (BOOL)imagesSettingsManaged { - return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( - CONTENT_SETTINGS_TYPE_IMAGES); -} - - (void)setJavaScriptEnabledIndex:(NSInteger)value { ContentSetting setting = value == kContentSettingsEnabledIndex ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; @@ -454,11 +422,6 @@ class PrefObserverDisabler { return enabled ? kContentSettingsEnabledIndex : kContentSettingsDisabledIndex; } -- (BOOL)javaScriptSettingsManaged { - return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( - CONTENT_SETTINGS_TYPE_JAVASCRIPT); -} - - (void)setPluginsEnabledIndex:(NSInteger)value { ContentSetting setting = CONTENT_SETTING_DEFAULT; switch (value) { @@ -500,11 +463,6 @@ class PrefObserverDisabler { } } -- (BOOL)pluginsSettingsManaged { - return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( - CONTENT_SETTINGS_TYPE_PLUGINS); -} - - (void)setPopupsEnabledIndex:(NSInteger)value { ContentSetting setting = value == kContentSettingsEnabledIndex ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; @@ -522,11 +480,6 @@ class PrefObserverDisabler { return enabled ? kContentSettingsEnabledIndex : kContentSettingsDisabledIndex; } -- (BOOL)popupsSettingsManaged { - return profile_->GetHostContentSettingsMap()->IsDefaultContentSettingManaged( - CONTENT_SETTINGS_TYPE_POPUPS); -} - - (void)setGeolocationSettingIndex:(NSInteger)value { ContentSetting setting = CONTENT_SETTING_DEFAULT; switch (value) { @@ -585,22 +538,22 @@ class PrefObserverDisabler { // Callback when preferences are changed. |prefName| is the name of the // pref that has changed and should not be NULL. -- (void)prefChanged:(const std::string&)prefName { - if (prefName == prefs::kClearSiteDataOnExit) { +- (void)prefChanged:(std::string*)prefName { + DCHECK(prefName); + if (!prefName) return; + if (*prefName == prefs::kClearSiteDataOnExit) { [self willChangeValueForKey:@"clearSiteDataOnExit"]; [self didChangeValueForKey:@"clearSiteDataOnExit"]; } - if (prefName == prefs::kBlockThirdPartyCookies) { + if (*prefName == prefs::kBlockThirdPartyCookies) { [self willChangeValueForKey:@"blockThirdPartyCookies"]; [self didChangeValueForKey:@"blockThirdPartyCookies"]; - [self willChangeValueForKey:@"blockThirdPartyCookiesManaged"]; - [self didChangeValueForKey:@"blockThirdPartyCookiesManaged"]; } - if (prefName == prefs::kBlockNonsandboxedPlugins) { + if (*prefName == prefs::kBlockNonsandboxedPlugins) { [self willChangeValueForKey:@"pluginsEnabledIndex"]; [self didChangeValueForKey:@"pluginsEnabledIndex"]; } - if (prefName == prefs::kDefaultContentSettings) { + if (*prefName == prefs::kDefaultContentSettings) { // We don't know exactly which setting has changed, so we'll tickle all // of the properties that apply to kDefaultContentSettings. This will // keep the UI up-to-date. @@ -614,33 +567,15 @@ class PrefObserverDisabler { [self didChangeValueForKey:@"pluginsEnabledIndex"]; [self willChangeValueForKey:@"popupsEnabledIndex"]; [self didChangeValueForKey:@"popupsEnabledIndex"]; - - // Updates the "Enable" state of the radio groups and the exception buttons. - [self willChangeValueForKey:@"cookieSettingsManaged"]; - [self didChangeValueForKey:@"cookieSettingsManaged"]; - [self willChangeValueForKey:@"imagesSettingsManaged"]; - [self didChangeValueForKey:@"imagesSettingsManaged"]; - [self willChangeValueForKey:@"javaScriptSettingsManaged"]; - [self didChangeValueForKey:@"javaScriptSettingsManaged"]; - [self willChangeValueForKey:@"pluginsSettingsManaged"]; - [self didChangeValueForKey:@"pluginsSettingsManaged"]; - [self willChangeValueForKey:@"popupsSettingsManaged"]; - [self didChangeValueForKey:@"popupsSettingsManaged"]; } - if (prefName == prefs::kGeolocationDefaultContentSetting) { + if (*prefName == prefs::kGeolocationDefaultContentSetting) { [self willChangeValueForKey:@"geolocationSettingIndex"]; [self didChangeValueForKey:@"geolocationSettingIndex"]; } - if (prefName == prefs::kDesktopNotificationDefaultContentSetting) { + if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) { [self willChangeValueForKey:@"notificationsSettingIndex"]; [self didChangeValueForKey:@"notificationsSettingIndex"]; } } -- (void)contentSettingsChanged: - (HostContentSettingsMap::ContentSettingsDetails*)details { - [self prefChanged:prefs::kBlockNonsandboxedPlugins]; - [self prefChanged:prefs::kDefaultContentSettings]; -} - @end |