base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
[chromium-blink-merge.git] / ui / wm / core / focus_rules.h
blobcb9a4ddbd8fa5d0d6a59227d19385a3c9031a9ae
1 // Copyright (c) 2012 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.
5 #ifndef UI_WM_CORE_FOCUS_RULES_H_
6 #define UI_WM_CORE_FOCUS_RULES_H_
8 #include "ui/wm/wm_export.h"
10 namespace aura {
11 class Window;
14 namespace wm {
16 // Implemented by an object that establishes the rules about what can be
17 // focused or activated.
18 class WM_EXPORT FocusRules {
19 public:
20 virtual ~FocusRules() {}
22 // Returns true if |window| is a toplevel window. Whether or not a window
23 // is considered toplevel is determined by a similar set of rules that
24 // govern activation and focus. Not all toplevel windows are activatable,
25 // call CanActivateWindow() to determine if a window can be activated.
26 virtual bool IsToplevelWindow(aura::Window* window) const = 0;
27 // Returns true if |window| can be activated or focused.
28 virtual bool CanActivateWindow(aura::Window* window) const = 0;
29 // For CanFocusWindow(), NULL is supported, because NULL is a valid focusable
30 // window (in the case of clearing focus).
31 virtual bool CanFocusWindow(aura::Window* window) const = 0;
33 // Returns the toplevel window containing |window|. Not all toplevel windows
34 // are activatable, call GetActivatableWindow() instead to return the
35 // activatable window, which might be in a different hierarchy.
36 // Will return NULL if |window| is not contained by a window considered to be
37 // a toplevel window.
38 virtual aura::Window* GetToplevelWindow(aura::Window* window) const = 0;
39 // Returns the activatable or focusable window given an attempt to activate or
40 // focus |window|. Some possible scenarios (not intended to be exhaustive):
41 // - |window| is a child of a non-focusable window and so focus must be set
42 // according to rules defined by the delegate, e.g. to a parent.
43 // - |window| is an activatable window that is the transient parent of a modal
44 // window, so attempts to activate |window| should result in the modal
45 // transient being activated instead.
46 // These methods may return NULL if they are unable to find an activatable
47 // or focusable window given |window|.
48 virtual aura::Window* GetActivatableWindow(aura::Window* window) const = 0;
49 virtual aura::Window* GetFocusableWindow(aura::Window* window) const = 0;
51 // Returns the next window to activate in the event that |ignore| is no longer
52 // activatable. This function is called when something is happening to
53 // |ignore| that means it can no longer have focus or activation, including
54 // but not limited to:
55 // - it or its parent hierarchy is being hidden, or removed from the
56 // RootWindow.
57 // - it is being destroyed.
58 // - it is being explicitly deactivated.
59 // |ignore| cannot be NULL.
60 virtual aura::Window* GetNextActivatableWindow(
61 aura::Window* ignore) const = 0;
64 } // namespace wm
66 #endif // UI_WM_CORE_FOCUS_RULES_H_