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

Unified Diff: chrome/browser/cocoa/notifications/balloon_controller.mm

Issue 2825073: Fix memory leaks in the balloon controller unit test by loading the NIB in th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « no previous file | chrome/browser/cocoa/notifications/balloon_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/notifications/balloon_controller.mm
===================================================================
--- chrome/browser/cocoa/notifications/balloon_controller.mm (revision 53978)
+++ chrome/browser/cocoa/notifications/balloon_controller.mm (working copy)
@@ -7,6 +7,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#import "base/cocoa_protocols_mac.h"
+#include "base/mac_util.h"
#import "base/scoped_nsobject.h"
#include "base/utf_string_conversions.h"
#import "chrome/browser/cocoa/menu_controller.h"
@@ -33,7 +34,10 @@
@implementation BalloonController
- (id)initWithBalloon:(Balloon*)balloon {
- if ((self = [super initWithWindowNibName:@"Notification"])) {
+ NSString* nibpath =
+ [mac_util::MainAppBundle() pathForResource:@"Notification"
+ ofType:@"nib"];
+ if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
balloon_ = balloon;
[self initializeHost];
menuModel_.reset(new NotificationOptionsMenuModel(balloon));
@@ -57,11 +61,14 @@
WideToUTF16(balloon_->notification().display_source()));
[originLabel_ setStringValue:sourceLabelText];
- gfx::NativeView contents = htmlContents_->native_view();
- [contents setFrame:NSMakeRect(kLeftMargin, kTopMargin, 0, 0)];
- [[htmlContainer_ superview] addSubview:contents
- positioned:NSWindowBelow
- relativeTo:nil];
+ // This condition is false in unit tests which have no RVH.
+ if (htmlContents_.get()) {
+ gfx::NativeView contents = htmlContents_->native_view();
+ [contents setFrame:NSMakeRect(kLeftMargin, kTopMargin, 0, 0)];
+ [[htmlContainer_ superview] addSubview:contents
+ positioned:NSWindowBelow
+ relativeTo:nil];
+ }
}
- (IBAction)optionsButtonPressed:(id)sender {
@@ -104,7 +111,9 @@
int w = [self desiredTotalWidth];
int h = [self desiredTotalHeight];
- htmlContents_->UpdateActualSize(balloon_->content_size());
+ if (htmlContents_.get())
+ htmlContents_->UpdateActualSize(balloon_->content_size());
+
[[self window] setFrame:NSMakeRect(x, y, w, h)
display:YES
animate:YES];
« no previous file with comments | « no previous file | chrome/browser/cocoa/notifications/balloon_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698