OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/infobars/infobar_utilities.h" | 5 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" |
8 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 9 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
9 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" | 10 #import "chrome/browser/ui/cocoa/infobars/infobar_gradient_view.h" |
10 #import "components/infobars/core/infobar.h" | 11 #import "components/infobars/core/infobar.h" |
11 #import "ui/base/cocoa/nsview_additions.h" | 12 #import "ui/base/cocoa/nsview_additions.h" |
12 | 13 |
13 @interface InfobarLabelTextField : NSTextField | 14 @interface InfobarLabelTextField : NSTextField |
14 @end | 15 @end |
15 | 16 |
16 @implementation InfobarLabelTextField | 17 @implementation InfobarLabelTextField |
17 | 18 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 // Vertically center |toMove| in its container. | 61 // Vertically center |toMove| in its container. |
61 void VerticallyCenterView(NSView* toMove) { | 62 void VerticallyCenterView(NSView* toMove) { |
62 NSRect superViewFrame = [[toMove superview] frame]; | 63 NSRect superViewFrame = [[toMove superview] frame]; |
63 NSRect viewFrame = [toMove frame]; | 64 NSRect viewFrame = [toMove frame]; |
64 // If the superview is the infobar view, then subtract out the anti-spoof | 65 // If the superview is the infobar view, then subtract out the anti-spoof |
65 // height so that the content is centered in the content area of the infobar, | 66 // height so that the content is centered in the content area of the infobar, |
66 // rather than in the total height (which includes the bulge). | 67 // rather than in the total height (which includes the bulge). |
67 CGFloat superHeight = NSHeight(superViewFrame); | 68 CGFloat superHeight = NSHeight(superViewFrame); |
68 if ([[toMove superview] isKindOfClass:[InfoBarGradientView class]]) | 69 if ([[toMove superview] isKindOfClass:[InfoBarGradientView class]]) |
69 superHeight = infobars::InfoBar::kDefaultBarTargetHeight; | 70 superHeight = kChromeInfoBarConstants.default_bar_target_height; |
70 viewFrame.origin.y = | 71 viewFrame.origin.y = |
71 floor((superHeight - NSHeight(viewFrame)) / 2.0); | 72 floor((superHeight - NSHeight(viewFrame)) / 2.0); |
72 [toMove setFrame:viewFrame]; | 73 [toMove setFrame:viewFrame]; |
73 } | 74 } |
74 | 75 |
75 // Creates a label control in the style we need for the infobar's labels | 76 // Creates a label control in the style we need for the infobar's labels |
76 // within |bounds|. | 77 // within |bounds|. |
77 NSTextField* CreateLabel(NSRect bounds) { | 78 NSTextField* CreateLabel(NSRect bounds) { |
78 NSTextField* ret = [[InfobarLabelTextField alloc] initWithFrame:bounds]; | 79 NSTextField* ret = [[InfobarLabelTextField alloc] initWithFrame:bounds]; |
79 [ret setEditable:NO]; | 80 [ret setEditable:NO]; |
(...skipping 16 matching lines...) Expand all Loading... |
96 [menu addItem:item]; | 97 [menu addItem:item]; |
97 [item setTarget:target]; | 98 [item setTarget:target]; |
98 if (checked) | 99 if (checked) |
99 [item setState:NSOnState]; | 100 [item setState:NSOnState]; |
100 if (!enabled) | 101 if (!enabled) |
101 [item setEnabled:NO]; | 102 [item setEnabled:NO]; |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 } // namespace InfoBarUtilities | 106 } // namespace InfoBarUtilities |
OLD | NEW |