Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Unified Diff: components/dom_distiller/core/distilled_page_prefs_android.cc

Issue 403323005: Observer Support for DistilledPagePrefs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed observerMap type from HashMap to Map Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/dom_distiller/core/distilled_page_prefs_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/core/distilled_page_prefs_android.cc
diff --git a/components/dom_distiller/core/distilled_page_prefs_android.cc b/components/dom_distiller/core/distilled_page_prefs_android.cc
index a4edfbd690516145a0f87b2022e57c9c06627dc3..e6fb247376cc241fd7e981b7ff9e90e352ad0fd7 100644
--- a/components/dom_distiller/core/distilled_page_prefs_android.cc
+++ b/components/dom_distiller/core/distilled_page_prefs_android.cc
@@ -9,13 +9,14 @@
#include "jni/DistilledPagePrefs_jni.h"
namespace dom_distiller {
+
namespace android {
DistilledPagePrefsAndroid::DistilledPagePrefsAndroid(
JNIEnv* env,
jobject obj,
- DistilledPagePrefs* distillerPagePrefsPtr)
- : distilled_page_prefs_(distillerPagePrefsPtr) {
+ DistilledPagePrefs* distilled_page_prefs_ptr)
+ : distilled_page_prefs_(distilled_page_prefs_ptr) {
}
DistilledPagePrefsAndroid::~DistilledPagePrefsAndroid() {
@@ -29,11 +30,11 @@ jint DistilledPagePrefsAndroid::GetTheme(JNIEnv* env, jobject obj) {
return (int)distilled_page_prefs_->GetTheme();
}
-jlong Init(JNIEnv* env, jobject obj, jlong distilledPagePrefsPtr) {
- DistilledPagePrefs* distilledPagePrefs =
- reinterpret_cast<DistilledPagePrefs*>(distilledPagePrefsPtr);
+jlong Init(JNIEnv* env, jobject obj, jlong distilled_page_prefs_ptr) {
+ DistilledPagePrefs* distilled_page_prefs =
+ reinterpret_cast<DistilledPagePrefs*>(distilled_page_prefs_ptr);
DistilledPagePrefsAndroid* distilled_page_prefs_android =
- new DistilledPagePrefsAndroid(env, obj, distilledPagePrefs);
+ new DistilledPagePrefsAndroid(env, obj, distilled_page_prefs);
return reinterpret_cast<intptr_t>(distilled_page_prefs_android);
}
@@ -41,5 +42,48 @@ bool DistilledPagePrefsAndroid::Register(JNIEnv* env) {
return RegisterNativesImpl(env);
}
+void DistilledPagePrefsAndroid::AddObserver(JNIEnv* env,
+ jobject obj,
+ jlong observer_ptr) {
+ DistilledPagePrefsObserverAndroid* distilled_page_prefs_observer_wrapper =
+ reinterpret_cast<DistilledPagePrefsObserverAndroid*>(observer_ptr);
+ distilled_page_prefs_->AddObserver(distilled_page_prefs_observer_wrapper);
+}
+
+void DistilledPagePrefsAndroid::RemoveObserver(JNIEnv* env,
+ jobject obj,
+ jlong observer_ptr) {
+ DistilledPagePrefsObserverAndroid* distilled_page_prefs_observer_wrapper =
+ reinterpret_cast<DistilledPagePrefsObserverAndroid*>(observer_ptr);
+ distilled_page_prefs_->RemoveObserver(distilled_page_prefs_observer_wrapper);
+}
+
+DistilledPagePrefsObserverAndroid::DistilledPagePrefsObserverAndroid(
+ JNIEnv* env,
+ jobject obj) {
+ java_ref_.Reset(env, obj);
+}
+
+DistilledPagePrefsObserverAndroid::~DistilledPagePrefsObserverAndroid() {}
+
+void DistilledPagePrefsObserverAndroid::DestroyObserverAndroid(JNIEnv* env,
+ jobject obj) {
+ delete this;
+}
+
+void DistilledPagePrefsObserverAndroid::OnChangeTheme(
+ DistilledPagePrefs::Theme new_theme) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ Java_DistilledPagePrefsObserverWrapper_onChangeTheme(
+ env, java_ref_.obj(), (int)new_theme);
+}
+
+jlong InitObserverAndroid(JNIEnv* env, jobject obj) {
+ DistilledPagePrefsObserverAndroid* observer_android =
+ new DistilledPagePrefsObserverAndroid(env, obj);
+ return reinterpret_cast<intptr_t>(observer_android);
+}
+
} // namespace android
+
} // namespace dom_distiller
« no previous file with comments | « components/dom_distiller/core/distilled_page_prefs_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698