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

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

Issue 321093002: Fix ExtensionPopup close issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_popup_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 - (void)close { 207 - (void)close {
208 // |windowWillClose:| could have already been called. http://crbug.com/279505 208 // |windowWillClose:| could have already been called. http://crbug.com/279505
209 if (host_) { 209 if (host_) {
210 web_modal::WebContentsModalDialogManager* modalDialogManager = 210 web_modal::WebContentsModalDialogManager* modalDialogManager =
211 web_modal::WebContentsModalDialogManager::FromWebContents( 211 web_modal::WebContentsModalDialogManager::FromWebContents(
212 host_->host_contents()); 212 host_->host_contents());
213 if (modalDialogManager && 213 if (modalDialogManager &&
214 modalDialogManager->IsDialogActive()) { 214 modalDialogManager->IsDialogActive()) {
215 return; 215 return;
216 } 216 }
217 // We must shutdown host_ immediately, and it will notify RendererProcess
218 // right away. We can't wait to do it in
219 // -[ExtensionPopController windowWillClose:...]
220 if (host_->view())
221 host_->view()->set_container(NULL);
222 host_.reset();
217 } 223 }
218 [super close]; 224 [super close];
219 } 225 }
220 226
221 - (void)windowWillClose:(NSNotification *)notification { 227 - (void)windowWillClose:(NSNotification*)notification {
222 [super windowWillClose:notification]; 228 [super windowWillClose:notification];
223 if (gPopup == self) 229 if (gPopup == self)
224 gPopup = nil; 230 gPopup = nil;
225 if (host_->view())
226 host_->view()->set_container(NULL);
227 host_.reset();
228 } 231 }
229 232
230 - (void)windowDidResignKey:(NSNotification*)notification { 233 - (void)windowDidResignKey:(NSNotification*)notification {
231 // |windowWillClose:| could have already been called. http://crbug.com/279505 234 // |windowWillClose:| could have already been called. http://crbug.com/279505
232 if (host_) { 235 if (host_) {
233 // When a modal dialog is opened on top of the popup and when it's closed, 236 // When a modal dialog is opened on top of the popup and when it's closed,
234 // it steals key-ness from the popup. Don't close the popup when this 237 // it steals key-ness from the popup. Don't close the popup when this
235 // happens. There's an extra windowDidResignKey: notification after the 238 // happens. There's an extra windowDidResignKey: notification after the
236 // modal dialog closes that should also be ignored. 239 // modal dialog closes that should also be ignored.
237 web_modal::WebContentsModalDialogManager* modalDialogManager = 240 web_modal::WebContentsModalDialogManager* modalDialogManager =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 DCHECK(browser); 276 DCHECK(browser);
274 if (!browser) 277 if (!browser)
275 return nil; 278 return nil;
276 279
277 extensions::ExtensionViewHost* host = 280 extensions::ExtensionViewHost* host =
278 extensions::ExtensionViewHostFactory::CreatePopupHost(url, browser); 281 extensions::ExtensionViewHostFactory::CreatePopupHost(url, browser);
279 DCHECK(host); 282 DCHECK(host);
280 if (!host) 283 if (!host)
281 return nil; 284 return nil;
282 285
286 // Since we only close without releasing(see bug:351278), we need to shutdown
287 // host_ in -[ExtensionPopupController close] immediately. If not, host_ might
288 // not be released even when new ExtensionPopupController is ready. And
289 // this causes bug:376511.
290 // See above -[ExtensionPopupController close].
283 [gPopup close]; 291 [gPopup close];
Xuefei Ren 2014/06/10 05:24:32 See bug:361278, and patch is 64ced6a2af4cb2b46756b
284 292
285 // Takes ownership of |host|. Also will autorelease itself when the popup is 293 // Takes ownership of |host|. Also will autorelease itself when the popup is
286 // closed, so no need to do that here. 294 // closed, so no need to do that here.
287 gPopup = [[ExtensionPopupController alloc] 295 gPopup = [[ExtensionPopupController alloc]
288 initWithHost:host 296 initWithHost:host
289 parentWindow:browser->window()->GetNativeWindow() 297 parentWindow:browser->window()->GetNativeWindow()
290 anchoredAt:anchoredAt 298 anchoredAt:anchoredAt
291 arrowLocation:arrowLocation 299 arrowLocation:arrowLocation
292 devMode:devMode]; 300 devMode:devMode];
293 return gPopup; 301 return gPopup;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 [extensionView_ setFrame:frame]; 385 [extensionView_ setFrame:frame];
378 [extensionView_ setNeedsDisplay:YES]; 386 [extensionView_ setNeedsDisplay:YES];
379 } 387 }
380 388
381 - (void)onViewDidShow { 389 - (void)onViewDidShow {
382 [self onSizeChanged:pendingSize_]; 390 [self onSizeChanged:pendingSize_];
383 } 391 }
384 392
385 - (void)windowDidResize:(NSNotification*)notification { 393 - (void)windowDidResize:(NSNotification*)notification {
386 // Let the extension view know, so that it can tell plugins. 394 // Let the extension view know, so that it can tell plugins.
387 if (host_->view()) 395 if (host_ && host_->view())
388 host_->view()->WindowFrameChanged(); 396 host_->view()->WindowFrameChanged();
389 } 397 }
390 398
391 - (void)windowDidMove:(NSNotification*)notification { 399 - (void)windowDidMove:(NSNotification*)notification {
392 // Let the extension view know, so that it can tell plugins. 400 // Let the extension view know, so that it can tell plugins.
393 if (host_->view()) 401 if (host_ && host_->view())
394 host_->view()->WindowFrameChanged(); 402 host_->view()->WindowFrameChanged();
395 } 403 }
396 404
397 // Private (TestingAPI) 405 // Private (TestingAPI)
398 - (NSView*)view { 406 - (NSView*)view {
399 return extensionView_; 407 return extensionView_;
400 } 408 }
401 409
402 // Private (TestingAPI) 410 // Private (TestingAPI)
403 + (NSSize)minPopupSize { 411 + (NSSize)minPopupSize {
404 NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight}; 412 NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight};
405 return minSize; 413 return minSize;
406 } 414 }
407 415
408 // Private (TestingAPI) 416 // Private (TestingAPI)
409 + (NSSize)maxPopupSize { 417 + (NSSize)maxPopupSize {
410 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 418 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
411 return maxSize; 419 return maxSize;
412 } 420 }
413 421
414 @end 422 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698