OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_AURA_SHELL_ACTIVATION_CONTROLLER_H_ |
| 6 #define UI_AURA_SHELL_ACTIVATION_CONTROLLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/aura/client/activation_client.h" |
| 13 #include "ui/aura/root_window_observer.h" |
| 14 #include "ui/aura/window_observer.h" |
| 15 |
| 16 namespace aura_shell { |
| 17 namespace internal { |
| 18 |
| 19 class ActivationController : public aura::ActivationClient, |
| 20 public aura::WindowObserver, |
| 21 public aura::RootWindowObserver { |
| 22 public: |
| 23 ActivationController(); |
| 24 virtual ~ActivationController(); |
| 25 |
| 26 // Returns true if |window| exists within a container that supports |
| 27 // activation. |
| 28 static aura::Window* GetActivatableWindow(aura::Window* window); |
| 29 |
| 30 // Overridden from aura::ActivationClient: |
| 31 virtual void ActivateWindow(aura::Window* window) OVERRIDE; |
| 32 virtual void DeactivateWindow(aura::Window* window) OVERRIDE; |
| 33 virtual aura::Window* GetActiveWindow() OVERRIDE; |
| 34 virtual bool CanFocusWindow(aura::Window* window) const OVERRIDE; |
| 35 |
| 36 // Overridden from aura::WindowObserver: |
| 37 virtual void OnWindowVisibilityChanged(aura::Window* window, |
| 38 bool visible) OVERRIDE; |
| 39 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 40 |
| 41 // Overridden from aura::RootWindowObserver: |
| 42 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; |
| 43 virtual void OnWindowFocused(aura::Window* window) OVERRIDE; |
| 44 |
| 45 #if defined(UNIT_TEST) |
| 46 void set_default_container_for_test(aura::Window* window) { |
| 47 default_container_for_test_ = window; |
| 48 } |
| 49 #endif |
| 50 |
| 51 private: |
| 52 // Shifts activation to the next window, ignoring |window|. |
| 53 void ActivateNextWindow(aura::Window* window); |
| 54 |
| 55 // Returns the next window that should be activated, ignoring |ignore|. |
| 56 aura::Window* GetTopmostWindowToActivate(aura::Window* ignore) const; |
| 57 |
| 58 // True inside ActivateWindow(). Used to prevent recursion of focus |
| 59 // change notifications causing activation. |
| 60 bool updating_activation_; |
| 61 |
| 62 // For tests that are not running with a Shell instance, |
| 63 // ActivationController's attempts to locate the next active window in |
| 64 // GetTopmostWindowToActivate() will crash, so we provide this way for such |
| 65 // tests to specify a default container. |
| 66 aura::Window* default_container_for_test_; |
| 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(ActivationController); |
| 69 }; |
| 70 |
| 71 } // namespace internal |
| 72 } // namespace aura_shell |
| 73 |
| 74 #endif // UI_AURA_SHELL_ACTIVATION_CONTROLLER_H_ |
OLD | NEW |