Add CryptAuthDeviceManager for syncing the user's devices from CryptAuth.
[chromium-blink-merge.git] / chromecast / base / chromecast_config_android.cc
blobf16b4733069fa4b63d05f6b61dc5ac820beba58a
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 {
12 namespace android {
14 namespace {
15 base::LazyInstance<ChromecastConfigAndroid> g_instance =
16 LAZY_INSTANCE_INITIALIZER;
17 } // namespace
19 // static
20 ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() {
21 return g_instance.Pointer();
24 // static
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;
49 // Called from Java.
50 void SetSendUsageStatsEnabled(JNIEnv* env, jclass caller, jboolean enabled) {
51 ChromecastConfigAndroid::GetInstance()->
52 send_usage_stats_changed_callback().Run(enabled);
55 } // namespace android
56 } // namespace chromecast