| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" | 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h
" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 parentWindow:(NSWindow*)parentWindow | 229 parentWindow:(NSWindow*)parentWindow |
| 230 anchoredAt:(NSPoint)anchor { | 230 anchoredAt:(NSPoint)anchor { |
| 231 // Autoreleases itself on bubble close. | 231 // Autoreleases itself on bubble close. |
| 232 return [[ContentSettingBubbleController alloc] | 232 return [[ContentSettingBubbleController alloc] |
| 233 initWithModel:contentSettingBubbleModel | 233 initWithModel:contentSettingBubbleModel |
| 234 webContents:webContents | 234 webContents:webContents |
| 235 parentWindow:parentWindow | 235 parentWindow:parentWindow |
| 236 anchoredAt:anchor]; | 236 anchoredAt:anchor]; |
| 237 } | 237 } |
| 238 | 238 |
| 239 struct ContentTypeToNibPath { |
| 240 ContentSettingsType type; |
| 241 NSString* path; |
| 242 }; |
| 243 |
| 244 const ContentTypeToNibPath kNibPaths[] = { |
| 245 {CONTENT_SETTINGS_TYPE_COOKIES, @"ContentBlockedCookies"}, |
| 246 {CONTENT_SETTINGS_TYPE_IMAGES, @"ContentBlockedSimple"}, |
| 247 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, @"ContentBlockedSimple"}, |
| 248 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, @"ContentBlockedSimple"}, |
| 249 {CONTENT_SETTINGS_TYPE_PLUGINS, @"ContentBlockedPlugins"}, |
| 250 {CONTENT_SETTINGS_TYPE_POPUPS, @"ContentBlockedPopups"}, |
| 251 {CONTENT_SETTINGS_TYPE_GEOLOCATION, @"ContentBlockedGeolocation"}, |
| 252 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, @"ContentBlockedMixedScript"}, |
| 253 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, @"ContentProtocolHandlers"}, |
| 254 {CONTENT_SETTINGS_TYPE_MEDIASTREAM, @"ContentBlockedMedia"}, |
| 255 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, @"ContentBlockedMedia"}, |
| 256 {CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, @"ContentBlockedMedia"}, |
| 257 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, @"ContentBlockedDownloads"}, |
| 258 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, @"ContentBlockedMIDISysEx"}, |
| 259 }; |
| 260 |
| 239 - (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel | 261 - (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel |
| 240 webContents:(content::WebContents*)webContents | 262 webContents:(content::WebContents*)webContents |
| 241 parentWindow:(NSWindow*)parentWindow | 263 parentWindow:(NSWindow*)parentWindow |
| 242 anchoredAt:(NSPoint)anchoredAt { | 264 anchoredAt:(NSPoint)anchoredAt { |
| 243 // This method takes ownership of |contentSettingBubbleModel| in all cases. | 265 // This method takes ownership of |contentSettingBubbleModel| in all cases. |
| 244 scoped_ptr<ContentSettingBubbleModel> model(contentSettingBubbleModel); | 266 scoped_ptr<ContentSettingBubbleModel> model(contentSettingBubbleModel); |
| 245 DCHECK(model.get()); | 267 DCHECK(model.get()); |
| 246 observerBridge_.reset( | 268 observerBridge_.reset( |
| 247 new ContentSettingBubbleWebContentsObserverBridge(webContents, self)); | 269 new ContentSettingBubbleWebContentsObserverBridge(webContents, self)); |
| 248 | 270 |
| 249 ContentSettingsType settingsType = model->content_type(); | 271 ContentSettingsType settingsType = model->content_type(); |
| 272 DCHECK(ContainsKey(ContentSettingBubbleModel::GetSupportedBubbleTypes(), |
| 273 settingsType)); |
| 274 DCHECK_EQ(ContentSettingBubbleModel::GetSupportedBubbleTypes().size(), |
| 275 arraysize(kNibPaths)); |
| 250 NSString* nibPath = @""; | 276 NSString* nibPath = @""; |
| 251 switch (settingsType) { | 277 for (const ContentTypeToNibPath& type_to_path : kNibPaths) { |
| 252 case CONTENT_SETTINGS_TYPE_COOKIES: | 278 if (settingsType == type_to_path.type) { |
| 253 nibPath = @"ContentBlockedCookies"; break; | 279 nibPath = type_to_path.path; |
| 254 case CONTENT_SETTINGS_TYPE_IMAGES: | 280 break; |
| 255 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: | 281 } |
| 256 case CONTENT_SETTINGS_TYPE_PPAPI_BROKER: | |
| 257 nibPath = @"ContentBlockedSimple"; break; | |
| 258 case CONTENT_SETTINGS_TYPE_PLUGINS: | |
| 259 nibPath = @"ContentBlockedPlugins"; break; | |
| 260 case CONTENT_SETTINGS_TYPE_POPUPS: | |
| 261 nibPath = @"ContentBlockedPopups"; break; | |
| 262 case CONTENT_SETTINGS_TYPE_GEOLOCATION: | |
| 263 nibPath = @"ContentBlockedGeolocation"; break; | |
| 264 case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT: | |
| 265 nibPath = @"ContentBlockedMixedScript"; break; | |
| 266 case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS: | |
| 267 nibPath = @"ContentProtocolHandlers"; break; | |
| 268 case CONTENT_SETTINGS_TYPE_MEDIASTREAM: | |
| 269 nibPath = @"ContentBlockedMedia"; break; | |
| 270 case CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS: | |
| 271 nibPath = @"ContentBlockedDownloads"; break; | |
| 272 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: | |
| 273 nibPath = @"ContentBlockedMIDISysEx"; break; | |
| 274 // These content types have no bubble: | |
| 275 case CONTENT_SETTINGS_TYPE_DEFAULT: | |
| 276 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: | |
| 277 case CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE: | |
| 278 case CONTENT_SETTINGS_TYPE_FULLSCREEN: | |
| 279 case CONTENT_SETTINGS_TYPE_MOUSELOCK: | |
| 280 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: | |
| 281 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: | |
| 282 case CONTENT_SETTINGS_NUM_TYPES: | |
| 283 // TODO(miguelg): Remove this nib content settings support | |
| 284 // is implemented | |
| 285 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: | |
| 286 case CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS: | |
| 287 case CONTENT_SETTINGS_TYPE_APP_BANNER: | |
| 288 case CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT: | |
| 289 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: | |
| 290 NOTREACHED(); | |
| 291 } | 282 } |
| 283 DCHECK_NE(0u, [nibPath length]); |
| 284 |
| 292 if ((self = [super initWithWindowNibPath:nibPath | 285 if ((self = [super initWithWindowNibPath:nibPath |
| 293 parentWindow:parentWindow | 286 parentWindow:parentWindow |
| 294 anchoredAt:anchoredAt])) { | 287 anchoredAt:anchoredAt])) { |
| 295 contentSettingBubbleModel_.reset(model.release()); | 288 contentSettingBubbleModel_.reset(model.release()); |
| 296 [self showWindow:nil]; | 289 [self showWindow:nil]; |
| 297 } | 290 } |
| 298 return self; | 291 return self; |
| 299 } | 292 } |
| 300 | 293 |
| 301 - (void)dealloc { | 294 - (void)dealloc { |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index))); | 831 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index))); |
| 839 | 832 |
| 840 it->second->model->ExecuteCommand(index, 0); | 833 it->second->model->ExecuteCommand(index, 0); |
| 841 } | 834 } |
| 842 | 835 |
| 843 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { | 836 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { |
| 844 return &mediaMenus_; | 837 return &mediaMenus_; |
| 845 } | 838 } |
| 846 | 839 |
| 847 @end // ContentSettingBubbleController | 840 @end // ContentSettingBubbleController |
| OLD | NEW |