Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / android / accessibility / font_size_prefs_android.h
blobc89639e19379d9d81cae74d18a1211b20e727600
1 // Copyright 2014 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.
5 #ifndef CHROME_BROWSER_ANDROID_ACCESSIBILITY_FONT_SIZE_PREFS_ANDROID_H_
6 #define CHROME_BROWSER_ANDROID_ACCESSIBILITY_FONT_SIZE_PREFS_ANDROID_H_
8 #include <jni.h>
9 #include "base/android/scoped_java_ref.h"
10 #include "base/observer_list.h"
12 class PrefChangeRegistrar;
13 class PrefService;
16 * Native implementation of FontSizePrefs. This class is used to get and set
17 * FontScaleFactor and ForceEnableZoom.
19 class FontSizePrefsAndroid {
20 public:
21 class Observer {
22 public:
23 virtual void OnChangeFontSize(float font) = 0;
24 virtual void OnChangeForceEnableZoom(bool enabled) = 0;
27 FontSizePrefsAndroid(JNIEnv* env, jobject obj);
28 ~FontSizePrefsAndroid();
30 void SetFontScaleFactor(JNIEnv* env, jobject obj, jfloat font);
31 float GetFontScaleFactor(JNIEnv* env, jobject obj);
32 void SetForceEnableZoom(JNIEnv* env, jobject obj, jboolean enabled);
33 bool GetForceEnableZoom(JNIEnv* env, jobject obj);
35 void AddObserver(JNIEnv* env, jobject obj, jlong obs);
36 void RemoveObserver(JNIEnv* env, jobject obj, jlong obs);
38 static bool Register(JNIEnv* env);
40 private:
41 // Callback for FontScaleFactor changes from pref change registrar.
42 void OnFontScaleFactorPrefsChanged();
43 // Callback for ForceEnableZoom changes from pref change registrar.
44 void OnForceEnableZoomPrefsChanged();
46 scoped_ptr<PrefChangeRegistrar> pref_change_registrar_;
47 PrefService* const pref_service_;
48 base::ObserverList<Observer> observers_;
49 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
51 DISALLOW_COPY_AND_ASSIGN(FontSizePrefsAndroid);
55 * Native implementation of FontSizePrefsObserverWrapper. Adds observer support
56 * for FontSizePrefs.
58 class FontSizePrefsObserverAndroid : public FontSizePrefsAndroid::Observer {
59 public:
60 FontSizePrefsObserverAndroid(JNIEnv* env, jobject obj);
61 virtual ~FontSizePrefsObserverAndroid();
62 void DestroyObserverAndroid(JNIEnv* env, jobject obj);
64 static bool Register(JNIEnv* env);
66 // FontSizePrefs::Observer implementation.
67 void OnChangeFontSize(float font) override;
68 void OnChangeForceEnableZoom(bool enabled) override;
70 private:
71 base::android::ScopedJavaGlobalRef<jobject> java_ref_;
74 #endif // CHROME_BROWSER_ANDROID_ACCESSIBILITY_FONT_SIZE_PREFS_ANDROID_H_