| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/message_center/cocoa/notification_controller.h" | 5 #import "ui/message_center/cocoa/notification_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 } else { | 450 } else { |
| 451 message = notification->context_message(); | 451 message = notification->context_message(); |
| 452 } | 452 } |
| 453 | 453 |
| 454 base::string16 elided = | 454 base::string16 elided = |
| 455 [self wrapText:message | 455 [self wrapText:message |
| 456 forFont:[contextMessage_ font] | 456 forFont:[contextMessage_ font] |
| 457 maxNumberOfLines:message_center::kContextMessageLineLimit]; | 457 maxNumberOfLines:message_center::kContextMessageLineLimit]; |
| 458 [contextMessage_ setString:base::SysUTF16ToNSString(elided)]; | 458 [contextMessage_ setString:base::SysUTF16ToNSString(elided)]; |
| 459 [contextMessage_ sizeToFit]; | 459 [contextMessage_ sizeToFit]; |
| 460 |
| 460 NSRect contextMessageFrame = [contextMessage_ frame]; | 461 NSRect contextMessageFrame = [contextMessage_ frame]; |
| 461 | 462 |
| 462 if (notification->context_message().empty() && | 463 if (notification->context_message().empty() && |
| 463 !notification->UseOriginAsContextMessage()) { | 464 !notification->UseOriginAsContextMessage()) { |
| 464 [contextMessage_ setHidden:YES]; | 465 [contextMessage_ setHidden:YES]; |
| 465 contextMessageFrame.origin.y = messageFrame.origin.y; | 466 contextMessageFrame.origin.y = messageFrame.origin.y; |
| 466 contextMessageFrame.size.height = 0; | 467 contextMessageFrame.size.height = 0; |
| 467 } else { | 468 } else { |
| 468 [contextMessage_ setHidden:NO]; | 469 [contextMessage_ setHidden:NO]; |
| 469 contextMessageFrame.origin.y = | 470 contextMessageFrame.origin.y = |
| 470 NSMinY(messageFrame) - | 471 NSMinY(messageFrame) - |
| 471 contextMessagePadding - | 472 contextMessagePadding - |
| 472 NSHeight(contextMessageFrame); | 473 NSHeight(contextMessageFrame); |
| 473 contextMessageFrame.size.height = NSHeight([contextMessage_ frame]); | 474 contextMessageFrame.size.height = NSHeight([contextMessage_ frame]); |
| 474 } | 475 } |
| 476 NSRect settingsButtonFrame = [settingsButton_ frame]; |
| 475 | 477 |
| 476 // Create the list item views (up to a maximum). | 478 // Create the list item views (up to a maximum). |
| 477 [listView_ removeFromSuperview]; | 479 [listView_ removeFromSuperview]; |
| 478 NSRect listFrame = NSZeroRect; | 480 NSRect listFrame = NSZeroRect; |
| 479 if (items.size() > 0) { | 481 if (items.size() > 0) { |
| 480 listFrame = [self currentContentRect]; | 482 listFrame = [self currentContentRect]; |
| 481 listFrame.origin.y = 0; | 483 listFrame.origin.y = 0; |
| 482 listFrame.size.height = 0; | 484 listFrame.size.height = 0; |
| 483 listView_.reset([[NSView alloc] initWithFrame:listFrame]); | 485 listView_.reset([[NSView alloc] initWithFrame:listFrame]); |
| 484 [listView_ accessibilitySetOverrideValue:NSAccessibilityListRole | 486 [listView_ accessibilitySetOverrideValue:NSAccessibilityListRole |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 messageFrame.origin.y += bottomAdjust; | 656 messageFrame.origin.y += bottomAdjust; |
| 655 contextMessageFrame.origin.y += bottomAdjust; | 657 contextMessageFrame.origin.y += bottomAdjust; |
| 656 listFrame.origin.y += bottomAdjust; | 658 listFrame.origin.y += bottomAdjust; |
| 657 progressBarFrame.origin.y += bottomAdjust; | 659 progressBarFrame.origin.y += bottomAdjust; |
| 658 } | 660 } |
| 659 | 661 |
| 660 [[self view] setFrame:rootFrame]; | 662 [[self view] setFrame:rootFrame]; |
| 661 [title_ setFrame:titleFrame]; | 663 [title_ setFrame:titleFrame]; |
| 662 [message_ setFrame:messageFrame]; | 664 [message_ setFrame:messageFrame]; |
| 663 [contextMessage_ setFrame:contextMessageFrame]; | 665 [contextMessage_ setFrame:contextMessageFrame]; |
| 666 [settingsButton_ setFrame:settingsButtonFrame]; |
| 664 [listView_ setFrame:listFrame]; | 667 [listView_ setFrame:listFrame]; |
| 665 [progressBarView_ setFrame:progressBarFrame]; | 668 [progressBarView_ setFrame:progressBarFrame]; |
| 666 | 669 |
| 667 return rootFrame; | 670 return rootFrame; |
| 668 } | 671 } |
| 669 | 672 |
| 670 - (void)close:(id)sender { | 673 - (void)close:(id)sender { |
| 671 [closeButton_ setTarget:nil]; | 674 [closeButton_ setTarget:nil]; |
| 672 messageCenter_->RemoveNotification([self notificationID], /*by_user=*/true); | 675 messageCenter_->RemoveNotification([self notificationID], /*by_user=*/true); |
| 673 } | 676 } |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 forFont:(NSFont*)nsfont | 960 forFont:(NSFont*)nsfont |
| 958 maxNumberOfLines:(size_t)lines { | 961 maxNumberOfLines:(size_t)lines { |
| 959 size_t unused; | 962 size_t unused; |
| 960 return [self wrapText:text | 963 return [self wrapText:text |
| 961 forFont:nsfont | 964 forFont:nsfont |
| 962 maxNumberOfLines:lines | 965 maxNumberOfLines:lines |
| 963 actualLines:&unused]; | 966 actualLines:&unused]; |
| 964 } | 967 } |
| 965 | 968 |
| 966 @end | 969 @end |
| OLD | NEW |