Fix invalid cast in SavePasswordsPreferences#resetList

The resetList method tries to call PreferenceGroup#removeAll on
TextMessagePreference (which is not a PreferenceGroup) if an update of
the settings happens while the last state had no saved passwords to
display.

This is a rare situation because people who have no saved passwords
are not very often inspecting their passwords settings, but can happen
in reality as well (e.g., when somebody inspects the page during early
moments of syncing and Chrome sync populates the page as the user
views it).

This CL introduces a special method to do the job of resetList in the
case there are no lists, and adds a test which executed the invalid
cast before the fix.

Bug: 788701
Change-Id: I64ada510deb78cc7b8f22f085ef2f401e9bb76ba
Reviewed-on: https://chromium-review.googlesource.com/806165
Commit-Queue: Vaclav Brozek <vabr@chromium.org>
Reviewed-by: Finnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521667}
2 files changed