1 // Copyright 2012 The Chromium Authors 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 COMPONENTS_PREFS_IOS_PREF_OBSERVER_BRIDGE_H_ 6 #define COMPONENTS_PREFS_IOS_PREF_OBSERVER_BRIDGE_H_ 7 8 #import <Foundation/Foundation.h> 9 10 #include <string> 11 12 class PrefChangeRegistrar; 13 14 @protocol PrefObserverDelegate 15 - (void)onPreferenceChanged:(const std::string&)preferenceName; 16 @end 17 18 class PrefObserverBridge { 19 public: 20 explicit PrefObserverBridge(id<PrefObserverDelegate> delegate); 21 virtual ~PrefObserverBridge(); 22 23 virtual void ObserveChangesForPreference(const std::string& pref_name, 24 PrefChangeRegistrar* registrar); 25 26 private: 27 virtual void OnPreferenceChanged(const std::string& pref_name); 28 29 __weak id<PrefObserverDelegate> delegate_ = nil; 30 }; 31 32 #endif // COMPONENTS_PREFS_IOS_PREF_OBSERVER_BRIDGE_H_ 33