OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #import "chrome/browser/ui/cocoa/autofill/autofill_error_bubble_controller.h" | |
6 | |
7 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | |
8 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | |
9 #include "skia/ext/skia_utils_mac.h" | |
10 | |
11 namespace { | |
12 | |
13 // Border inset for error label. | |
14 const CGFloat kLabelInset = 3.0; | |
15 | |
16 // Imported constant from Views version. TODO(groby): Share. | |
17 SkColor const kWarningColor = 0xffde4932; // SkColorSetRGB(0xde, 0x49, 0x32); | |
18 | |
19 } // namespace | |
20 | |
21 | |
22 @implementation AutofillErrorBubbleController | |
23 | |
24 - (id)initWithParentWindow:(NSWindow*)parentWindow | |
25 message:(NSString*)message { | |
26 base::scoped_nsobject<InfoBubbleWindow> window( | |
27 [[InfoBubbleWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 100) | |
28 styleMask:NSBorderlessWindowMask | |
29 backing:NSBackingStoreBuffered | |
30 defer:NO]); | |
31 [window setAllowedAnimations:info_bubble::kAnimateNone]; | |
32 if ((self = [super initWithWindow:window | |
33 parentWindow:parentWindow | |
34 anchoredAt:NSZeroPoint])) { | |
35 [self setShouldOpenAsKeyWindow:NO]; | |
36 [[self bubble] setBackgroundColor: | |
37 gfx::SkColorToCalibratedNSColor(kWarningColor)]; | |
Robert Sesek
2013/11/04 23:49:18
nit: indent 2 more spaces
groby-ooo-7-16
2013/11/05 00:51:48
Done.
| |
38 [[self bubble] setArrowLocation:info_bubble::kTopCenter]; | |
39 [[self bubble] setAlignment:info_bubble::kAlignArrowToAnchor]; | |
40 | |
41 label_.reset([[NSTextField alloc] init]); | |
42 [label_ setEditable:NO]; | |
43 [label_ setBordered:NO]; | |
44 [label_ setDrawsBackground:NO]; | |
45 [label_ setTextColor:[NSColor whiteColor]]; | |
46 [label_ setStringValue:message]; | |
47 [label_ sizeToFit]; | |
48 [label_ setFrameOrigin:NSMakePoint(kLabelInset, kLabelInset)]; | |
49 | |
50 [[self bubble] addSubview:label_]; | |
51 | |
52 NSRect windowFrame = [[self window] frame]; | |
53 windowFrame.size = NSMakeSize( | |
54 NSMaxX([label_ frame]), | |
55 NSHeight([label_ frame]) + info_bubble::kBubbleArrowHeight); | |
56 windowFrame = NSInsetRect(windowFrame, -kLabelInset, -kLabelInset); | |
57 [[self window] setFrame:windowFrame display:NO]; | |
58 } | |
59 return self; | |
60 } | |
61 | |
62 @end | |
63 | |
Robert Sesek
2013/11/04 23:49:18
nit: remove blank line
groby-ooo-7-16
2013/11/05 00:51:48
Done.
| |
OLD | NEW |