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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/native_window_tracker_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/native_window_tracker_cocoa.mm b/chrome/browser/ui/cocoa/native_window_tracker_cocoa.mm
new file mode 100644
index 0000000000000000000000000000000000000000..14afb8d9550177e1b29fd471ccc306c8085f0479
--- /dev/null
+++ b/chrome/browser/ui/cocoa/native_window_tracker_cocoa.mm
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/cocoa/native_window_tracker_cocoa.h"
+
+#import <AppKit/AppKit.h>
+
+@interface BridgedNativeWindowTracker : NSObject {
+ @private
+ NSWindow* window_;
+}
+
+- (id)initWithNSWindow:(NSWindow*)window;
+- (bool)wasNSWindowClosed;
+- (void)onWindowWillClose:(NSNotification*)notification;
+
+@end
+
+@implementation BridgedNativeWindowTracker
+
+- (id)initWithNSWindow:(NSWindow*)window {
+ window_ = window;
+ NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
+ [center addObserver:self
+ selector:@selector(onWindowWillClose:)
+ name:NSWindowWillCloseNotification
+ object:window_];
+ return self;
+}
+
+- (void)dealloc {
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
+- (bool)wasNSWindowClosed {
+ return window_ == nil;
+}
+
+- (void)onWindowWillClose:(NSNotification*)notification {
+ [[NSNotificationCenter defaultCenter]
+ removeObserver:self
+ name:NSWindowWillCloseNotification
+ object:window_];
+ window_ = nil;
+}
+
+@end
+
+NativeWindowTrackerCocoa::NativeWindowTrackerCocoa(gfx::NativeWindow window) {
+ bridge_.reset([[BridgedNativeWindowTracker alloc] initWithNSWindow:window]);
+}
+
+NativeWindowTrackerCocoa::~NativeWindowTrackerCocoa() {
+}
+
+bool NativeWindowTrackerCocoa::WasNativeWindowClosed() const {
+ return [bridge_ wasNSWindowClosed];
+}
+
+// static
+scoped_ptr<NativeWindowTracker> NativeWindowTracker::Create(
+ gfx::NativeWindow window) {
+ return scoped_ptr<NativeWindowTracker>(new NativeWindowTrackerCocoa(window));
+}
« 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