OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/dom_distiller/core/distilled_page_prefs_android.h" | 5 #include "components/dom_distiller/core/distilled_page_prefs_android.h" |
6 | 6 |
7 #include "components/dom_distiller/core/distilled_page_prefs.h" | 7 #include "components/dom_distiller/core/distilled_page_prefs.h" |
8 #include "components/dom_distiller/core/dom_distiller_service.h" | 8 #include "components/dom_distiller/core/dom_distiller_service.h" |
9 #include "jni/DistilledPagePrefs_jni.h" | 9 #include "jni/DistilledPagePrefs_jni.h" |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 void DistilledPagePrefsAndroid::SetTheme(JNIEnv* env, jobject obj, jint theme) { | 36 void DistilledPagePrefsAndroid::SetTheme(JNIEnv* env, jobject obj, jint theme) { |
37 distilled_page_prefs_->SetTheme( | 37 distilled_page_prefs_->SetTheme( |
38 static_cast<DistilledPagePrefs::Theme>(theme)); | 38 static_cast<DistilledPagePrefs::Theme>(theme)); |
39 } | 39 } |
40 | 40 |
41 jint DistilledPagePrefsAndroid::GetTheme(JNIEnv* env, jobject obj) { | 41 jint DistilledPagePrefsAndroid::GetTheme(JNIEnv* env, jobject obj) { |
42 return (int) distilled_page_prefs_->GetTheme(); | 42 return (int) distilled_page_prefs_->GetTheme(); |
43 } | 43 } |
44 | 44 |
| 45 void DistilledPagePrefsAndroid::SetFontScaling(JNIEnv* env, |
| 46 jobject obj, |
| 47 jfloat scaling) { |
| 48 distilled_page_prefs_->SetFontScaling(static_cast<float>(scaling)); |
| 49 } |
| 50 |
| 51 jfloat DistilledPagePrefsAndroid::GetFontScaling(JNIEnv* env, jobject obj) { |
| 52 return distilled_page_prefs_->GetFontScaling(); |
| 53 } |
| 54 |
45 jlong Init(JNIEnv* env, jobject obj, jlong distilled_page_prefs_ptr) { | 55 jlong Init(JNIEnv* env, jobject obj, jlong distilled_page_prefs_ptr) { |
46 DistilledPagePrefs* distilled_page_prefs = | 56 DistilledPagePrefs* distilled_page_prefs = |
47 reinterpret_cast<DistilledPagePrefs*>(distilled_page_prefs_ptr); | 57 reinterpret_cast<DistilledPagePrefs*>(distilled_page_prefs_ptr); |
48 DistilledPagePrefsAndroid* distilled_page_prefs_android = | 58 DistilledPagePrefsAndroid* distilled_page_prefs_android = |
49 new DistilledPagePrefsAndroid(env, obj, distilled_page_prefs); | 59 new DistilledPagePrefsAndroid(env, obj, distilled_page_prefs); |
50 return reinterpret_cast<intptr_t>(distilled_page_prefs_android); | 60 return reinterpret_cast<intptr_t>(distilled_page_prefs_android); |
51 } | 61 } |
52 | 62 |
53 bool DistilledPagePrefsAndroid::Register(JNIEnv* env) { | 63 bool DistilledPagePrefsAndroid::Register(JNIEnv* env) { |
54 return RegisterNativesImpl(env); | 64 return RegisterNativesImpl(env); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 env, java_ref_.obj(), (int)new_font_family); | 100 env, java_ref_.obj(), (int)new_font_family); |
91 } | 101 } |
92 | 102 |
93 void DistilledPagePrefsObserverAndroid::OnChangeTheme( | 103 void DistilledPagePrefsObserverAndroid::OnChangeTheme( |
94 DistilledPagePrefs::Theme new_theme) { | 104 DistilledPagePrefs::Theme new_theme) { |
95 JNIEnv* env = base::android::AttachCurrentThread(); | 105 JNIEnv* env = base::android::AttachCurrentThread(); |
96 Java_DistilledPagePrefsObserverWrapper_onChangeTheme( | 106 Java_DistilledPagePrefsObserverWrapper_onChangeTheme( |
97 env, java_ref_.obj(), (int)new_theme); | 107 env, java_ref_.obj(), (int)new_theme); |
98 } | 108 } |
99 | 109 |
| 110 void DistilledPagePrefsObserverAndroid::OnChangeFontScaling( |
| 111 float scaling) { |
| 112 JNIEnv* env = base::android::AttachCurrentThread(); |
| 113 Java_DistilledPagePrefsObserverWrapper_onChangeFontScaling( |
| 114 env, java_ref_.obj(), scaling); |
| 115 } |
| 116 |
100 jlong InitObserverAndroid(JNIEnv* env, jobject obj) { | 117 jlong InitObserverAndroid(JNIEnv* env, jobject obj) { |
101 DistilledPagePrefsObserverAndroid* observer_android = | 118 DistilledPagePrefsObserverAndroid* observer_android = |
102 new DistilledPagePrefsObserverAndroid(env, obj); | 119 new DistilledPagePrefsObserverAndroid(env, obj); |
103 return reinterpret_cast<intptr_t>(observer_android); | 120 return reinterpret_cast<intptr_t>(observer_android); |
104 } | 121 } |
105 | 122 |
106 } // namespace android | 123 } // namespace android |
107 | 124 |
108 } // namespace dom_distiller | 125 } // namespace dom_distiller |
OLD | NEW |