| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/payments/content/android/journey_logger_android.h" | 5 #include "chrome/browser/payments/android/journey_logger_android.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 "jni/JourneyLogger_jni.h" | 9 #include "jni/JourneyLogger_jni.h" |
| 10 #include "url/gurl.h" |
| 9 | 11 |
| 10 namespace payments { | 12 namespace payments { |
| 11 namespace { | 13 namespace { |
| 12 | 14 |
| 13 using ::base::android::JavaParamRef; | 15 using ::base::android::JavaParamRef; |
| 14 using ::base::android::ConvertJavaStringToUTF8; | 16 using ::base::android::ConvertJavaStringToUTF8; |
| 15 | 17 |
| 16 } // namespace | 18 } // namespace |
| 17 | 19 |
| 18 // static | 20 // static |
| 19 bool JourneyLoggerAndroid::Register(JNIEnv* env) { | 21 bool JourneyLoggerAndroid::Register(JNIEnv* env) { |
| 20 return RegisterNativesImpl(env); | 22 return RegisterNativesImpl(env); |
| 21 } | 23 } |
| 22 | 24 |
| 23 JourneyLoggerAndroid::JourneyLoggerAndroid(bool is_incognito) | 25 JourneyLoggerAndroid::JourneyLoggerAndroid(bool is_incognito, |
| 24 : journey_logger_(is_incognito) {} | 26 const std::string& url) |
| 27 : journey_logger_(is_incognito, |
| 28 GURL(url), |
| 29 g_browser_process->ukm_service()) {} |
| 25 | 30 |
| 26 JourneyLoggerAndroid::~JourneyLoggerAndroid() {} | 31 JourneyLoggerAndroid::~JourneyLoggerAndroid() {} |
| 27 | 32 |
| 28 void JourneyLoggerAndroid::Destroy(JNIEnv* env, | 33 void JourneyLoggerAndroid::Destroy(JNIEnv* env, |
| 29 const JavaParamRef<jobject>& jcaller) { | 34 const JavaParamRef<jobject>& jcaller) { |
| 30 delete this; | 35 delete this; |
| 31 } | 36 } |
| 32 | 37 |
| 33 void JourneyLoggerAndroid::SetNumberOfSuggestionsShown( | 38 void JourneyLoggerAndroid::SetNumberOfSuggestionsShown( |
| 34 JNIEnv* env, | 39 JNIEnv* env, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 jboolean jvalue) { | 82 jboolean jvalue) { |
| 78 journey_logger_.SetCanMakePaymentValue(jvalue); | 83 journey_logger_.SetCanMakePaymentValue(jvalue); |
| 79 } | 84 } |
| 80 | 85 |
| 81 void JourneyLoggerAndroid::SetShowCalled( | 86 void JourneyLoggerAndroid::SetShowCalled( |
| 82 JNIEnv* env, | 87 JNIEnv* env, |
| 83 const base::android::JavaParamRef<jobject>& jcaller) { | 88 const base::android::JavaParamRef<jobject>& jcaller) { |
| 84 journey_logger_.SetShowCalled(); | 89 journey_logger_.SetShowCalled(); |
| 85 } | 90 } |
| 86 | 91 |
| 92 void JourneyLoggerAndroid::SetEventOccurred( |
| 93 JNIEnv* env, |
| 94 const base::android::JavaParamRef<jobject>& jcaller, |
| 95 jint jevent) { |
| 96 DCHECK_GE(jevent, 0); |
| 97 DCHECK_LT(jevent, JourneyLogger::Event::EVENT_MAX); |
| 98 journey_logger_.SetEventOccurred(static_cast<JourneyLogger::Event>(jevent)); |
| 99 } |
| 100 |
| 87 void JourneyLoggerAndroid::RecordJourneyStatsHistograms( | 101 void JourneyLoggerAndroid::RecordJourneyStatsHistograms( |
| 88 JNIEnv* env, | 102 JNIEnv* env, |
| 89 const base::android::JavaParamRef<jobject>& jcaller, | 103 const base::android::JavaParamRef<jobject>& jcaller, |
| 90 jint jcompletion_status) { | 104 jint jcompletion_status) { |
| 91 DCHECK_GE(jcompletion_status, 0); | 105 DCHECK_GE(jcompletion_status, 0); |
| 92 DCHECK_LT(jcompletion_status, | 106 DCHECK_LT(jcompletion_status, |
| 93 JourneyLogger::CompletionStatus::COMPLETION_STATUS_MAX); | 107 JourneyLogger::CompletionStatus::COMPLETION_STATUS_MAX); |
| 94 journey_logger_.RecordJourneyStatsHistograms( | 108 journey_logger_.RecordJourneyStatsHistograms( |
| 95 static_cast<JourneyLogger::CompletionStatus>(jcompletion_status)); | 109 static_cast<JourneyLogger::CompletionStatus>(jcompletion_status)); |
| 96 } | 110 } |
| 97 | 111 |
| 98 static jlong InitJourneyLoggerAndroid(JNIEnv* env, | 112 static jlong InitJourneyLoggerAndroid( |
| 99 const JavaParamRef<jobject>& jcaller, | 113 JNIEnv* env, |
| 100 jboolean jis_incognito) { | 114 const JavaParamRef<jobject>& jcaller, |
| 101 return reinterpret_cast<jlong>(new JourneyLoggerAndroid(jis_incognito)); | 115 jboolean jis_incognito, |
| 116 const base::android::JavaParamRef<jstring>& jurl) { |
| 117 return reinterpret_cast<jlong>(new JourneyLoggerAndroid( |
| 118 jis_incognito, ConvertJavaStringToUTF8(env, jurl))); |
| 102 } | 119 } |
| 103 | 120 |
| 104 } // namespace payments | 121 } // namespace payments |
| OLD | NEW |