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

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

Issue 2703253007: Use (i) icon and the same tooltip for the credit cards dialog and account chooser on Mac. (Closed)
Patch Set: rebase Created 3 years, 9 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
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_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/base_view.h" 9 #import "ui/base/cocoa/base_view.h"
10 #include "ui/base/cocoa/cocoa_base_utils.h" 10 #include "ui/base/cocoa/cocoa_base_utils.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 [tooltipController_ setHoveringOnBubble:NO]; 95 [tooltipController_ setHoveringOnBubble:NO];
96 } 96 }
97 97
98 @end 98 @end
99 99
100 #pragma mark AutofillTooltipController 100 #pragma mark AutofillTooltipController
101 101
102 @implementation AutofillTooltipController 102 @implementation AutofillTooltipController
103 103
104 @synthesize message = message_; 104 @synthesize message = message_;
105 @synthesize maxTooltipWidth = maxTooltipWidth_;
105 106
106 - (id)initWithArrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation { 107 - (id)initWithArrowLocation:(info_bubble::BubbleArrowLocation)arrowLocation {
107 if ((self = [super init])) { 108 if ((self = [super init])) {
108 arrowLocation_ = arrowLocation; 109 arrowLocation_ = arrowLocation;
110 maxTooltipWidth_ = CGFLOAT_MAX;
109 view_.reset([[AutofillTooltip alloc] init]); 111 view_.reset([[AutofillTooltip alloc] init]);
110 [self setView:view_]; 112 [self setView:view_];
111 [view_ setTooltipController:self]; 113 [view_ setTooltipController:self];
112 } 114 }
113 return self; 115 return self;
114 } 116 }
115 117
116 - (void)dealloc { 118 - (void)dealloc {
117 [view_ setTooltipController:nil]; 119 [view_ setTooltipController:nil];
118 [NSObject cancelPreviousPerformRequestsWithTarget:self]; 120 [NSObject cancelPreviousPerformRequestsWithTarget:self];
119 [[NSNotificationCenter defaultCenter] 121 [[NSNotificationCenter defaultCenter]
120 removeObserver:self 122 removeObserver:self
121 name:NSWindowWillCloseNotification 123 name:NSWindowWillCloseNotification
122 object:[bubbleController_ window]]; 124 object:[bubbleController_ window]];
123 [super dealloc]; 125 [super dealloc];
124 } 126 }
125 127
126 - (void)setImage:(NSImage*)image { 128 - (void)setImage:(NSImage*)image {
127 [view_ setImage:image]; 129 [view_ setImage:image];
128 [view_ setFrameSize:[image size]]; 130 [view_ setFrameSize:[image size]];
129 } 131 }
130 132
131 - (void)tooltipWindowWillClose:(NSNotification*)notification { 133 - (void)tooltipWindowWillClose:(NSNotification*)notification {
132 bubbleController_ = nil; 134 bubbleController_ = nil;
133 } 135 }
134 136
135 - (void)displayHover { 137 - (void)displayHover {
136 [bubbleController_ close]; 138 [bubbleController_ close];
137 bubbleController_ = 139 bubbleController_ = [[AutofillBubbleController alloc]
138 [[AutofillBubbleController alloc] 140 initWithParentWindow:[[self view] window]
139 initWithParentWindow:[[self view] window] 141 message:[self message]
140 message:[self message] 142 inset:NSMakeSize(kTooltipInset, kTooltipInset)
141 inset:NSMakeSize(kTooltipInset, kTooltipInset) 143 maxLabelWidth:maxTooltipWidth_
142 arrowLocation:arrowLocation_]; 144 arrowLocation:arrowLocation_];
143 [bubbleController_ setShouldCloseOnResignKey:NO]; 145 [bubbleController_ setShouldCloseOnResignKey:NO];
144 146
145 // Handle bubble self-deleting. 147 // Handle bubble self-deleting.
146 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; 148 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
147 [center addObserver:self 149 [center addObserver:self
148 selector:@selector(tooltipWindowWillClose:) 150 selector:@selector(tooltipWindowWillClose:)
149 name:NSWindowWillCloseNotification 151 name:NSWindowWillCloseNotification
150 object:[bubbleController_ window]]; 152 object:[bubbleController_ window]];
151 153
152 // Inject a tracking view so controller can track hover events for the bubble. 154 // Inject a tracking view so controller can track hover events for the bubble.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // timer to change visibility. (Uses '!!' to force bool values) 195 // timer to change visibility. (Uses '!!' to force bool values)
194 if (!!bubbleController_ ^ !!shouldDisplayTooltip_) { 196 if (!!bubbleController_ ^ !!shouldDisplayTooltip_) {
195 SEL sel = shouldDisplayTooltip_ ? @selector(displayHover) 197 SEL sel = shouldDisplayTooltip_ ? @selector(displayHover)
196 : @selector(hideHover); 198 : @selector(hideHover);
197 [self performSelector:sel withObject:nil afterDelay:kTooltipDelay]; 199 [self performSelector:sel withObject:nil afterDelay:kTooltipDelay];
198 } 200 }
199 } 201 }
200 } 202 }
201 203
202 @end 204 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698