| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/aura/mus/focus_synchronizer.h" | 5 #include "ui/aura/mus/focus_synchronizer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "services/ui/public/interfaces/window_tree.mojom.h" | 8 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/client/focus_client.h" | 10 #include "ui/aura/client/focus_client.h" |
| 11 #include "ui/aura/mus/focus_synchronizer_delegate.h" | 11 #include "ui/aura/mus/focus_synchronizer_delegate.h" |
| 12 #include "ui/aura/mus/window_mus.h" | 12 #include "ui/aura/mus/window_mus.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 | 14 |
| 15 namespace aura { | 15 namespace aura { |
| 16 | 16 |
| 17 FocusSynchronizer::FocusSynchronizer(FocusSynchronizerDelegate* delegate, | 17 FocusSynchronizer::FocusSynchronizer(FocusSynchronizerDelegate* delegate, |
| 18 ui::mojom::WindowTree* window_tree) | 18 ui::mojom::WindowTree* window_tree) |
| 19 : delegate_(delegate), window_tree_(window_tree) {} | 19 : delegate_(delegate), window_tree_(window_tree) {} |
| 20 | 20 |
| 21 FocusSynchronizer::~FocusSynchronizer() { | 21 FocusSynchronizer::~FocusSynchronizer() { |
| 22 SetActiveFocusClientInternal(nullptr); | 22 SetActiveFocusClientInternal(nullptr); |
| 23 if (active_focus_client_root_) |
| 24 active_focus_client_root_->RemoveObserver(this); |
| 23 } | 25 } |
| 24 | 26 |
| 25 void FocusSynchronizer::AddObserver(FocusSynchronizerObserver* observer) { | 27 void FocusSynchronizer::AddObserver(FocusSynchronizerObserver* observer) { |
| 26 observers_.AddObserver(observer); | 28 observers_.AddObserver(observer); |
| 27 } | 29 } |
| 28 | 30 |
| 29 void FocusSynchronizer::RemoveObserver(FocusSynchronizerObserver* observer) { | 31 void FocusSynchronizer::RemoveObserver(FocusSynchronizerObserver* observer) { |
| 30 observers_.RemoveObserver(observer); | 32 observers_.RemoveObserver(observer); |
| 31 } | 33 } |
| 32 | 34 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 intptr_t old) { | 143 intptr_t old) { |
| 142 DCHECK(!is_singleton_focus_client_); | 144 DCHECK(!is_singleton_focus_client_); |
| 143 if (key != client::kFocusClientKey) | 145 if (key != client::kFocusClientKey) |
| 144 return; | 146 return; |
| 145 | 147 |
| 146 // Assume if the focus client changes the window is being destroyed. | 148 // Assume if the focus client changes the window is being destroyed. |
| 147 SetActiveFocusClient(nullptr, nullptr); | 149 SetActiveFocusClient(nullptr, nullptr); |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace aura | 152 } // namespace aura |
| OLD | NEW |