| 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 std::string latest_country = variations_service->GetLatestCountry(); |
| 51 if (latest_country.empty()) |
| 52 return nullptr; |
| 53 |
| 54 return base::android::ConvertUTF8ToJavaString(env, latest_country); |
| 55 } |
| 56 |
| 42 namespace chrome { | 57 namespace chrome { |
| 43 namespace android { | 58 namespace android { |
| 44 | 59 |
| 45 // Register native methods | 60 // Register native methods |
| 46 bool RegisterVariationsSession(JNIEnv* env) { return RegisterNativesImpl(env); } | 61 bool RegisterVariationsSession(JNIEnv* env) { return RegisterNativesImpl(env); } |
| 47 | 62 |
| 48 } // namespace android | 63 } // namespace android |
| 49 } // namespace chrome | 64 } // namespace chrome |
| OLD | NEW |