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

Side by Side Diff: chrome/browser/ui/cocoa/native_window_tracker_cocoa.mm

Issue 662073002: Fix crash when user closes window prior to the "Confirm Install" prompt showing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/install_prompt_navigator
Patch Set: Created 6 years, 1 month 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/cocoa/native_window_tracker_cocoa.h"
6
7 #import <AppKit/AppKit.h>
8
9 @interface BridgedNativeWindowTracker : NSObject {
10 @private
11 NSWindow* window_;
12 }
13
14 - (id)initWithNSWindow:(NSWindow*)window;
15 - (bool)wasNSWindowClosed;
16 - (void)onWindowWillClose:(NSNotification*)notification;
17
18 @end
19
20 @implementation BridgedNativeWindowTracker
21
22 - (id)initWithNSWindow:(NSWindow*)window {
23 window_ = window;
24 NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
25 [center addObserver:self
26 selector:@selector(onWindowWillClose:)
27 name:NSWindowWillCloseNotification
28 object:window_];
29 return self;
30 }
31
32 - (void)dealloc {
33 [[NSNotificationCenter defaultCenter] removeObserver:self];
34 [super dealloc];
35 }
36
37 - (bool)wasNSWindowClosed {
38 return window_ == nil;
39 }
40
41 - (void)onWindowWillClose:(NSNotification*)notification {
42 [[NSNotificationCenter defaultCenter]
43 removeObserver:self
44 name:NSWindowWillCloseNotification
45 object:window_];
46 window_ = nil;
47 }
48
49 @end
50
51 NativeWindowTrackerCocoa::NativeWindowTrackerCocoa(gfx::NativeWindow window) {
52 bridge_.reset([[BridgedNativeWindowTracker alloc] initWithNSWindow:window]);
53 }
54
55 NativeWindowTrackerCocoa::~NativeWindowTrackerCocoa() {
56 }
57
58 bool NativeWindowTrackerCocoa::WasNativeWindowClosed() const {
59 return [bridge_ wasNSWindowClosed];
60 }
61
62 // static
63 scoped_ptr<NativeWindowTracker> NativeWindowTracker::Create(
64 gfx::NativeWindow window) {
65 return scoped_ptr<NativeWindowTracker>(new NativeWindowTrackerCocoa(window));
66 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/native_window_tracker_cocoa.h ('k') | chrome/browser/ui/native_window_tracker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698