Foreign tab suggestions should update when disabling sync or signing out.

Previously we were responding to OnSyncConfigurationCompleted by
invoking our callback to regenerate suggestions. This covered initial
sync setup, along with enabling or disabling any types from sync, in
case Open Tabs was one of the types that was changing. However, when
sync is completely disabled or the user signs out, we don't perform an
configuration, but session data is no longer there. We want to clear
our suggestions, but the hook we were using isn't called.

The approach this CL takes is to switch to using OnStateChanged for
this tracking. This event is called extremely often, for a variety of
things. Because generating suggestions when there are actual sessions
data is not computationally trivial, we only want to invoke the
callback in TabDelegateSyncAdapter when it is reasonable to do so, so
we've added a bool state variable to track the previous state, and only
invoke the callback when we're transitioning between states.

Note that this change does not mean that the current or any existing
NTPs are going to remove their foreign sessions data. By having the
ForeignSessionsSuggestionsProvider provide new suggestions, this
current only seems to affect NTPs that are opened afterwards.

BUG=669041

Review-Url: https://codereview.chromium.org/2578293002
Cr-Commit-Position: refs/heads/master@{#439578}
6 files changed