| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/filesystem/public/cpp/prefs/pref_service_factory.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_notifier_impl.h" |
| 9 #include "base/prefs/pref_registry.h" |
| 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/prefs/pref_value_store.h" |
| 12 #include "base/prefs/value_map_pref_store.h" |
| 13 #include "base/prefs/writeable_pref_store.h" |
| 14 #include "components/filesystem/public/cpp/prefs/filesystem_json_pref_store.h" |
| 15 #include "mojo/shell/public/cpp/application_impl.h" |
| 16 |
| 17 namespace filesystem { |
| 18 |
| 19 namespace { |
| 20 |
| 21 // Do-nothing default implementation. |
| 22 void DoNothingHandleReadError(PersistentPrefStore::PrefReadError error) {} |
| 23 |
| 24 } // namespace |
| 25 |
| 26 scoped_ptr<PrefService> CreatePrefService(mojo::ApplicationImpl* application, |
| 27 PrefRegistry* pref_registry) { |
| 28 filesystem::FileSystemPtr filesystem; |
| 29 application->ConnectToService("mojo:filesystem", &filesystem); |
| 30 |
| 31 scoped_refptr<FilesystemJsonPrefStore> user_prefs = |
| 32 new FilesystemJsonPrefStore("preferences.json", std::move(filesystem), |
| 33 nullptr /* TODO(erg): pref filter */); |
| 34 |
| 35 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); |
| 36 scoped_ptr<PrefService> pref_service(new PrefService( |
| 37 pref_notifier, |
| 38 new PrefValueStore(nullptr, nullptr, nullptr, nullptr, user_prefs.get(), |
| 39 nullptr, pref_registry->defaults().get(), |
| 40 pref_notifier), |
| 41 user_prefs.get(), pref_registry, base::Bind(&DoNothingHandleReadError), |
| 42 true /* async */)); |
| 43 return pref_service; |
| 44 } |
| 45 |
| 46 } // namespace filesystem |
| OLD | NEW |