OLD | NEW |
| (Empty) |
1 // Copyright 2016 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. | |
4 | |
5 #include "blimp/client/core/settings/android/settings_observer_proxy.h" | |
6 | |
7 #include "base/android/jni_android.h" | |
8 #include "base/android/jni_string.h" | |
9 #include "jni/SettingsObserverProxy_jni.h" | |
10 | |
11 namespace blimp { | |
12 namespace client { | |
13 | |
14 jlong Init(JNIEnv* env, | |
15 const base::android::JavaParamRef<jobject>& jobj, | |
16 const base::android::JavaParamRef<jobject>& jsettings) { | |
17 SettingsAndroid* settings_android = | |
18 SettingsAndroid::FromJavaObject(env, jsettings); | |
19 CHECK(settings_android); | |
20 | |
21 return reinterpret_cast<intptr_t>( | |
22 new SettingsObserverProxy(env, jobj, settings_android)); | |
23 } | |
24 | |
25 // static | |
26 bool SettingsObserverProxy::RegisterJni(JNIEnv* env) { | |
27 return RegisterNativesImpl(env); | |
28 } | |
29 | |
30 SettingsObserverProxy::SettingsObserverProxy(JNIEnv* env, | |
31 jobject obj, | |
32 SettingsAndroid* settings_android) | |
33 : settings_android_(settings_android) { | |
34 settings_android_->AddObserver(this); | |
35 java_obj_.Reset(env, obj); | |
36 } | |
37 | |
38 SettingsObserverProxy::~SettingsObserverProxy() { | |
39 if (settings_android_) | |
40 settings_android_->RemoveObserver(this); | |
41 } | |
42 | |
43 void SettingsObserverProxy::Destroy( | |
44 JNIEnv* env, | |
45 const base::android::JavaParamRef<jobject>& jobj) { | |
46 settings_android_->RemoveObserver(this); | |
47 delete this; | |
48 } | |
49 | |
50 void SettingsObserverProxy::OnBlimpModeEnabled(bool enable) { | |
51 JNIEnv* env = base::android::AttachCurrentThread(); | |
52 Java_SettingsObserverProxy_onBlimpModeEnabled(env, java_obj_, enable); | |
53 } | |
54 | |
55 void SettingsObserverProxy::OnShowNetworkStatsChanged(bool enable) { | |
56 JNIEnv* env = base::android::AttachCurrentThread(); | |
57 Java_SettingsObserverProxy_onShowNetworkStatsChanged(env, java_obj_, enable); | |
58 } | |
59 | |
60 void SettingsObserverProxy::OnRecordWholeDocumentChanged(bool enable) { | |
61 JNIEnv* env = base::android::AttachCurrentThread(); | |
62 Java_SettingsObserverProxy_onRecordWholeDocumentChanged(env, java_obj_, | |
63 enable); | |
64 } | |
65 | |
66 void SettingsObserverProxy::OnRestartRequired() { | |
67 JNIEnv* env = base::android::AttachCurrentThread(); | |
68 Java_SettingsObserverProxy_onRestartRequired(env, java_obj_); | |
69 } | |
70 | |
71 } // namespace client | |
72 } // namespace blimp | |
OLD | NEW |