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_
9 #include "base/android/scoped_java_ref.h"
10 #include "base/observer_list.h"
12 class PrefChangeRegistrar
;
16 * Native implementation of FontSizePrefs. This class is used to get and set
17 * FontScaleFactor and ForceEnableZoom.
19 class FontSizePrefsAndroid
{
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
);
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
58 class FontSizePrefsObserverAndroid
: public FontSizePrefsAndroid::Observer
{
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
;
71 base::android::ScopedJavaGlobalRef
<jobject
> java_ref_
;
74 #endif // CHROME_BROWSER_ANDROID_ACCESSIBILITY_FONT_SIZE_PREFS_ANDROID_H_