OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromecast/base/chromecast_config_android.h" | 5 #include "chromecast/base/chromecast_config_android.h" |
6 | 6 |
7 #include "base/android/context_utils.h" | |
8 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
9 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
10 #include "jni/ChromecastConfigAndroid_jni.h" | 9 #include "jni/ChromecastConfigAndroid_jni.h" |
11 | 10 |
12 using base::android::JavaParamRef; | 11 using base::android::JavaParamRef; |
13 | 12 |
14 namespace chromecast { | 13 namespace chromecast { |
15 namespace android { | 14 namespace android { |
16 | 15 |
17 namespace { | 16 namespace { |
(...skipping 14 matching lines...) Expand all Loading... |
32 ChromecastConfigAndroid::ChromecastConfigAndroid() { | 31 ChromecastConfigAndroid::ChromecastConfigAndroid() { |
33 } | 32 } |
34 | 33 |
35 ChromecastConfigAndroid::~ChromecastConfigAndroid() { | 34 ChromecastConfigAndroid::~ChromecastConfigAndroid() { |
36 } | 35 } |
37 | 36 |
38 bool ChromecastConfigAndroid::CanSendUsageStats() { | 37 bool ChromecastConfigAndroid::CanSendUsageStats() { |
39 // TODO(gunsch): make opt-in.stats pref the source of truth for this data, | 38 // TODO(gunsch): make opt-in.stats pref the source of truth for this data, |
40 // instead of Android prefs, then delete ChromecastConfigAndroid. | 39 // instead of Android prefs, then delete ChromecastConfigAndroid. |
41 JNIEnv* env = base::android::AttachCurrentThread(); | 40 JNIEnv* env = base::android::AttachCurrentThread(); |
42 return Java_ChromecastConfigAndroid_canSendUsageStats( | 41 return Java_ChromecastConfigAndroid_canSendUsageStats(env); |
43 env, base::android::GetApplicationContext()); | |
44 } | 42 } |
45 | 43 |
46 // Registers a handler to be notified when SendUsageStats is changed. | 44 // Registers a handler to be notified when SendUsageStats is changed. |
47 void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback( | 45 void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback( |
48 const base::Callback<void(bool)>& callback) { | 46 const base::Callback<void(bool)>& callback) { |
49 send_usage_stats_changed_callback_ = callback; | 47 send_usage_stats_changed_callback_ = callback; |
50 } | 48 } |
51 | 49 |
52 // Called from Java. | 50 // Called from Java. |
53 void SetSendUsageStatsEnabled(JNIEnv* env, | 51 void SetSendUsageStatsEnabled(JNIEnv* env, |
54 const JavaParamRef<jclass>& caller, | 52 const JavaParamRef<jclass>& caller, |
55 jboolean enabled) { | 53 jboolean enabled) { |
56 ChromecastConfigAndroid::GetInstance()-> | 54 ChromecastConfigAndroid::GetInstance()-> |
57 send_usage_stats_changed_callback().Run(enabled); | 55 send_usage_stats_changed_callback().Run(enabled); |
58 } | 56 } |
59 | 57 |
60 } // namespace android | 58 } // namespace android |
61 } // namespace chromecast | 59 } // namespace chromecast |
OLD | NEW |