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

Unified Diff: chrome/browser/ui/aura/native_window_deletion_observer_aura.cc

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
Index: chrome/browser/ui/aura/native_window_deletion_observer_aura.cc
diff --git a/chrome/browser/ui/aura/native_window_deletion_observer_aura.cc b/chrome/browser/ui/aura/native_window_deletion_observer_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e0dbde2374046b87e7814d086b4d871165d82304
--- /dev/null
+++ b/chrome/browser/ui/aura/native_window_deletion_observer_aura.cc
@@ -0,0 +1,35 @@
+// 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/aura/native_window_deletion_observer_aura.h"
+
+#include "ui/aura/window.h"
+
+NativeWindowDeletionObserverAura::NativeWindowDeletionObserverAura(
+ gfx::NativeWindow window)
+ : window_(window) {
sky 2014/10/24 20:22:56 nit: indent 2 more.
+ window->AddObserver(this);
+}
+
+NativeWindowDeletionObserverAura::~NativeWindowDeletionObserverAura() {
+ if (window_)
+ window_->RemoveObserver(this);
+}
+
+bool NativeWindowDeletionObserverAura::IsNativeWindowAlive() const {
+ return window_;
sky 2014/10/24 20:22:56 I'm surprised the compiler is happy with this. Usu
+}
+
+void NativeWindowDeletionObserverAura::OnWindowDestroying(
+ aura::Window* window) {
+ window_->RemoveObserver(this);
+ window_ = NULL;
sky 2014/10/24 20:22:56 nullptr.
+}
+
+// static
+scoped_ptr<NativeWindowDeletionObserver> NativeWindowDeletionObserver::Create(
+ gfx::NativeWindow window) {
+ return scoped_ptr<NativeWindowDeletionObserver>(
+ new NativeWindowDeletionObserverAura(window));
+}

Powered by Google App Engine
This is Rietveld 408576698