| 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 #ifndef CHROME_BROWSER_PREFS_PREFERENCES_SERVICE_H_ |  | 
| 6 #define CHROME_BROWSER_PREFS_PREFERENCES_SERVICE_H_ |  | 
| 7 |  | 
| 8 #include <memory> |  | 
| 9 |  | 
| 10 #include "base/macros.h" |  | 
| 11 #include "services/preferences/public/interfaces/preferences.mojom.h" |  | 
| 12 |  | 
| 13 namespace test { |  | 
| 14 class PreferencesServiceTest; |  | 
| 15 } |  | 
| 16 |  | 
| 17 class PrefChangeRegistrar; |  | 
| 18 class PrefService; |  | 
| 19 class Profile; |  | 
| 20 |  | 
| 21 // Implementation of prefs::mojom::PreferencesService that accepts a single |  | 
| 22 // prefs::mojom::PreferencesServiceClient. |  | 
| 23 // |  | 
| 24 // After calling AddObserver PreferencesService will begin observing changes to |  | 
| 25 // the requested preferences, notifying the client of all changes. |  | 
| 26 class PreferencesService : public prefs::mojom::PreferencesService { |  | 
| 27  public: |  | 
| 28   PreferencesService(prefs::mojom::PreferencesServiceClientPtr client, |  | 
| 29                      Profile* profile); |  | 
| 30   ~PreferencesService() override; |  | 
| 31 |  | 
| 32  private: |  | 
| 33   friend class test::PreferencesServiceTest; |  | 
| 34 |  | 
| 35   // PrefChangeRegistrar::NamedChangeCallback: |  | 
| 36   void PreferenceChanged(const std::string& preference_name); |  | 
| 37 |  | 
| 38   // mojom::PreferencesService: |  | 
| 39   void SetPreferences( |  | 
| 40       std::unique_ptr<base::DictionaryValue> preferences) override; |  | 
| 41   void Subscribe(const std::vector<std::string>& preferences) override; |  | 
| 42 |  | 
| 43   // Tracks the desired preferences, and listens for updates. |  | 
| 44   std::unique_ptr<PrefChangeRegistrar> preferences_change_registrar_; |  | 
| 45   prefs::mojom::PreferencesServiceClientPtr client_; |  | 
| 46   PrefService* service_; |  | 
| 47 |  | 
| 48   // Used to prevent notifying |client_| of changes caused by it calling |  | 
| 49   // SetPreferences. |  | 
| 50   bool setting_preferences_; |  | 
| 51 |  | 
| 52   DISALLOW_COPY_AND_ASSIGN(PreferencesService); |  | 
| 53 }; |  | 
| 54 |  | 
| 55 #endif  // CHROME_BROWSER_PREFS_PREFERENCES_SERVICE_H_ |  | 
| OLD | NEW | 
|---|