Maintain a connection to each profile's PrefService from ash.

Move responsibility for managing per-user PrefService instances into
ash::SessionController. When a new user is added, SessionController uses
its Connector to connect to the "ash_pref_connector" service to obtain a
prefs::mojom::PrefStoreConnector for that user, which it then uses to
construct a client PrefService.

Provide access to per-user prefs via GetUserPrefServiceForUser() which
returns the PrefService for a particular AccountId or null if the
connection has not completed successfully, and
GetLastActiveUserPrefService(), which returns the PrefService for the
last active user that had a PrefService.

Consolidate the mash and non-mash code-paths for per-user prefs to
always access per-user PrefService over mojo.

Add a test-only method to SessionController so unit tests can inject a
PrefService for an individual user without mocking out service manager.
Change TestSessionControllerClient to default to injecting a
PrefServicefPrefService for each user session it adds. Update ash
unit tests to no longer inject their own PrefServices now the test
helper handles it.

Replace the preferences_forwarder service with ash_preferences_connector
service. Instead of forwarding connections to the pref service for the
active user, it provides access to a prefs::mojom::PrefStoreConnector
for the AccountId request by SessionController.

Add a new overload to prefs::ConnectToPrefService that takes a
user-provided PrefStoreConnectorPtr for SessionController to use.

Change prefs::ConnectToPrefService to wait until all PrefStores are
initialized instead of just the user prefs pref store and add plumbing
to PrefService and PrefValueStore to expose this information.

Fix PrefRegistrySyncable::ForkForIncognito() to copy all fields from
PrefRegistry.

Bug: 752993,753149
Change-Id: Id36a18988b1e713199f3029cb04a72dd63bf1b34
Reviewed-on: https://chromium-review.googlesource.com/605027
Commit-Queue: Sam McNally <[email protected]>
Reviewed-by: Bernhard Bauer <[email protected]>
Reviewed-by: Michael Wasserman <[email protected]>
Reviewed-by: Xiyuan Xia <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
Reviewed-by: Oliver Chang <[email protected]>
Reviewed-by: James Cook <[email protected]>
Cr-Commit-Position: refs/heads/master@{#494684}
65 files changed