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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 12929002: Observe for window's (self) deletion during activation/focus change (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nits Created 7 years, 9 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 | « no previous file | ui/aura/aura.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index e8214ca8c554fba3d4bcb70f9c2b4180dcc289e7..4bd8ed113b33ba52b2b23b30d16d43da0809abec 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -48,6 +48,7 @@
#include "ui/aura/env.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
+#include "ui/aura/window_destruction_observer.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_tracker.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
@@ -2024,8 +2025,17 @@ void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
if (host_tracker_.get() && !host_tracker_->windows().empty()) {
aura::Window* host = *(host_tracker_->windows().begin());
aura::client::FocusClient* client = aura::client::GetFocusClient(host);
- if (client)
+ if (client) {
+ // Calling host->Focus() may delete |this|. We create a local
+ // observer for that. In that case we exit without further
+ // access to any members.
+ aura::WindowDestructionObserver destruction_observer(window_);
host->Focus();
+ if (destruction_observer.destroyed()) {
+ event->SetHandled();
+ return;
+ }
+ }
}
if (!in_shutdown_) {
in_shutdown_ = true;
« no previous file with comments | « no previous file | ui/aura/aura.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698