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

Unified Diff: chromecast/base/chromecast_config_android.cc

Issue 1180633002: Chromecast: don't try to upload crash immediately. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: rebase Created 5 years, 6 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
Index: chromecast/base/chromecast_config_android.cc
diff --git a/chromecast/base/chromecast_config_android.cc b/chromecast/base/chromecast_config_android.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f16b4733069fa4b63d05f6b61dc5ac820beba58a
--- /dev/null
+++ b/chromecast/base/chromecast_config_android.cc
@@ -0,0 +1,56 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromecast/base/chromecast_config_android.h"
+
+#include "base/android/jni_android.h"
+#include "base/lazy_instance.h"
+#include "jni/ChromecastConfigAndroid_jni.h"
+
+namespace chromecast {
+namespace android {
+
+namespace {
+base::LazyInstance<ChromecastConfigAndroid> g_instance =
+ LAZY_INSTANCE_INITIALIZER;
+} // namespace
+
+// static
+ChromecastConfigAndroid* ChromecastConfigAndroid::GetInstance() {
+ return g_instance.Pointer();
+}
+
+// static
+bool ChromecastConfigAndroid::RegisterJni(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+ChromecastConfigAndroid::ChromecastConfigAndroid() {
+}
+
+ChromecastConfigAndroid::~ChromecastConfigAndroid() {
+}
+
+bool ChromecastConfigAndroid::CanSendUsageStats() {
+ // TODO(gunsch): make opt-in.stats pref the source of truth for this data,
+ // instead of Android prefs, then delete ChromecastConfigAndroid.
+ JNIEnv* env = base::android::AttachCurrentThread();
+ return Java_ChromecastConfigAndroid_canSendUsageStats(
+ env, base::android::GetApplicationContext());
+}
+
+// Registers a handler to be notified when SendUsageStats is changed.
+void ChromecastConfigAndroid::SetSendUsageStatsChangedCallback(
+ const base::Callback<void(bool)>& callback) {
+ send_usage_stats_changed_callback_ = callback;
+}
+
+// Called from Java.
+void SetSendUsageStatsEnabled(JNIEnv* env, jclass caller, jboolean enabled) {
+ ChromecastConfigAndroid::GetInstance()->
+ send_usage_stats_changed_callback().Run(enabled);
+}
+
+} // namespace android
+} // namespace chromecast

Powered by Google App Engine
This is Rietveld 408576698