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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_notification_container.mm

Issue 21692002: Rename AutofillDialogController to AutofillDialogViewDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
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_controller.h"
11 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" 10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
11 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
12 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" 12 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
13 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h" 13 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_controller.h"
14 #include "skia/ext/skia_utils_mac.h" 14 #include "skia/ext/skia_utils_mac.h"
15 15
16 @implementation AutofillNotificationContainer 16 @implementation AutofillNotificationContainer
17 17
18 - (id)initWithController:(autofill::AutofillDialogController*)controller { 18 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate {
19 if (self = [super init]) { 19 if (self = [super init]) {
20 controller_ = controller; 20 delegate_ = delegate;
21 [self setView:[[[NSView alloc] initWithFrame:NSZeroRect] autorelease]]; 21 [self setView:[[[NSView alloc] initWithFrame:NSZeroRect] autorelease]];
22 } 22 }
23 return self; 23 return self;
24 } 24 }
25 25
26 // Just here to satisfy the protocol - not actually invoked. 26 // Just here to satisfy the protocol - not actually invoked.
27 - (NSSize)preferredSize { 27 - (NSSize)preferredSize {
28 NOTREACHED(); 28 NOTREACHED();
29 return NSZeroSize; 29 return NSZeroSize;
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 += kArrowHeight;
41 41
42 for (AutofillNotificationController* controller in 42 for (AutofillNotificationController* delegate in
43 notificationControllers_.get()) 43 notificationControllers_.get())
44 preferredSize.height += [controller 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 -= kArrowHeight;
57 57
58 for (AutofillNotificationController* controller in 58 for (AutofillNotificationController* delegate in
59 notificationControllers_.get()) { 59 notificationControllers_.get()) {
60 NSRect viewRect; 60 NSRect viewRect;
61 NSSize size = [controller 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 [[controller view ] setFrame:viewRect]; 63 [[delegate view ] setFrame:viewRect];
64 [controller performLayout]; 64 [delegate performLayout];
65 } 65 }
66 DCHECK_EQ(0, NSHeight(remaining)); 66 DCHECK_EQ(0, NSHeight(remaining));
67 } 67 }
68 68
69 - (void)setNotifications:(const autofill::DialogNotifications&)notifications { 69 - (void)setNotifications:(const autofill::DialogNotifications&)notifications {
70 notificationControllers_.reset([[NSMutableArray alloc] init]); 70 notificationControllers_.reset([[NSMutableArray alloc] init]);
71 checkboxNotification_.reset(); 71 checkboxNotification_.reset();
72 [[self view] setSubviews:@[]]; 72 [[self view] setSubviews:@[]];
73 73
74 for (size_t i = 0; i < notifications.size(); ++i) { 74 for (size_t i = 0; i < notifications.size(); ++i) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 } 108 }
109 109
110 - (void)setAnchorView:(NSView*)anchorView { 110 - (void)setAnchorView:(NSView*)anchorView {
111 anchorView_ = anchorView; 111 anchorView_ = anchorView;
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 controller_->NotificationCheckboxStateChanged(checkboxNotification_->type(), 117 delegate_->NotificationCheckboxStateChanged(checkboxNotification_->type(),
118 isChecked); 118 isChecked);
119 } 119 }
120 120
121 @end 121 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698