Index: android_webview/browser/aw_metrics_service_client_impl.cc |
diff --git a/android_webview/browser/aw_metrics_service_client_impl.cc b/android_webview/browser/aw_metrics_service_client_impl.cc |
index 2baf2a158ae541d5824bd22eb0732aa666eb5d2f..9acbea58dfce3e8b5993c2c5390319b094b45932 100644 |
--- a/android_webview/browser/aw_metrics_service_client_impl.cc |
+++ b/android_webview/browser/aw_metrics_service_client_impl.cc |
@@ -8,6 +8,7 @@ |
#include "android_webview/common/aw_version_info_values.h" |
#include "android_webview/jni/AwMetricsServiceClient_jni.h" |
#include "base/android/build_info.h" |
+#include "base/android/jni_string.h" |
#include "base/bind.h" |
#include "base/files/file_util.h" |
#include "base/guid.h" |
@@ -23,7 +24,10 @@ |
#include "components/metrics/profiler/profiler_metrics_provider.h" |
#include "components/metrics/ui/screen_info_metrics_provider.h" |
#include "components/metrics/url_constants.h" |
+#include "components/metrics/version_utils.h" |
#include "components/prefs/pref_service.h" |
+#include "components/version_info/channel_android.h" |
+#include "components/version_info/version_info.h" |
#include "content/public/browser/browser_thread.h" |
namespace android_webview { |
@@ -87,6 +91,13 @@ void AwMetricsServiceClientImpl::Initialize( |
pref_service_ = pref_service; |
request_context_ = request_context; |
+ // The channel will always be "unknown" when using stand-alone WebView, since |
+ // stand-alone WebView has the same package name across channels. |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ std::string package_name = base::android::ConvertJavaStringToUTF8( |
+ env, Java_AwMetricsServiceClient_getWebViewPackageName(env)); |
+ channel_ = version_info::ChannelFromPackageName(package_name.c_str()); |
Alexei Svitkine (slow)
2017/05/12 14:26:22
Nit: This seems like a good candidate for a helper
paulmiller
2017/05/12 19:45:35
Done.
|
+ |
std::string* guid = new std::string; |
// Initialization happens on the UI thread, but getting the GUID should happen |
// on the file I/O thread. So we start to initialize, then post to get the |
@@ -187,9 +198,7 @@ bool AwMetricsServiceClientImpl::GetBrand(std::string* brand_code) { |
} |
metrics::SystemProfileProto::Channel AwMetricsServiceClientImpl::GetChannel() { |
- // "Channel" means stable, beta, etc. WebView doesn't have channel info yet. |
- // TODO(paulmiller) Update this once we have channel info. |
- return metrics::SystemProfileProto::CHANNEL_UNKNOWN; |
+ return metrics::AsProtobufChannel(channel_); |
} |
std::string AwMetricsServiceClientImpl::GetVersionString() { |
@@ -225,7 +234,10 @@ base::TimeDelta AwMetricsServiceClientImpl::GetStandardUploadInterval() { |
} |
AwMetricsServiceClientImpl::AwMetricsServiceClientImpl() |
- : is_enabled_(false), pref_service_(nullptr), request_context_(nullptr) {} |
+ : is_enabled_(false), |
+ pref_service_(nullptr), |
+ request_context_(nullptr), |
+ channel_(version_info::Channel::UNKNOWN) {} |
AwMetricsServiceClientImpl::~AwMetricsServiceClientImpl() {} |