Chromium Code Reviews| Index: components/arc/ime/arc_ime_service.cc |
| diff --git a/components/arc/ime/arc_ime_service.cc b/components/arc/ime/arc_ime_service.cc |
| index dd10ba9170642799c66ce96c68f2eb632e3be281..eeeeb5eeb1024fdf520403eab548e0e10cdb3597 100644 |
| --- a/components/arc/ime/arc_ime_service.cc |
| +++ b/components/arc/ime/arc_ime_service.cc |
| @@ -11,7 +11,6 @@ |
| #include "components/arc/ime/arc_ime_bridge_impl.h" |
| #include "components/exo/shell_surface.h" |
| #include "components/exo/surface.h" |
| -#include "ui/aura/client/focus_client.h" |
| #include "ui/aura/env.h" |
| #include "ui/aura/window.h" |
| #include "ui/aura/window_tree_host.h" |
| @@ -42,9 +41,9 @@ ArcImeService::ArcImeService(ArcBridgeService* bridge_service) |
| ime_bridge_(new ArcImeBridgeImpl(this, bridge_service)), |
| ime_type_(ui::TEXT_INPUT_TYPE_NONE), |
| has_composition_text_(false), |
| - focus_client_(nullptr), |
| keyboard_controller_(nullptr), |
| - test_input_method_(nullptr) { |
| + test_input_method_(nullptr), |
| + is_focus_observer_installed_(false) { |
| aura::Env* env = aura::Env::GetInstanceDontCreate(); |
| if (env) |
| env->AddObserver(this); |
| @@ -55,10 +54,8 @@ ArcImeService::~ArcImeService() { |
| if (input_method) |
| input_method->DetachTextInputClient(this); |
| - for (aura::Window* window : arc_windows_.windows()) |
| - window->RemoveObserver(this); |
| - if (focus_client_) |
| - focus_client_->RemoveObserver(this); |
| + if (is_focus_observer_installed_ && exo::WMHelper::GetInstance()) |
|
Yusuke Sato
2016/08/20 01:25:38
Is the is_focus_observer_installed_ check really n
Peng
2016/08/20 13:09:23
As I explained at line 94. It is difficult to remo
|
| + exo::WMHelper::GetInstance()->RemoveFocusObserver(this); |
| aura::Env* env = aura::Env::GetInstanceDontCreate(); |
| if (env) |
| env->RemoveObserver(this); |
| @@ -93,8 +90,10 @@ ui::InputMethod* ArcImeService::GetInputMethod() { |
| void ArcImeService::OnWindowInitialized(aura::Window* new_window) { |
| if (IsArcWindow(new_window)) { |
| - arc_windows_.Add(new_window); |
| - new_window->AddObserver(this); |
| + if (!is_focus_observer_installed_) { |
| + exo::WMHelper::GetInstance()->AddFocusObserver(this); |
|
Yusuke Sato
2016/08/20 01:25:38
Can't we move this to somewhere else (e.g. the con
Peng
2016/08/20 13:09:23
The constructor doesn't work, because this class i
|
| + is_focus_observer_installed_ = true; |
| + } |
| } |
| keyboard::KeyboardController* keyboard_controller = |
| keyboard::KeyboardController::GetInstance(); |
| @@ -105,23 +104,8 @@ void ArcImeService::OnWindowInitialized(aura::Window* new_window) { |
| } |
| } |
| -void ArcImeService::OnWindowAddedToRootWindow(aura::Window* window) { |
| - aura::Window* root = window->GetRootWindow(); |
| - aura::client::FocusClient* focus_client = aura::client::GetFocusClient(root); |
| - if (!focus_client) |
| - return; |
| - |
| - if (focus_client_) { |
| - // Root windows share the same FocusClient in Ash. |
| - DCHECK_EQ(focus_client_, focus_client); |
| - } else { |
| - focus_client_ = focus_client; |
| - focus_client_->AddObserver(this); |
| - } |
| -} |
| - |
| //////////////////////////////////////////////////////////////////////////////// |
| -// Overridden from aura::client::FocusChangeObserver: |
| +// Overridden from exo::WMHelper::FocusChangeObserver: |
| void ArcImeService::OnWindowFocused(aura::Window* gained_focus, |
| aura::Window* lost_focus) { |