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

Unified Diff: chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm

Issue 9705038: [Mac] Make ExtensionInstalledBubbleController is-a BaseBubbleController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm
index 34f6227f409557f2fd821e7ba2a88ab20c35eeca..231fa62f354460f109ae3e0207eb38cc18af1d26 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm
@@ -92,11 +92,9 @@ class ExtensionLoadedNotificationObserver
icon:(SkBitmap)icon {
NSString* nibName = bundle ? @"ExtensionInstalledBubbleBundle" :
@"ExtensionInstalledBubble";
- NSString* nibPath = [base::mac::FrameworkBundle() pathForResource:nibName
- ofType:@"nib"];
- if ((self = [super initWithWindowNibPath:nibPath owner:self])) {
- DCHECK(parentWindow);
- parentWindow_ = parentWindow;
+ if ((self = [super initWithWindowNibPath:nibName
+ parentWindow:parentWindow
+ anchoredAt:NSZeroPoint])) {
extension_ = extension;
bundle_ = bundle;
DCHECK(browser);
@@ -124,55 +122,28 @@ class ExtensionLoadedNotificationObserver
extensionObserver_.reset(new ExtensionLoadedNotificationObserver(
self, browser->profile()));
}
-
- // Watch to see if the parent window closes, and if so, close this one.
- NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
- [center addObserver:self
- selector:@selector(parentWindowWillClose:)
- name:NSWindowWillCloseNotification
- object:parentWindow_];
}
return self;
}
-- (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [super dealloc];
-}
-
-- (void)close {
- [[[self window] parentWindow] removeChildWindow:[self window]];
- [super close];
-}
-
-- (void)parentWindowWillClose:(NSNotification*)notification {
- [self close];
-}
-
- (void)windowWillClose:(NSNotification*)notification {
// Turn off page action icon preview when the window closes, unless we
// already removed it when the window resigned key status.
[self removePageActionPreviewIfNecessary];
extension_ = NULL;
browser_ = NULL;
- parentWindow_ = nil;
- // We caught a close so we don't need to watch for the parent closing.
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [self autorelease];
+
+ [super windowWillClose:notification];
}
// The controller is the delegate of the window, so it receives "did resign
// key" notifications. When key is resigned, close the window.
- (void)windowDidResignKey:(NSNotification*)notification {
- NSWindow* window = [self window];
- DCHECK_EQ([notification object], window);
- DCHECK([window isVisible]);
-
// If the browser window is closing, we need to remove the page action
// immediately, otherwise the closing animation may overlap with
// browser destruction.
[self removePageActionPreviewIfNecessary];
- [self close];
+ [super windowDidResignKey:notification];
}
- (IBAction)closeWindow:(id)sender {
@@ -264,7 +235,7 @@ class ExtensionLoadedNotificationObserver
// Load nib and calculate height based on messages to be shown.
NSWindow* window = [self initializeWindow];
int newWindowHeight = [self calculateWindowHeight];
- [infoBubbleView_ setFrameSize:NSMakeSize(
+ [self.bubble setFrameSize:NSMakeSize(
NSWidth([[window contentView] bounds]), newWindowHeight)];
NSSize windowDelta = NSMakeSize(
0, newWindowHeight - NSHeight([[window contentView] bounds]));
@@ -277,19 +248,9 @@ class ExtensionLoadedNotificationObserver
[self setMessageFrames:newWindowHeight];
// Find window origin, taking into account bubble size and arrow location.
- NSPoint origin =
- [parentWindow_ convertBaseToScreen:[self calculateArrowPoint]];
- NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset +
- info_bubble::kBubbleArrowWidth / 2.0, 0);
- offsets = [[window contentView] convertSize:offsets toView:nil];
- if ([infoBubbleView_ arrowLocation] == info_bubble::kTopRight)
- origin.x -= NSWidth([window frame]) - offsets.width;
- origin.y -= NSHeight([window frame]);
- [window setFrameOrigin:origin];
-
- [parentWindow_ addChildWindow:window
- ordered:NSWindowAbove];
- [window makeKeyAndOrderFront:self];
+ self.anchorPoint =
Nico 2012/03/14 23:59:46 bleh, property syntax for nontrivial setters :-/
+ [self.parentWindow convertBaseToScreen:[self calculateArrowPoint]];
+ [super showWindow:sender];
}
// Finish nib loading, set arrow location and load icon into window. This
@@ -298,9 +259,9 @@ class ExtensionLoadedNotificationObserver
NSWindow* window = [self window]; // completes nib load
if (type_ == extension_installed_bubble::kOmniboxKeyword) {
- [infoBubbleView_ setArrowLocation:info_bubble::kTopLeft];
+ [self.bubble setArrowLocation:info_bubble::kTopLeft];
} else {
- [infoBubbleView_ setArrowLocation:info_bubble::kTopRight];
+ [self.bubble setArrowLocation:info_bubble::kTopRight];
}
if (type_ == extension_installed_bubble::kBundle)
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698