[Mac] Moved TextSuggestionsTouchBarController's Range Validity Check

Previously, -updateTextSelection:range:offset: could receive an invalid
range from WebContentsTextObserver::DidChangeTextSelection(). This
invalid range would then cause a crash in -requestSuggestions.

A check has been added to -updateTextSelection:range:offset: to make
sure that a selection with an invalid range is not passed to
-requestSuggestions. This should prevent future crashes.

TextSuggestionsTouchBarControllerTest.InvalidRange tests that an
invalid range does not crash the controller and is handled
properly.

Bug: 717553
Change-Id: I69f49cb1f1819e1d528837767dfb894d8652e84d
Reviewed-on: https://chromium-review.googlesource.com/1178467
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Sarah Chan <spqchan@chromium.org>
Commit-Queue: Tessa Nijssen <tnijssen@google.com>
Cr-Commit-Position: refs/heads/master@{#583815}
2 files changed