| 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 #include "ui/aura_shell/aura_shell_export.h" | |
| 16 | |
| 17 namespace aura_shell { | |
| 18 namespace internal { | |
| 19 | |
| 20 // Exported for unit tests. | |
| 21 class AURA_SHELL_EXPORT ActivationController | |
| 22 : public aura::client::ActivationClient, | |
| 23 public aura::WindowObserver, | |
| 24 public aura::RootWindowObserver { | |
| 25 public: | |
| 26 ActivationController(); | |
| 27 virtual ~ActivationController(); | |
| 28 | |
| 29 // Returns true if |window| exists within a container that supports | |
| 30 // activation. | |
| 31 static aura::Window* GetActivatableWindow(aura::Window* window); | |
| 32 | |
| 33 // Overridden from aura::client::ActivationClient: | |
| 34 virtual void ActivateWindow(aura::Window* window) OVERRIDE; | |
| 35 virtual void DeactivateWindow(aura::Window* window) OVERRIDE; | |
| 36 virtual aura::Window* GetActiveWindow() OVERRIDE; | |
| 37 virtual bool CanFocusWindow(aura::Window* window) const OVERRIDE; | |
| 38 | |
| 39 // Overridden from aura::WindowObserver: | |
| 40 virtual void OnWindowVisibilityChanged(aura::Window* window, | |
| 41 bool visible) OVERRIDE; | |
| 42 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | |
| 43 | |
| 44 // Overridden from aura::RootWindowObserver: | |
| 45 virtual void OnWindowInitialized(aura::Window* window) OVERRIDE; | |
| 46 virtual void OnWindowFocused(aura::Window* window) OVERRIDE; | |
| 47 | |
| 48 #if defined(UNIT_TEST) | |
| 49 void set_default_container_for_test(aura::Window* window) { | |
| 50 default_container_for_test_ = window; | |
| 51 } | |
| 52 #endif | |
| 53 | |
| 54 private: | |
| 55 // Shifts activation to the next window, ignoring |window|. | |
| 56 void ActivateNextWindow(aura::Window* window); | |
| 57 | |
| 58 // Returns the next window that should be activated, ignoring |ignore|. | |
| 59 aura::Window* GetTopmostWindowToActivate(aura::Window* ignore) const; | |
| 60 | |
| 61 // True inside ActivateWindow(). Used to prevent recursion of focus | |
| 62 // change notifications causing activation. | |
| 63 bool updating_activation_; | |
| 64 | |
| 65 // For tests that are not running with a Shell instance, | |
| 66 // ActivationController's attempts to locate the next active window in | |
| 67 // GetTopmostWindowToActivate() will crash, so we provide this way for such | |
| 68 // tests to specify a default container. | |
| 69 aura::Window* default_container_for_test_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(ActivationController); | |
| 72 }; | |
| 73 | |
| 74 } // namespace internal | |
| 75 } // namespace aura_shell | |
| 76 | |
| 77 #endif // UI_AURA_SHELL_ACTIVATION_CONTROLLER_H_ | |
| OLD | NEW |