diff options
-rw-r--r-- | chrome/browser/cocoa/bubble_view.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/bubble_view.mm | 15 | ||||
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac.mm | 2 |
3 files changed, 19 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/bubble_view.h b/chrome/browser/cocoa/bubble_view.h index 8b52779..755c8a4 100644 --- a/chrome/browser/cocoa/bubble_view.h +++ b/chrome/browser/cocoa/bubble_view.h @@ -41,8 +41,8 @@ enum { // Designated initializer. |provider| is the window from which we get the // current theme to draw text and backgrounds. If nil, the current window will -// be checked. Defaults to all corners being rounded. The caller needs to -// ensure |provider| can't go away as it will not be retained. +// be checked. The caller needs to ensure |provider| can't go away as it will +// not be retained. Defaults to all corners being rounded. - (id)initWithFrame:(NSRect)frame themeProvider:(NSWindow*)provider; // Sets the string displayed in the bubble. A copy of the string is made. @@ -51,6 +51,9 @@ enum { // Sets which corners will be rounded. - (void)setCornerFlags:(unsigned long)flags; +// Sets the window whose theme is used to draw. +- (void)setThemeProvider:(NSWindow*)provider; + // The font used to display the content string. - (NSFont*)font; diff --git a/chrome/browser/cocoa/bubble_view.mm b/chrome/browser/cocoa/bubble_view.mm index c612c6a..9c5f569 100644 --- a/chrome/browser/cocoa/bubble_view.mm +++ b/chrome/browser/cocoa/bubble_view.mm @@ -17,8 +17,8 @@ const float kWindowEdge = 0.7f; // Designated initializer. |provider| is the window from which we get the // current theme to draw text and backgrounds. If nil, the current window will -// be checked. Defaults to all corners being rounded. The caller needs to -// ensure |provider| can't go away as it will not be retained. +// be checked. The caller needs to ensure |provider| can't go away as it will +// not be retained. Defaults to all corners being rounded. - (id)initWithFrame:(NSRect)frame themeProvider:(NSWindow*)provider { if ((self = [super initWithFrame:frame])) { cornerFlags_ = kRoundedAllCorners; @@ -43,6 +43,13 @@ const float kWindowEdge = 0.7f; [self setNeedsDisplay:YES]; } +- (void)setThemeProvider:(NSWindow*)provider { + if (themeProvider_ == provider) + return; + themeProvider_ = provider; + [self setNeedsDisplay:YES]; +} + - (NSString*)content { return content_.get(); } @@ -67,7 +74,9 @@ const float kWindowEdge = 0.7f; float bottomRightRadius = cornerFlags_ & kRoundedBottomRightCorner ? kBubbleCornerRadius : 0; - ThemeProvider* themeProvider = [themeProvider_ themeProvider]; + ThemeProvider* themeProvider = + themeProvider_ ? [themeProvider_ themeProvider] : + [[self window] themeProvider]; // Background / Edge diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm index a08f732..c249a0d 100644 --- a/chrome/browser/cocoa/status_bubble_mac.mm +++ b/chrome/browser/cocoa/status_bubble_mac.mm @@ -538,12 +538,14 @@ void StatusBubbleMac::SwitchParentWindow(NSWindow* parent) { // If not attached, just update our member variable and position. if (!is_attached()) { parent_ = parent; + [[window_ contentView] setThemeProvider:parent]; UpdateSizeAndPosition(); return; } Detach(); parent_ = parent; + [[window_ contentView] setThemeProvider:parent]; Attach(); UpdateSizeAndPosition(); } |