OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/content_settings_dialog_controller.h" | 5 #import "chrome/browser/cocoa/content_settings_dialog_controller.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 // flexible widths as this looks weird. | 180 // flexible widths as this looks weird. |
181 [view setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; | 181 [view setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 NSString* label = | 185 NSString* label = |
186 l10n_util::GetNSStringWithFixup(IDS_CONTENT_SETTINGS_FEATURES_LABEL); | 186 l10n_util::GetNSStringWithFixup(IDS_CONTENT_SETTINGS_FEATURES_LABEL); |
187 label = [label stringByReplacingOccurrencesOfString:@":" withString:@""]; | 187 label = [label stringByReplacingOccurrencesOfString:@":" withString:@""]; |
188 [tabViewPicker_ setHeading:label]; | 188 [tabViewPicker_ setHeading:label]; |
189 | 189 |
| 190 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 191 switches::kEnableClickToPlay)) { |
| 192 // The |pluginsEnabledIndex| property is bound to the selected *tag*, |
| 193 // so we don't have to worry about index shifts when removing a row |
| 194 // from the matrix. |
| 195 [pluginDefaultSettingMatrix_ removeRow:kPluginsAskIndex]; |
| 196 NSArray* siblingViews = [[pluginDefaultSettingMatrix_ superview] subviews]; |
| 197 for (NSView* view in siblingViews) { |
| 198 NSRect frame = [view frame]; |
| 199 if (frame.origin.y < [pluginDefaultSettingMatrix_ frame].origin.y) { |
| 200 frame.origin.y += |
| 201 ([pluginDefaultSettingMatrix_ cellSize].height + |
| 202 [pluginDefaultSettingMatrix_ intercellSpacing].height); |
| 203 [view setFrame:frame]; |
| 204 } |
| 205 } |
| 206 } |
| 207 |
190 NSRect frame = [[self window] frame]; | 208 NSRect frame = [[self window] frame]; |
191 frame.origin.y -= windowDelta; | 209 frame.origin.y -= windowDelta; |
192 frame.size.height += windowDelta; | 210 frame.size.height += windowDelta; |
193 [[self window] setFrame:frame display:NO]; | 211 [[self window] setFrame:frame display:NO]; |
194 } | 212 } |
195 | 213 |
196 // NSWindowDelegate method. | 214 // NSWindowDelegate method. |
197 - (void)windowWillClose:(NSNotification*)notification { | 215 - (void)windowWillClose:(NSNotification*)notification { |
198 [self autorelease]; | 216 [self autorelease]; |
199 g_instance = nil; | 217 g_instance = nil; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 disabler(observer_.get()); | 441 disabler(observer_.get()); |
424 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( | 442 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( |
425 CONTENT_SETTINGS_TYPE_PLUGINS, setting); | 443 CONTENT_SETTINGS_TYPE_PLUGINS, setting); |
426 } | 444 } |
427 | 445 |
428 - (NSInteger)pluginsEnabledIndex { | 446 - (NSInteger)pluginsEnabledIndex { |
429 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); | 447 HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); |
430 ContentSetting setting = | 448 ContentSetting setting = |
431 map->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); | 449 map->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS); |
432 switch (setting) { | 450 switch (setting) { |
433 case CONTENT_SETTING_ALLOW: return kPluginsAllowIndex; | 451 case CONTENT_SETTING_ALLOW: |
434 case CONTENT_SETTING_ASK: return kPluginsAskIndex; | 452 return kPluginsAllowIndex; |
435 case CONTENT_SETTING_BLOCK: return kPluginsBlockIndex; | 453 case CONTENT_SETTING_ASK: |
| 454 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 455 switches::kEnableClickToPlay)) |
| 456 return kPluginsAskIndex; |
| 457 // Fall through to the next case. |
| 458 case CONTENT_SETTING_BLOCK: |
| 459 return kPluginsBlockIndex; |
436 default: | 460 default: |
437 NOTREACHED(); | 461 NOTREACHED(); |
438 return kPluginsAllowIndex; | 462 return kPluginsAllowIndex; |
439 } | 463 } |
440 } | 464 } |
441 | 465 |
442 - (void)setPopupsEnabledIndex:(NSInteger)value { | 466 - (void)setPopupsEnabledIndex:(NSInteger)value { |
443 ContentSetting setting = value == kContentSettingsEnabledIndex ? | 467 ContentSetting setting = value == kContentSettingsEnabledIndex ? |
444 CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 468 CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
445 ContentSettingsDialogControllerInternal::PrefObserverDisabler | 469 ContentSettingsDialogControllerInternal::PrefObserverDisabler |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 [self willChangeValueForKey:@"geolocationSettingIndex"]; | 572 [self willChangeValueForKey:@"geolocationSettingIndex"]; |
549 [self didChangeValueForKey:@"geolocationSettingIndex"]; | 573 [self didChangeValueForKey:@"geolocationSettingIndex"]; |
550 } | 574 } |
551 if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) { | 575 if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) { |
552 [self willChangeValueForKey:@"notificationsSettingIndex"]; | 576 [self willChangeValueForKey:@"notificationsSettingIndex"]; |
553 [self didChangeValueForKey:@"notificationsSettingIndex"]; | 577 [self didChangeValueForKey:@"notificationsSettingIndex"]; |
554 } | 578 } |
555 } | 579 } |
556 | 580 |
557 @end | 581 @end |
OLD | NEW |