From 68828be583862a07c72c3c223a6309b8fb708051 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Fri, 26 Mar 2010 21:44:17 +0000 Subject: Mac: Add geolocation content setting. The radio button seems to be non-functional; probably the backend probably isn't there yet. xib changes: Added a location tab to contentsettings.xib, bind its radio buttons and normal button to the new methods in the controller. In the bubble, enable the "settings" button. BUG=11246 TEST=content settings now has a "location" tab. Review URL: http://codereview.chromium.org/1428002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42827 0039d316-1c4b-4281-b951-d872f2087c98 --- .../cocoa/content_settings_dialog_controller.mm | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'chrome/browser/cocoa/content_settings_dialog_controller.mm') diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.mm b/chrome/browser/cocoa/content_settings_dialog_controller.mm index ef66d7d..a23ea9b 100644 --- a/chrome/browser/cocoa/content_settings_dialog_controller.mm +++ b/chrome/browser/cocoa/content_settings_dialog_controller.mm @@ -12,6 +12,7 @@ #include "chrome/browser/browser_window.h" #import "chrome/browser/cocoa/content_exceptions_window_controller.h" #import "chrome/browser/cocoa/cookies_window_controller.h" +#import "chrome/browser/geolocation/geolocation_content_settings_map.h" #import "chrome/browser/host_content_settings_map.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" @@ -36,6 +37,11 @@ const NSInteger kCookieDisabledIndex = 2; // Stores the currently visible content settings dialog, if any. ContentSettingsDialogController* g_instance = nil; +// Indices of the various geolocation settings in the geolocation radio group. +const NSInteger kGeolocationEnabledIndex = 0; +const NSInteger kGeolocationAskIndex = 1; +const NSInteger kGeolocationDisabledIndex = 2; + } // namespace @@ -52,6 +58,8 @@ ContentSettingsDialogController* g_instance = nil; @property(assign, nonatomic) NSInteger javaScriptEnabledIndex; @property(assign, nonatomic) NSInteger popupsEnabledIndex; @property(assign, nonatomic) NSInteger pluginsEnabledIndex; +@property(assign, nonatomic) NSInteger geolocationSettingIndex; + @end namespace ContentSettingsDialogControllerInternal { @@ -258,6 +266,11 @@ class PrefObserverBridge : public NotificationObserver { [self showExceptionsForType:CONTENT_SETTINGS_TYPE_POPUPS]; } +- (IBAction)showGeolocationExceptions:(id)sender { + // TODO(thakis): Implement. + NOTIMPLEMENTED(); +} + - (void)showExceptionsForType:(ContentSettingsType)settingsType { HostContentSettingsMap* settingsMap = profile_->GetHostContentSettingsMap(); [ContentExceptionsWindowController showForType:settingsType @@ -324,4 +337,30 @@ class PrefObserverBridge : public NotificationObserver { return enabled ? kEnabledIndex : kDisabledIndex; } +- (void)setGeolocationSettingIndex:(NSInteger)value { + ContentSetting setting = CONTENT_SETTING_DEFAULT; + switch (value) { + case kGeolocationEnabledIndex: setting = CONTENT_SETTING_ALLOW; break; + case kGeolocationAskIndex: setting = CONTENT_SETTING_ASK; break; + case kGeolocationDisabledIndex: setting = CONTENT_SETTING_BLOCK; break; + default: + NOTREACHED(); + } + profile_->GetGeolocationContentSettingsMap()->SetDefaultContentSetting( + setting); +} + +- (NSInteger)geolocationSettingIndex { + ContentSetting setting = + profile_->GetGeolocationContentSettingsMap()->GetDefaultContentSetting(); + switch (setting) { + case CONTENT_SETTING_ALLOW: return kGeolocationEnabledIndex; + case CONTENT_SETTING_ASK: return kGeolocationAskIndex; + case CONTENT_SETTING_BLOCK: return kGeolocationDisabledIndex; + default: + NOTREACHED(); + return kGeolocationAskIndex; + } +} + @end -- cgit v1.1