Reland [Mac] Get Suggestions from Whole Text and Current Selection

Currently, the SuggestedTextTouchBarController generates text
suggestions based only text being selected and doesn't take any
surrounding text into account. The goal is to generate text
suggestions from all the text present in the textfield and the
current cursor position, which results in behavior more similar to
Safari's text suggestions.

First, WebContents::DidChangeTextSelection() and
WebContentsObserver::DidChangeTextSelection() were modified to pass in
the whole text in the textfield and the current selection range
instead of the selected text.

The method requestSuggestionsForText: was modified to
requestSuggestionsForText:inRange: so that it may receive the full
text in the textfield along with the range of the current selection.

The WebContentsTextObserver was edited to also observe when a
webpage finishes loading. This way, the controller can check whether
the cursor is in a textfield before the text selection changes. This
is necessary for websites in which a textfield is autofocused.
This currently does not account for text that may be in the
autofocused textfield, which will be addressed in a later CL.

The browser tests for SuggestedTextTouchBarController were updated to
reflect the new behavior. TouchBarTest now only checks if a touch
bar is created based on whether or not a textfield is focused, as that
is the only condition required for the creation of a touch bar. Text
selection test now passes a range to -webContentsTextSelectionChanged:
and tests that the range is stored properly afterwards. Unnecessary
asserts were removed from both tests. The way that tests access the
SuggestedTextTouchBarController was also modified to reduce the amount
of memory used and make the code cleaner. Now, tests access one global
controller rather than creating a new one for every test.

Bug: 717553
Change-Id: Ia9a62a1b802976cbc76e2243d60d0a41cd1844cd
Reviewed-on: https://chromium-review.googlesource.com/1119363
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@{#571624}
8 files changed