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 "chromecast/base/chromecast_config_android.h"
7 #include "base/android/jni_android.h"
8 #include "base/lazy_instance.h"
9 #include "jni/ChromecastConfigAndroid_jni.h"
11 namespace chromecast
{
15 base::LazyInstance
<ChromecastConfigAndroid
> g_instance
=
16 LAZY_INSTANCE_INITIALIZER
;
20 ChromecastConfigAndroid
* ChromecastConfigAndroid::GetInstance() {
21 return g_instance
.Pointer();
25 bool ChromecastConfigAndroid::RegisterJni(JNIEnv
* env
) {
26 return RegisterNativesImpl(env
);
29 ChromecastConfigAndroid::ChromecastConfigAndroid() {
32 ChromecastConfigAndroid::~ChromecastConfigAndroid() {
35 bool ChromecastConfigAndroid::CanSendUsageStats() {
36 // TODO(gunsch): make opt-in.stats pref the source of truth for this data,
37 // instead of Android prefs, then delete ChromecastConfigAndroid.
38 JNIEnv
* env
= base::android::AttachCurrentThread();
39 return Java_ChromecastConfigAndroid_canSendUsageStats(
40 env
, base::android::GetApplicationContext());
43 // Registers a handler to be notified when SendUsageStats is changed.
44 void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback(
45 const base::Callback
<void(bool)>& callback
) {
46 send_usage_stats_changed_callback_
= callback
;
50 void SetSendUsageStatsEnabled(JNIEnv
* env
,
51 const JavaParamRef
<jclass
>& caller
,
53 ChromecastConfigAndroid::GetInstance()->
54 send_usage_stats_changed_callback().Run(enabled
);
57 } // namespace android
58 } // namespace chromecast