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)); |
+} |