OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/android/metrics/variations_session.h" | 5 #include "chrome/browser/android/metrics/variations_session.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "components/variations/service/variations_service.h" | 9 #include "components/variations/service/variations_service.h" |
10 #include "jni/VariationsSession_jni.h" | 10 #include "jni/VariationsSession_jni.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 if (variations_service) { | 32 if (variations_service) { |
33 std::string restrict_mode = | 33 std::string restrict_mode = |
34 base::android::ConvertJavaStringToUTF8(env, jrestrict_mode); | 34 base::android::ConvertJavaStringToUTF8(env, jrestrict_mode); |
35 if (!restrict_mode.empty() && !g_on_app_enter_foreground_called) | 35 if (!restrict_mode.empty() && !g_on_app_enter_foreground_called) |
36 variations_service->SetRestrictMode(restrict_mode); | 36 variations_service->SetRestrictMode(restrict_mode); |
37 variations_service->OnAppEnterForeground(); | 37 variations_service->OnAppEnterForeground(); |
38 g_on_app_enter_foreground_called = true; | 38 g_on_app_enter_foreground_called = true; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 static base::android::ScopedJavaLocalRef<jstring> GetLatestCountry( | |
43 JNIEnv* env, | |
44 const JavaParamRef<jobject>& obj) { | |
45 variations::VariationsService* variations_service = | |
46 g_browser_process->variations_service(); | |
47 if (!variations_service) | |
48 return nullptr; | |
49 | |
50 return base::android::ConvertUTF8ToJavaString( | |
51 env, variations_service->GetLatestCountry()); | |
Alexei Svitkine (slow)
2017/04/19 21:42:57
Can you add checking for empty string here and ret
Yusuf
2017/04/19 22:16:46
Done.
| |
52 } | |
53 | |
42 namespace chrome { | 54 namespace chrome { |
43 namespace android { | 55 namespace android { |
44 | 56 |
45 // Register native methods | 57 // Register native methods |
46 bool RegisterVariationsSession(JNIEnv* env) { return RegisterNativesImpl(env); } | 58 bool RegisterVariationsSession(JNIEnv* env) { return RegisterNativesImpl(env); } |
47 | 59 |
48 } // namespace android | 60 } // namespace android |
49 } // namespace chrome | 61 } // namespace chrome |
OLD | NEW |