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

Side by Side Diff: ui/aura/scoped_window_targeter.cc

Issue 423503002: Make ScopedWindowTargeter add itself as a WindowObserver for real (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/aura/window_targeter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/scoped_window_targeter.h" 5 #include "ui/aura/scoped_window_targeter.h"
6 6
7 #include "ui/aura/window.h" 7 #include "ui/aura/window.h"
8 8
9 namespace aura { 9 namespace aura {
10 10
11 ScopedWindowTargeter::ScopedWindowTargeter( 11 ScopedWindowTargeter::ScopedWindowTargeter(
12 Window* window, 12 Window* window,
13 scoped_ptr<ui::EventTargeter> new_targeter) 13 scoped_ptr<ui::EventTargeter> new_targeter)
14 : window_(window), 14 : window_(window),
15 old_targeter_(window->SetEventTargeter(new_targeter.Pass())) { 15 old_targeter_(window->SetEventTargeter(new_targeter.Pass())) {
16 window_->AddObserver(this);
16 } 17 }
17 18
18 ScopedWindowTargeter::~ScopedWindowTargeter() { 19 ScopedWindowTargeter::~ScopedWindowTargeter() {
19 if (window_) 20 if (window_) {
21 window_->RemoveObserver(this);
20 window_->SetEventTargeter(old_targeter_.Pass()); 22 window_->SetEventTargeter(old_targeter_.Pass());
23 }
21 } 24 }
22 25
23 void ScopedWindowTargeter::OnWindowDestroyed(Window* window) { 26 void ScopedWindowTargeter::OnWindowDestroyed(Window* window) {
24 CHECK_EQ(window_, window); 27 CHECK_EQ(window_, window);
28 window_->RemoveObserver(this);
Jun Mukai 2014/07/25 20:24:00 aura::Window destructor removes the observer right
pkotwicz 2014/07/25 20:31:20 You're right. Thanks for letting me know!
25 window_ = NULL; 29 window_ = NULL;
26 old_targeter_.reset(); 30 old_targeter_.reset();
27 } 31 }
28 32
29 } // namespace aura 33 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura/window_targeter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698