| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/views/corewm/focus_controller.h" | 5 #include "ui/views/corewm/focus_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "ui/aura/client/activation_client.h" | 9 #include "ui/aura/client/activation_client.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 class TestFocusRules : public BaseFocusRules { | 78 class TestFocusRules : public BaseFocusRules { |
| 79 public: | 79 public: |
| 80 TestFocusRules() : focus_restriction_(NULL) {} | 80 TestFocusRules() : focus_restriction_(NULL) {} |
| 81 | 81 |
| 82 // Restricts focus and activation to this window and its child hierarchy. | 82 // Restricts focus and activation to this window and its child hierarchy. |
| 83 void set_focus_restriction(aura::Window* focus_restriction) { | 83 void set_focus_restriction(aura::Window* focus_restriction) { |
| 84 focus_restriction_ = focus_restriction; | 84 focus_restriction_ = focus_restriction; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Overridden from BaseFocusRules: | 87 // Overridden from BaseFocusRules: |
| 88 virtual bool SupportsChildActivation(aura::Window* window) OVERRIDE { |
| 89 // In FocusControllerTests, only the RootWindow has activatable children. |
| 90 return window->GetRootWindow() == window; |
| 91 } |
| 88 virtual bool CanActivateWindow(aura::Window* window) OVERRIDE { | 92 virtual bool CanActivateWindow(aura::Window* window) OVERRIDE { |
| 89 // Restricting focus to a non-activatable child window means the activatable | 93 // Restricting focus to a non-activatable child window means the activatable |
| 90 // parent outside the focus restriction is activatable. | 94 // parent outside the focus restriction is activatable. |
| 91 bool can_activate = CanFocusOrActivate(window) || | 95 bool can_activate = |
| 92 window->Contains(GetActivatableWindow(focus_restriction_)); | 96 CanFocusOrActivate(window) || window->Contains(focus_restriction_); |
| 93 return can_activate ? BaseFocusRules::CanActivateWindow(window) : false; | 97 return can_activate ? BaseFocusRules::CanActivateWindow(window) : false; |
| 94 } | 98 } |
| 95 virtual bool CanFocusWindow(aura::Window* window) OVERRIDE { | 99 virtual bool CanFocusWindow(aura::Window* window) OVERRIDE { |
| 96 return CanFocusOrActivate(window) ? | 100 return CanFocusOrActivate(window) ? |
| 97 BaseFocusRules::CanFocusWindow(window) : false; | 101 BaseFocusRules::CanFocusWindow(window) : false; |
| 98 } | 102 } |
| 99 virtual aura::Window* GetActivatableWindow(aura::Window* window) OVERRIDE { | 103 virtual aura::Window* GetActivatableWindow(aura::Window* window) OVERRIDE { |
| 100 return BaseFocusRules::GetActivatableWindow( | 104 return BaseFocusRules::GetActivatableWindow( |
| 101 CanFocusOrActivate(window) ? window : focus_restriction_); | 105 CanFocusOrActivate(window) ? window : focus_restriction_); |
| 102 } | 106 } |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveWindow); | 736 DIRECT_FOCUS_CHANGE_TESTS(ShiftFocusToChildOfInactiveWindow); |
| 733 | 737 |
| 734 // - Verifies that FocusRules determine what can be focused. | 738 // - Verifies that FocusRules determine what can be focused. |
| 735 ALL_FOCUS_TESTS(FocusRulesOverride); | 739 ALL_FOCUS_TESTS(FocusRulesOverride); |
| 736 | 740 |
| 737 // - Verifies that FocusRules determine what can be activated. | 741 // - Verifies that FocusRules determine what can be activated. |
| 738 TARGET_FOCUS_TESTS(ActivationRulesOverride); | 742 TARGET_FOCUS_TESTS(ActivationRulesOverride); |
| 739 | 743 |
| 740 } // namespace corewm | 744 } // namespace corewm |
| 741 } // namespace views | 745 } // namespace views |
| OLD | NEW |