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

Unified Diff: chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm

Issue 84343002: [rAC, OSX] Use a bubble for tooltips. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes. Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm b/chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm
index 4c1529896677f06190b5bcf84c08fd2057d54dbc..e78b94f6a9bb4d428334fe14a6eeb1f37342021c 100644
--- a/chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm
+++ b/chrome/browser/ui/cocoa/autofill/autofill_notification_controller.mm
@@ -14,6 +14,7 @@
#include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
#include "chrome/browser/ui/chrome_style.h"
#include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
+#import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h"
#import "chrome/browser/ui/cocoa/hyperlink_text_view.h"
#include "grit/theme_resources.h"
#include "skia/ext/skia_utils_mac.h"
@@ -141,16 +142,16 @@
// (2) this way, the sizing computation can be cached.
[checkbox_ sizeToFit];
- tooltipIcon_.reset([[NSImageView alloc] initWithFrame:NSZeroRect]);
- [tooltipIcon_ setImage:
+ tooltipController_.reset([[AutofillTooltipController alloc] init]);
+ [tooltipController_ setImage:
ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
IDR_AUTOFILL_TOOLTIP_ICON).ToNSImage()];
- [tooltipIcon_ setFrameSize:[[tooltipIcon_ image] size]];
- [tooltipIcon_ setToolTip:
+ [tooltipController_ setMessage:
base::SysUTF16ToNSString(notification->tooltip_text())];
- [tooltipIcon_ setHidden:[[tooltipIcon_ toolTip] length] == 0];
+ [[tooltipController_ view] setHidden:
+ [[tooltipController_ message] length] == 0];
- [view setSubviews:@[textview_, checkbox_, tooltipIcon_]];
+ [view setSubviews:@[ textview_, checkbox_, [tooltipController_ view] ]];
}
return self;
}
@@ -176,14 +177,16 @@
return checkbox_;
}
-- (NSImageView*)tooltipIcon {
- return tooltipIcon_;
+- (NSView*)tooltipView {
+ return [tooltipController_ view];
}
- (NSSize)preferredSizeForWidth:(CGFloat)width {
width -= 2 * chrome_style::kHorizontalPadding;
- if (![tooltipIcon_ isHidden])
- width -= [tooltipIcon_ frame].size.width + chrome_style::kHorizontalPadding;
+ if (![[tooltipController_ view] isHidden]) {
+ width -= NSWidth([[tooltipController_ view] frame]) +
+ chrome_style::kHorizontalPadding;
+ }
// TODO(isherman): Restore the DCHECK below once I figure out why it causes
// unit tests to fail.
//DCHECK_GT(width, 0);
@@ -235,20 +238,21 @@
NSRect labelFrame = NSInsetRect(bounds,
chrome_style::kHorizontalPadding,
autofill::kNotificationPadding);
- if (![tooltipIcon_ isHidden]) {
+ NSView* tooltipView = [tooltipController_ view];
+ if (![tooltipView isHidden]) {
labelFrame.size.width -=
- [tooltipIcon_ frame].size.width + chrome_style::kHorizontalPadding;
+ NSWidth([tooltipView frame]) + chrome_style::kHorizontalPadding;
}
NSView* label = [checkbox_ isHidden] ? textview_.get() : checkbox_.get();
[label setFrame:labelFrame];
- if (![tooltipIcon_ isHidden]) {
+ if (![tooltipView isHidden]) {
NSPoint tooltipOrigin =
NSMakePoint(
NSMaxX(labelFrame) + chrome_style::kHorizontalPadding,
- NSMidY(labelFrame) - (NSHeight([tooltipIcon_ frame]) / 2.0));
- [tooltipIcon_ setFrameOrigin:tooltipOrigin];
+ NSMidY(labelFrame) - (NSHeight([tooltipView frame]) / 2.0));
+ [tooltipView setFrameOrigin:tooltipOrigin];
}
}

Powered by Google App Engine
This is Rietveld 408576698