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_tooltip_controller.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #import "chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.h" | 8 #import "chrome/browser/ui/cocoa/autofill/autofill_bubble_controller.h" |
9 #import "ui/base/cocoa/hover_image_button.h" | 9 #import "ui/base/cocoa/hover_image_button.h" |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 @end | 61 @end |
62 | 62 |
63 #pragma mark AutofillTooltipController | 63 #pragma mark AutofillTooltipController |
64 | 64 |
65 @implementation AutofillTooltipController | 65 @implementation AutofillTooltipController |
66 | 66 |
67 @synthesize message = message_; | 67 @synthesize message = message_; |
68 | 68 |
69 - (id)init { | 69 - (id)initWithArrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation { |
70 if ((self = [super init])) { | 70 if ((self = [super init])) { |
| 71 arrowLocation_ = arrowLocation; |
71 view_.reset([[AutofillTooltip alloc] init]); | 72 view_.reset([[AutofillTooltip alloc] init]); |
72 [self setView:view_]; | 73 [self setView:view_]; |
73 [view_ setTooltipDelegate:self]; | 74 [view_ setTooltipDelegate:self]; |
74 } | 75 } |
75 return self; | 76 return self; |
76 } | 77 } |
77 | 78 |
78 - (void)dealloc { | 79 - (void)dealloc { |
79 [[NSNotificationCenter defaultCenter] | 80 [[NSNotificationCenter defaultCenter] |
80 removeObserver:self | 81 removeObserver:self |
(...skipping 20 matching lines...) Expand all Loading... |
101 - (void)tooltipWindowWillClose:(NSNotification*)notification { | 102 - (void)tooltipWindowWillClose:(NSNotification*)notification { |
102 bubbleController_ = nil; | 103 bubbleController_ = nil; |
103 } | 104 } |
104 | 105 |
105 - (void)displayHover { | 106 - (void)displayHover { |
106 [bubbleController_ close]; | 107 [bubbleController_ close]; |
107 bubbleController_ = | 108 bubbleController_ = |
108 [[AutofillBubbleController alloc] | 109 [[AutofillBubbleController alloc] |
109 initWithParentWindow:[[self view] window] | 110 initWithParentWindow:[[self view] window] |
110 message:[self message] | 111 message:[self message] |
111 inset:NSMakeSize(kTooltipInset, kTooltipInset)]; | 112 inset:NSMakeSize(kTooltipInset, kTooltipInset) |
| 113 arrowLocation:arrowLocation_]; |
112 | 114 |
113 // Handle bubble self-deleting. | 115 // Handle bubble self-deleting. |
114 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 116 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
115 [center addObserver:self | 117 [center addObserver:self |
116 selector:@selector(tooltipWindowWillClose:) | 118 selector:@selector(tooltipWindowWillClose:) |
117 name:NSWindowWillCloseNotification | 119 name:NSWindowWillCloseNotification |
118 object:[bubbleController_ window]]; | 120 object:[bubbleController_ window]]; |
119 | 121 |
120 // Compute anchor point (in window coords - views might be flipped). | 122 // Compute anchor point (in window coords - views might be flipped). |
121 NSRect viewRect = [view_ convertRect:[view_ bounds] toView:nil]; | 123 NSRect viewRect = [view_ convertRect:[view_ bounds] toView:nil]; |
(...skipping 11 matching lines...) Expand all Loading... |
133 [NSObject cancelPreviousPerformRequestsWithTarget:self]; | 135 [NSObject cancelPreviousPerformRequestsWithTarget:self]; |
134 // Start a timer to display the tooltip, unless it's already hidden. | 136 // Start a timer to display the tooltip, unless it's already hidden. |
135 if (bubbleController_) { | 137 if (bubbleController_) { |
136 [self performSelector:@selector(hideHover) | 138 [self performSelector:@selector(hideHover) |
137 withObject:nil | 139 withObject:nil |
138 afterDelay:kTooltipDelay]; | 140 afterDelay:kTooltipDelay]; |
139 } | 141 } |
140 } | 142 } |
141 | 143 |
142 @end | 144 @end |
OLD | NEW |