Commit 5d32b7e3 authored by Ahmed Fakhry's avatar Ahmed Fakhry Committed by Commit Bot

Fix a crash caused by disabling the docked magnifier feature

Despite the fact that the docked magnifier feature is enabled
by default, some users may explicitly disable it, which will
cause crashes if the docked magnifier controller is accessed
without checking that it exists.

BUG=880428

Change-Id: I551edf47184e7c2fa79c4ebf72843758e5ef948c
Reviewed-on: https://chromium-review.googlesource.com/1245731
Commit-Queue: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594382}
parent f78979a7
......@@ -9,6 +9,7 @@
#include "ash/accelerators/accelerator_controller.h"
#include "ash/magnifier/docked_magnifier_controller.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/shell.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/views/focus/focus_manager.h"
......@@ -53,6 +54,8 @@ void AshFocusManagerFactory::Delegate::OnDidChangeFocus(
gfx::Point point_of_interest = bounds_in_screen.CenterPoint();
const ui::InputMethod* input_method = focused_now->GetInputMethod();
const bool docked_magnifier_enabled =
features::IsDockedMagnifierEnabled() && docked_magnifier->GetEnabled();
if (input_method && input_method->GetTextInputClient() &&
input_method->GetTextInputClient()->GetTextInputType() !=
ui::TEXT_INPUT_TYPE_NONE) {
......@@ -64,7 +67,7 @@ void AshFocusManagerFactory::Delegate::OnDidChangeFocus(
// Note: Don't use Rect::IsEmpty() for the below check as in many cases the
// caret can have a zero width or height, but still be valid.
if (caret_bounds.width() || caret_bounds.height()) {
if (docked_magnifier->GetEnabled()) {
if (docked_magnifier_enabled) {
docked_magnifier->OnCaretBoundsChanged(
input_method->GetTextInputClient());
} else if (fullscreen_magnifier->IsEnabled()) {
......@@ -80,7 +83,7 @@ void AshFocusManagerFactory::Delegate::OnDidChangeFocus(
point_of_interest = bounds_in_screen.origin();
}
if (docked_magnifier->GetEnabled())
if (docked_magnifier_enabled)
docked_magnifier->CenterOnPoint(point_of_interest);
else if (fullscreen_magnifier->IsEnabled())
fullscreen_magnifier->CenterOnPoint(point_of_interest);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment