Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / components / dom_distiller / core / distilled_page_prefs_android.cc
blob051d821c2e4ca8de1388efb579659f40cbe52b4d
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 #include "components/dom_distiller/core/distilled_page_prefs_android.h"
7 #include "components/dom_distiller/core/distilled_page_prefs.h"
8 #include "components/dom_distiller/core/dom_distiller_service.h"
9 #include "jni/DistilledPagePrefs_jni.h"
11 namespace dom_distiller {
13 namespace android {
15 DistilledPagePrefsAndroid::DistilledPagePrefsAndroid(
16 JNIEnv* env,
17 jobject obj,
18 DistilledPagePrefs* distilled_page_prefs_ptr)
19 : distilled_page_prefs_(distilled_page_prefs_ptr) {
22 DistilledPagePrefsAndroid::~DistilledPagePrefsAndroid() {
25 void DistilledPagePrefsAndroid::SetFontFamily(JNIEnv* env,
26 jobject obj,
27 jint font_family) {
28 distilled_page_prefs_->SetFontFamily(
29 static_cast<DistilledPagePrefs::FontFamily>(font_family));
32 jint DistilledPagePrefsAndroid::GetFontFamily(JNIEnv* env, jobject obj) {
33 return (int) distilled_page_prefs_->GetFontFamily();
36 void DistilledPagePrefsAndroid::SetTheme(JNIEnv* env, jobject obj, jint theme) {
37 distilled_page_prefs_->SetTheme(
38 static_cast<DistilledPagePrefs::Theme>(theme));
41 jint DistilledPagePrefsAndroid::GetTheme(JNIEnv* env, jobject obj) {
42 return (int) distilled_page_prefs_->GetTheme();
45 jlong Init(JNIEnv* env, jobject obj, jlong distilled_page_prefs_ptr) {
46 DistilledPagePrefs* distilled_page_prefs =
47 reinterpret_cast<DistilledPagePrefs*>(distilled_page_prefs_ptr);
48 DistilledPagePrefsAndroid* distilled_page_prefs_android =
49 new DistilledPagePrefsAndroid(env, obj, distilled_page_prefs);
50 return reinterpret_cast<intptr_t>(distilled_page_prefs_android);
53 bool DistilledPagePrefsAndroid::Register(JNIEnv* env) {
54 return RegisterNativesImpl(env);
57 void DistilledPagePrefsAndroid::AddObserver(JNIEnv* env,
58 jobject obj,
59 jlong observer_ptr) {
60 DistilledPagePrefsObserverAndroid* distilled_page_prefs_observer_wrapper =
61 reinterpret_cast<DistilledPagePrefsObserverAndroid*>(observer_ptr);
62 distilled_page_prefs_->AddObserver(distilled_page_prefs_observer_wrapper);
65 void DistilledPagePrefsAndroid::RemoveObserver(JNIEnv* env,
66 jobject obj,
67 jlong observer_ptr) {
68 DistilledPagePrefsObserverAndroid* distilled_page_prefs_observer_wrapper =
69 reinterpret_cast<DistilledPagePrefsObserverAndroid*>(observer_ptr);
70 distilled_page_prefs_->RemoveObserver(distilled_page_prefs_observer_wrapper);
73 DistilledPagePrefsObserverAndroid::DistilledPagePrefsObserverAndroid(
74 JNIEnv* env,
75 jobject obj) {
76 java_ref_.Reset(env, obj);
79 DistilledPagePrefsObserverAndroid::~DistilledPagePrefsObserverAndroid() {}
81 void DistilledPagePrefsObserverAndroid::DestroyObserverAndroid(JNIEnv* env,
82 jobject obj) {
83 delete this;
86 void DistilledPagePrefsObserverAndroid::OnChangeFontFamily(
87 DistilledPagePrefs::FontFamily new_font_family) {
88 JNIEnv* env = base::android::AttachCurrentThread();
89 Java_DistilledPagePrefsObserverWrapper_onChangeFontFamily(
90 env, java_ref_.obj(), (int)new_font_family);
93 void DistilledPagePrefsObserverAndroid::OnChangeTheme(
94 DistilledPagePrefs::Theme new_theme) {
95 JNIEnv* env = base::android::AttachCurrentThread();
96 Java_DistilledPagePrefsObserverWrapper_onChangeTheme(
97 env, java_ref_.obj(), (int)new_theme);
100 jlong InitObserverAndroid(JNIEnv* env, jobject obj) {
101 DistilledPagePrefsObserverAndroid* observer_android =
102 new DistilledPagePrefsObserverAndroid(env, obj);
103 return reinterpret_cast<intptr_t>(observer_android);
106 } // namespace android
108 } // namespace dom_distiller