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

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

Issue 364783003: Revert of Fix ExtensionPopup close issue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 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();
223 } 217 }
224 [super close]; 218 [super close];
225 } 219 }
226 220
227 - (void)windowWillClose:(NSNotification*)notification { 221 - (void)windowWillClose:(NSNotification *)notification {
228 [super windowWillClose:notification]; 222 [super windowWillClose:notification];
229 if (gPopup == self) 223 if (gPopup == self)
230 gPopup = nil; 224 gPopup = nil;
225 if (host_->view())
226 host_->view()->set_container(NULL);
227 host_.reset();
231 } 228 }
232 229
233 - (void)windowDidResignKey:(NSNotification*)notification { 230 - (void)windowDidResignKey:(NSNotification*)notification {
234 // |windowWillClose:| could have already been called. http://crbug.com/279505 231 // |windowWillClose:| could have already been called. http://crbug.com/279505
235 if (host_) { 232 if (host_) {
236 // When a modal dialog is opened on top of the popup and when it's closed, 233 // When a modal dialog is opened on top of the popup and when it's closed,
237 // it steals key-ness from the popup. Don't close the popup when this 234 // it steals key-ness from the popup. Don't close the popup when this
238 // happens. There's an extra windowDidResignKey: notification after the 235 // happens. There's an extra windowDidResignKey: notification after the
239 // modal dialog closes that should also be ignored. 236 // modal dialog closes that should also be ignored.
240 web_modal::WebContentsModalDialogManager* modalDialogManager = 237 web_modal::WebContentsModalDialogManager* modalDialogManager =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 DCHECK(browser); 273 DCHECK(browser);
277 if (!browser) 274 if (!browser)
278 return nil; 275 return nil;
279 276
280 extensions::ExtensionViewHost* host = 277 extensions::ExtensionViewHost* host =
281 extensions::ExtensionViewHostFactory::CreatePopupHost(url, browser); 278 extensions::ExtensionViewHostFactory::CreatePopupHost(url, browser);
282 DCHECK(host); 279 DCHECK(host);
283 if (!host) 280 if (!host)
284 return nil; 281 return nil;
285 282
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].
291 [gPopup close]; 283 [gPopup close];
292 284
293 // Takes ownership of |host|. Also will autorelease itself when the popup is 285 // Takes ownership of |host|. Also will autorelease itself when the popup is
294 // closed, so no need to do that here. 286 // closed, so no need to do that here.
295 gPopup = [[ExtensionPopupController alloc] 287 gPopup = [[ExtensionPopupController alloc]
296 initWithHost:host 288 initWithHost:host
297 parentWindow:browser->window()->GetNativeWindow() 289 parentWindow:browser->window()->GetNativeWindow()
298 anchoredAt:anchoredAt 290 anchoredAt:anchoredAt
299 arrowLocation:arrowLocation 291 arrowLocation:arrowLocation
300 devMode:devMode]; 292 devMode:devMode];
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 [extensionView_ setFrame:frame]; 377 [extensionView_ setFrame:frame];
386 [extensionView_ setNeedsDisplay:YES]; 378 [extensionView_ setNeedsDisplay:YES];
387 } 379 }
388 380
389 - (void)onViewDidShow { 381 - (void)onViewDidShow {
390 [self onSizeChanged:pendingSize_]; 382 [self onSizeChanged:pendingSize_];
391 } 383 }
392 384
393 - (void)windowDidResize:(NSNotification*)notification { 385 - (void)windowDidResize:(NSNotification*)notification {
394 // Let the extension view know, so that it can tell plugins. 386 // Let the extension view know, so that it can tell plugins.
395 if (host_ && host_->view()) 387 if (host_->view())
396 host_->view()->WindowFrameChanged(); 388 host_->view()->WindowFrameChanged();
397 } 389 }
398 390
399 - (void)windowDidMove:(NSNotification*)notification { 391 - (void)windowDidMove:(NSNotification*)notification {
400 // Let the extension view know, so that it can tell plugins. 392 // Let the extension view know, so that it can tell plugins.
401 if (host_ && host_->view()) 393 if (host_->view())
402 host_->view()->WindowFrameChanged(); 394 host_->view()->WindowFrameChanged();
403 } 395 }
404 396
405 // Private (TestingAPI) 397 // Private (TestingAPI)
406 - (NSView*)view { 398 - (NSView*)view {
407 return extensionView_; 399 return extensionView_;
408 } 400 }
409 401
410 // Private (TestingAPI) 402 // Private (TestingAPI)
411 + (NSSize)minPopupSize { 403 + (NSSize)minPopupSize {
412 NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight}; 404 NSSize minSize = {ExtensionViewMac::kMinWidth, ExtensionViewMac::kMinHeight};
413 return minSize; 405 return minSize;
414 } 406 }
415 407
416 // Private (TestingAPI) 408 // Private (TestingAPI)
417 + (NSSize)maxPopupSize { 409 + (NSSize)maxPopupSize {
418 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 410 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
419 return maxSize; 411 return maxSize;
420 } 412 }
421 413
422 @end 414 @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