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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller.mm

Issue 7740060: [Mac] Tear down extension-installed bubble before main window closes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove the leaked notification. Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extensions/extension_installed_bubble_controlle r.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controlle r.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } else if (extension->page_action() && 100 } else if (extension->page_action() &&
101 !extension->page_action()->default_icon_path().empty()) { 101 !extension->page_action()->default_icon_path().empty()) {
102 type_ = extension_installed_bubble::kPageAction; 102 type_ = extension_installed_bubble::kPageAction;
103 } else { 103 } else {
104 NOTREACHED(); // kGeneric installs handled in the extension_install_ui. 104 NOTREACHED(); // kGeneric installs handled in the extension_install_ui.
105 } 105 }
106 106
107 // Start showing window only after extension has fully loaded. 107 // Start showing window only after extension has fully loaded.
108 extensionObserver_.reset(new ExtensionLoadedNotificationObserver( 108 extensionObserver_.reset(new ExtensionLoadedNotificationObserver(
109 self, browser->profile())); 109 self, browser->profile()));
110
111 // Watch to see if the parent window closes, and if so, close this one.
112 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
113 [center addObserver:self
114 selector:@selector(parentWindowWillClose:)
115 name:NSWindowWillCloseNotification
116 object:parentWindow_];
110 } 117 }
111 return self; 118 return self;
112 } 119 }
113 120
114 - (void)dealloc { 121 - (void)dealloc {
115 [[NSNotificationCenter defaultCenter] removeObserver:self]; 122 [[NSNotificationCenter defaultCenter] removeObserver:self];
116 [super dealloc]; 123 [super dealloc];
117 } 124 }
118 125
119 - (void)close { 126 - (void)close {
120 [parentWindow_ removeChildWindow:[self window]]; 127 [[[self window] parentWindow] removeChildWindow:[self window]];
121 [super close]; 128 [super close];
122 } 129 }
123 130
131 - (void)parentWindowWillClose:(NSNotification*)notification {
132 [self close];
133 }
134
124 - (void)windowWillClose:(NSNotification*)notification { 135 - (void)windowWillClose:(NSNotification*)notification {
125 // Turn off page action icon preview when the window closes, unless we 136 // Turn off page action icon preview when the window closes, unless we
126 // already removed it when the window resigned key status. 137 // already removed it when the window resigned key status.
127 [self removePageActionPreviewIfNecessary]; 138 [self removePageActionPreviewIfNecessary];
128 extension_ = NULL; 139 extension_ = NULL;
129 browser_ = NULL; 140 browser_ = NULL;
130 parentWindow_ = nil; 141 parentWindow_ = nil;
131 // We caught a close so we don't need to watch for the parent closing. 142 // We caught a close so we don't need to watch for the parent closing.
132 [[NSNotificationCenter defaultCenter] removeObserver:self]; 143 [[NSNotificationCenter defaultCenter] removeObserver:self];
133 [self autorelease]; 144 [self autorelease];
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 381
371 - (NSRect)getExtensionInstalledInfoMsgFrame { 382 - (NSRect)getExtensionInstalledInfoMsgFrame {
372 return [extensionInstalledInfoMsg_ frame]; 383 return [extensionInstalledInfoMsg_ frame];
373 } 384 }
374 385
375 - (void)extensionUnloaded:(id)sender { 386 - (void)extensionUnloaded:(id)sender {
376 extension_ = NULL; 387 extension_ = NULL;
377 } 388 }
378 389
379 @end 390 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698