15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#ifndef UI_AURA_SCOPED_WINDOW_TARGETER_H_ 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#define UI_AURA_SCOPED_WINDOW_TARGETER_H_ 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/macros.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/aura/window_observer.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ui { 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class EventTargeter; 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace aura { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class Window; 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// ScopedWindowTargeter is used to temporarily replace the event-targeter for a 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// window. Upon construction, it installs a new targeter on the window, and upon 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// destruction, it restores the previous event-targeter on the window. 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AURA_EXPORT ScopedWindowTargeter : public WindowObserver { 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ScopedWindowTargeter(Window* window, 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<ui::EventTargeter> new_targeter); 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~ScopedWindowTargeter(); 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 30a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch ui::EventTargeter* old_targeter() { 31a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch return old_targeter_.get(); 32a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch } 33a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) private: 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // WindowObserver: 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnWindowDestroyed(Window* window) OVERRIDE; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Window* window_; 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) scoped_ptr<ui::EventTargeter> old_targeter_; 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(ScopedWindowTargeter); 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace aura 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif // UI_AURA_SCOPED_WINDOW_TARGETER_H_ 47