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

Side by Side Diff: ui/views/cocoa/widget_owner_nswindow_adapter.mm

Issue 2629593005: MacViews: Support -[NSWindow close] on sheets. (Closed)
Patch Set: Fix lifetime Created 3 years, 11 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "ui/views/cocoa/widget_owner_nswindow_adapter.h" 5 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/sdk_forward_declarations.h" 10 #include "base/mac/sdk_forward_declarations.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 void WidgetOwnerNSWindowAdapter::OnWindowWillClose() { 78 void WidgetOwnerNSWindowAdapter::OnWindowWillClose() {
79 // Retain the child window before closing it. If the last reference to the 79 // Retain the child window before closing it. If the last reference to the
80 // NSWindow goes away inside -[NSWindow close], then bad stuff can happen. 80 // NSWindow goes away inside -[NSWindow close], then bad stuff can happen.
81 // See e.g. http://crbug.com/616701. 81 // See e.g. http://crbug.com/616701.
82 base::scoped_nsobject<NSWindow> child_window(child_->ns_window(), 82 base::scoped_nsobject<NSWindow> child_window(child_->ns_window(),
83 base::scoped_policy::RETAIN); 83 base::scoped_policy::RETAIN);
84 84
85 // AppKit child window relationships break when the windows are not visible, 85 // AppKit child window relationships break when the windows are not visible,
86 // so if the child is not visible, it won't currently be a child. 86 // so if the child is not visible, it won't currently be a child.
87 DCHECK(![child_window isVisible] || [child_window parentWindow]); 87 if (![child_window isVisible])
88 DCHECK(![child_window parentWindow] && ![child_window sheetParent]);
88 DCHECK([child_window delegate]); 89 DCHECK([child_window delegate]);
89 90
90 [child_window close]; 91 [child_window close];
91 // Note: |this| will be deleted here. 92 // Note: |this| will be deleted here.
92 93
93 DCHECK(![child_window parentWindow]); 94 DCHECK(![child_window parentWindow]);
94 DCHECK(![child_window delegate]); 95 DCHECK(![child_window delegate]);
95 } 96 }
96 97
97 void WidgetOwnerNSWindowAdapter::OnWindowDidChangeOcclusionState() { 98 void WidgetOwnerNSWindowAdapter::OnWindowDidChangeOcclusionState() {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 DCHECK_EQ(child, child_); 148 DCHECK_EQ(child, child_);
148 [GetNSWindow() removeChildWindow:child->ns_window()]; 149 [GetNSWindow() removeChildWindow:child->ns_window()];
149 delete this; 150 delete this;
150 } 151 }
151 152
152 WidgetOwnerNSWindowAdapter::~WidgetOwnerNSWindowAdapter() { 153 WidgetOwnerNSWindowAdapter::~WidgetOwnerNSWindowAdapter() {
153 [[NSNotificationCenter defaultCenter] removeObserver:observer_bridge_]; 154 [[NSNotificationCenter defaultCenter] removeObserver:observer_bridge_];
154 } 155 }
155 156
156 } // namespace views 157 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698