[Smart Selection] Fix selection menu flakiness

Current Smart Selection workflow:

1) When receiving showSelectionMenu() call in SelectionPopupController,
it asks SmartSelectionClient to do classification and suggestion.
2) A callback onClassified() in SelectionPopupController is called when
received classification/suggestion result.
3) onClassified() will call adjustSelectionByCharacterOffset() if
necessary.
4) When selection range expands, SelectionPopupController will receive
a onSelectionEvent() call, then it triggers selection menu if
SELECTION_HANDLES_MOVED event comes.

This workflow has one flaw since SELECTION_HANDLES_* events are not
very reliable for this use case. Because under certain condition the
original long press caused selection and the later selection expansion
event can be draw at once. In this case, there is only one
SELECTION_HANDLES_SHOWN event without a following
SELECTION_HANDLES_MOVED event will happen.

This CL changed 4), let adjustSelectionByCharacterOffset() triggers
another showSelectionMenu() call and handle the last selection menu
event from that point. It removes the dependency on
SELECTION_HANDLES_* events, therefore resolved the bug.

Bug: 763201
Change-Id: I3688fbb0a31e3794486cc9eab162f4392ab6ff80
Reviewed-on: https://chromium-review.googlesource.com/669881
Commit-Queue: Shimi Zhang <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Bo <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Reviewed-by: Donn Denman <[email protected]>
Reviewed-by: Changwan Ryu <[email protected]>
Cr-Commit-Position: refs/heads/master@{#504844}
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 57f5b07b..61e22be 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -516,7 +516,8 @@
   // beginning of the document, a positive amount moves the selection towards
   // the end of the document.
   virtual void AdjustSelectionByCharacterOffset(int start_adjust,
-                                                int end_adjust) = 0;
+                                                int end_adjust,
+                                                bool show_selection_menu) = 0;
 
   // Replaces the currently selected word or a word around the cursor.
   virtual void Replace(const base::string16& word) = 0;