Chromium Code Reviews| Index: ash/magnifier/magnification_controller.cc |
| diff --git a/ash/magnifier/magnification_controller.cc b/ash/magnifier/magnification_controller.cc |
| index a6ad0a1a1ad601877d8aa578781503fb3acfbffa..f7cc8b1c1ce6036c5fdc4548ef75432569d2a243 100644 |
| --- a/ash/magnifier/magnification_controller.cc |
| +++ b/ash/magnifier/magnification_controller.cc |
| @@ -62,6 +62,12 @@ void MoveCursorTo(aura::WindowTreeHost* host, const gfx::Point& root_location) { |
| gfx::ToCeiledPoint(host_location_3f.AsPointF())); |
| } |
| +ui::InputMethod* GetInputMethod(aura::Window* root_window) { |
| + if (root_window->GetHost()) |
| + return root_window->GetHost()->GetInputMethod(); |
| + return NULL; |
|
James Cook
2015/06/01 22:20:59
nullptr
Shu Chen
2015/06/02 04:11:16
Done.
|
| +} |
| + |
| } // namespace |
| namespace ash { |
| @@ -205,8 +211,6 @@ class MagnificationControllerImpl : virtual public MagnificationController, |
| ScrollDirection scroll_direction_; |
| - ui::InputMethod* input_method_; // Not owned. |
| - |
| DISALLOW_COPY_AND_ASSIGN(MagnificationControllerImpl); |
| }; |
| @@ -219,16 +223,16 @@ MagnificationControllerImpl::MagnificationControllerImpl() |
| is_enabled_(false), |
| move_cursor_after_animation_(false), |
| scale_(kNonMagnifiedScale), |
| - scroll_direction_(SCROLL_NONE), |
| - input_method_(NULL) { |
| + scroll_direction_(SCROLL_NONE) { |
| Shell::GetInstance()->AddPreTargetHandler(this); |
| root_window_->AddObserver(this); |
| point_of_interest_ = root_window_->bounds().CenterPoint(); |
| } |
| MagnificationControllerImpl::~MagnificationControllerImpl() { |
| - if (input_method_) |
| - input_method_->RemoveObserver(this); |
| + ui::InputMethod* input_method = GetInputMethod(root_window_); |
| + if (input_method) |
| + input_method->RemoveObserver(this); |
| root_window_->RemoveObserver(this); |
| @@ -529,13 +533,10 @@ void MagnificationControllerImpl::SetScrollDirection( |
| void MagnificationControllerImpl::SetEnabled(bool enabled) { |
| Shell* shell = Shell::GetInstance(); |
| + ui::InputMethod* input_method = GetInputMethod(root_window_); |
| if (enabled) { |
| - if (!input_method_) { |
| - input_method_ = |
| - root_window_->GetProperty(aura::client::kRootWindowInputMethodKey); |
| - if (input_method_) |
| - input_method_->AddObserver(this); |
| - } |
| + if (!is_enabled_ && input_method) |
| + input_method->AddObserver(this); |
| float scale = |
| Shell::GetInstance()->accessibility_delegate()-> |
| @@ -556,10 +557,8 @@ void MagnificationControllerImpl::SetEnabled(bool enabled) { |
| if (!is_enabled_) |
| return; |
| - if (input_method_) { |
| - input_method_->RemoveObserver(this); |
| - input_method_ = NULL; |
| - } |
| + if (input_method) |
| + input_method->RemoveObserver(this); |
| RedrawKeepingMousePosition(kNonMagnifiedScale, true); |
| is_enabled_ = enabled; |