Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm

Issue 1312053006: Remove CONTENT_SETTINGS_NUM_TYPES (part 2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@website-settings-registry-4
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_AUTOMATIC_DOWNLOADS, @"ContentBlockedDownloads"},
256 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, @"ContentBlockedMIDISysEx"},
257 };
258
239 - (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel 259 - (id)initWithModel:(ContentSettingBubbleModel*)contentSettingBubbleModel
240 webContents:(content::WebContents*)webContents 260 webContents:(content::WebContents*)webContents
241 parentWindow:(NSWindow*)parentWindow 261 parentWindow:(NSWindow*)parentWindow
242 anchoredAt:(NSPoint)anchoredAt { 262 anchoredAt:(NSPoint)anchoredAt {
243 // This method takes ownership of |contentSettingBubbleModel| in all cases. 263 // This method takes ownership of |contentSettingBubbleModel| in all cases.
244 scoped_ptr<ContentSettingBubbleModel> model(contentSettingBubbleModel); 264 scoped_ptr<ContentSettingBubbleModel> model(contentSettingBubbleModel);
245 DCHECK(model.get()); 265 DCHECK(model.get());
246 observerBridge_.reset( 266 observerBridge_.reset(
247 new ContentSettingBubbleWebContentsObserverBridge(webContents, self)); 267 new ContentSettingBubbleWebContentsObserverBridge(webContents, self));
248 268
249 ContentSettingsType settingsType = model->content_type(); 269 ContentSettingsType settingsType = model->content_type();
270 DCHECK(ContainsKey(ContentSettingBubbleModel::GetSupportedBubbleTypes(),
271 settingsType));
272 DCHECK_EQ(ContentSettingBubbleModel::GetSupportedBubbleTypes().size(),
273 arraysize(kNibPaths));
250 NSString* nibPath = @""; 274 NSString* nibPath = @"";
251 switch (settingsType) { 275 for (const ContentTypeToNibPath& type_to_path : kNibPaths) {
252 case CONTENT_SETTINGS_TYPE_COOKIES: 276 if (settingsType == type_to_path.type) {
253 nibPath = @"ContentBlockedCookies"; break; 277 nibPath = type_to_path.path;
254 case CONTENT_SETTINGS_TYPE_IMAGES: 278 break;
255 case CONTENT_SETTINGS_TYPE_JAVASCRIPT: 279 }
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 } 280 }
281 DCHECK_NE(0u, [nibPath length]);
282
292 if ((self = [super initWithWindowNibPath:nibPath 283 if ((self = [super initWithWindowNibPath:nibPath
293 parentWindow:parentWindow 284 parentWindow:parentWindow
294 anchoredAt:anchoredAt])) { 285 anchoredAt:anchoredAt])) {
295 contentSettingBubbleModel_.reset(model.release()); 286 contentSettingBubbleModel_.reset(model.release());
296 [self showWindow:nil]; 287 [self showWindow:nil];
297 } 288 }
298 return self; 289 return self;
299 } 290 }
300 291
301 - (void)dealloc { 292 - (void)dealloc {
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index))); 829 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index)));
839 830
840 it->second->model->ExecuteCommand(index, 0); 831 it->second->model->ExecuteCommand(index, 0);
841 } 832 }
842 833
843 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { 834 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus {
844 return &mediaMenus_; 835 return &mediaMenus_;
845 } 836 }
846 837
847 @end // ContentSettingBubbleController 838 @end // ContentSettingBubbleController
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698