| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/cocoa/autofill/autofill_notification_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_container.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 - (NSSize)preferredSizeForWidth:(CGFloat)width { | 32 - (NSSize)preferredSizeForWidth:(CGFloat)width { |
| 33 NSSize preferredSize = NSMakeSize(width, 0); | 33 NSSize preferredSize = NSMakeSize(width, 0); |
| 34 | 34 |
| 35 if ([notificationControllers_ count] == 0) | 35 if ([notificationControllers_ count] == 0) |
| 36 return preferredSize; | 36 return preferredSize; |
| 37 | 37 |
| 38 // If the first notification doesn't have an arrow, reserve empty space. | 38 // If the first notification doesn't have an arrow, reserve empty space. |
| 39 if (![[notificationControllers_ objectAtIndex:0] hasArrow]) | 39 if (![[notificationControllers_ objectAtIndex:0] hasArrow]) |
| 40 preferredSize.height += kArrowHeight; | 40 preferredSize.height += autofill::kArrowHeight; |
| 41 | 41 |
| 42 for (AutofillNotificationController* delegate in | 42 for (AutofillNotificationController* delegate in |
| 43 notificationControllers_.get()) | 43 notificationControllers_.get()) |
| 44 preferredSize.height += [delegate preferredSizeForWidth:width].height; | 44 preferredSize.height += [delegate preferredSizeForWidth:width].height; |
| 45 | 45 |
| 46 return preferredSize; | 46 return preferredSize; |
| 47 } | 47 } |
| 48 | 48 |
| 49 - (void)performLayout { | 49 - (void)performLayout { |
| 50 if ([notificationControllers_ count] == 0) | 50 if ([notificationControllers_ count] == 0) |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 NSRect remaining = [[self view] bounds]; | 53 NSRect remaining = [[self view] bounds]; |
| 54 | 54 |
| 55 if (![[notificationControllers_ objectAtIndex:0] hasArrow]) | 55 if (![[notificationControllers_ objectAtIndex:0] hasArrow]) |
| 56 remaining.size.height -= kArrowHeight; | 56 remaining.size.height -= autofill::kArrowHeight; |
| 57 | 57 |
| 58 for (AutofillNotificationController* delegate in | 58 for (AutofillNotificationController* delegate in |
| 59 notificationControllers_.get()) { | 59 notificationControllers_.get()) { |
| 60 NSRect viewRect; | 60 NSRect viewRect; |
| 61 NSSize size = [delegate preferredSizeForWidth:NSWidth(remaining)]; | 61 NSSize size = [delegate preferredSizeForWidth:NSWidth(remaining)]; |
| 62 NSDivideRect(remaining, &viewRect, &remaining, size.height, NSMaxYEdge); | 62 NSDivideRect(remaining, &viewRect, &remaining, size.height, NSMaxYEdge); |
| 63 [[delegate view ] setFrame:viewRect]; | 63 [[delegate view ] setFrame:viewRect]; |
| 64 [delegate performLayout]; | 64 [delegate performLayout]; |
| 65 } | 65 } |
| 66 DCHECK_EQ(0, NSHeight(remaining)); | 66 DCHECK_EQ(0, NSHeight(remaining)); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 - (IBAction)checkboxClicked:(id)sender { | 114 - (IBAction)checkboxClicked:(id)sender { |
| 115 DCHECK(checkboxNotification_); | 115 DCHECK(checkboxNotification_); |
| 116 BOOL isChecked = ([sender state] == NSOnState); | 116 BOOL isChecked = ([sender state] == NSOnState); |
| 117 delegate_->NotificationCheckboxStateChanged(checkboxNotification_->type(), | 117 delegate_->NotificationCheckboxStateChanged(checkboxNotification_->type(), |
| 118 isChecked); | 118 isChecked); |
| 119 } | 119 } |
| 120 | 120 |
| 121 @end | 121 @end |
| OLD | NEW |