| 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_setting_bubble_cocoa.h" | 5 #import "chrome/browser/cocoa/content_setting_bubble_cocoa.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 384 |
| 385 // Resize container to fit its subviews, and window to fit the container. | 385 // Resize container to fit its subviews, and window to fit the container. |
| 386 NSRect windowFrame = [[self window] frame]; | 386 NSRect windowFrame = [[self window] frame]; |
| 387 windowFrame.size.height += containerHeight - NSHeight(containerFrame); | 387 windowFrame.size.height += containerHeight - NSHeight(containerFrame); |
| 388 [[self window] setFrame:windowFrame display:NO]; | 388 [[self window] setFrame:windowFrame display:NO]; |
| 389 containerFrame.size.height = containerHeight; | 389 containerFrame.size.height = containerHeight; |
| 390 [contentsContainer_ setFrame:containerFrame]; | 390 [contentsContainer_ setFrame:containerFrame]; |
| 391 } | 391 } |
| 392 | 392 |
| 393 - (void)sizeToFitLoadPluginsButton { | 393 - (void)sizeToFitLoadPluginsButton { |
| 394 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 394 const ContentSettingBubbleModel::BubbleContent& content = |
| 395 switches::kDisableClickToPlay)) { | 395 contentSettingBubbleModel_->bubble_content(); |
| 396 const ContentSettingBubbleModel::BubbleContent& content = | 396 [loadAllPluginsButton_ setEnabled:content.load_plugins_link_enabled]; |
| 397 contentSettingBubbleModel_->bubble_content(); | |
| 398 [loadAllPluginsButton_ setEnabled:content.load_plugins_link_enabled]; | |
| 399 | 397 |
| 400 // Resize horizontally to fit button if necessary. | 398 // Resize horizontally to fit button if necessary. |
| 401 NSRect windowFrame = [[self window] frame]; | 399 NSRect windowFrame = [[self window] frame]; |
| 402 int widthNeeded = NSWidth([loadAllPluginsButton_ frame]) + | 400 int widthNeeded = NSWidth([loadAllPluginsButton_ frame]) + |
| 403 2 * NSMinX([loadAllPluginsButton_ frame]); | 401 2 * NSMinX([loadAllPluginsButton_ frame]); |
| 404 if (NSWidth(windowFrame) < widthNeeded) { | 402 if (NSWidth(windowFrame) < widthNeeded) { |
| 405 windowFrame.size.width = widthNeeded; | 403 windowFrame.size.width = widthNeeded; |
| 406 [[self window] setFrame:windowFrame display:NO]; | 404 [[self window] setFrame:windowFrame display:NO]; |
| 407 } | |
| 408 } else { | |
| 409 // Remove button and resize vertically. | |
| 410 int deltaY = kLoadAllPluginsButtonVerticalPadding + | |
| 411 NSHeight([loadAllPluginsButton_ frame]); | |
| 412 [loadAllPluginsButton_ removeFromSuperview]; | |
| 413 NSRect frame = [[self window] frame]; | |
| 414 frame.size.height -= deltaY; | |
| 415 [[self window] setFrame:frame display:NO]; | |
| 416 NSPoint radioOrigin = [allowBlockRadioGroup_ frame].origin; | |
| 417 radioOrigin.y -= deltaY; | |
| 418 [allowBlockRadioGroup_ setFrameOrigin:radioOrigin]; | |
| 419 [allowBlockRadioGroup_ setNeedsDisplay]; | |
| 420 } | 405 } |
| 421 } | 406 } |
| 422 | 407 |
| 423 - (void)sizeToFitManageDoneButtons { | 408 - (void)sizeToFitManageDoneButtons { |
| 424 CGFloat actualWidth = NSWidth([[[self window] contentView] frame]); | 409 CGFloat actualWidth = NSWidth([[[self window] contentView] frame]); |
| 425 CGFloat requiredWidth = NSMaxX([manageButton_ frame]) + kManageDonePadding + | 410 CGFloat requiredWidth = NSMaxX([manageButton_ frame]) + kManageDonePadding + |
| 426 NSWidth([[doneButton_ superview] frame]) - NSMinX([doneButton_ frame]); | 411 NSWidth([[doneButton_ superview] frame]) - NSMinX([doneButton_ frame]); |
| 427 if (requiredWidth <= actualWidth || !doneButton_ || !manageButton_) | 412 if (requiredWidth <= actualWidth || !doneButton_ || !manageButton_) |
| 428 return; | 413 return; |
| 429 | 414 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 DCHECK(i != popupLinks_.end()); | 476 DCHECK(i != popupLinks_.end()); |
| 492 contentSettingBubbleModel_->OnPopupClicked(i->second); | 477 contentSettingBubbleModel_->OnPopupClicked(i->second); |
| 493 } | 478 } |
| 494 | 479 |
| 495 - (void)clearGeolocationForCurrentHost:(id)sender { | 480 - (void)clearGeolocationForCurrentHost:(id)sender { |
| 496 contentSettingBubbleModel_->OnClearLinkClicked(); | 481 contentSettingBubbleModel_->OnClearLinkClicked(); |
| 497 [self close]; | 482 [self close]; |
| 498 } | 483 } |
| 499 | 484 |
| 500 @end // ContentSettingBubbleController | 485 @end // ContentSettingBubbleController |
| OLD | NEW |