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

Side by Side Diff: chrome/browser/translate/android/translate_utils.cc

Issue 2873103003: Implements logging in the new compact translate UI. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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 "chrome/browser/translate/android/translate_utils.h" 5 #include "chrome/browser/translate/android/translate_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/jni_array.h" 9 #include "base/android/jni_array.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/android/jni_weak_ref.h" 11 #include "base/android/jni_weak_ref.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "components/metrics/metrics_log.h"
13 #include "components/translate/core/browser/translate_infobar_delegate.h" 14 #include "components/translate/core/browser/translate_infobar_delegate.h"
14 15
15 using base::android::JavaParamRef; 16 using base::android::JavaParamRef;
16 using base::android::ScopedJavaLocalRef; 17 using base::android::ScopedJavaLocalRef;
17 18
18 ScopedJavaLocalRef<jobjectArray> TranslateUtils::GetJavaLanguages( 19 ScopedJavaLocalRef<jobjectArray> TranslateUtils::GetJavaLanguages(
19 JNIEnv* env, 20 JNIEnv* env,
20 translate::TranslateInfoBarDelegate* delegate) { 21 translate::TranslateInfoBarDelegate* delegate) {
21 std::vector<base::string16> languages; 22 std::vector<base::string16> languages;
22 languages.reserve(delegate->num_languages()); 23 languages.reserve(delegate->num_languages());
23 for (size_t i = 0; i < delegate->num_languages(); ++i) { 24 for (size_t i = 0; i < delegate->num_languages(); ++i) {
24 languages.push_back(delegate->language_name_at(i)); 25 languages.push_back(delegate->language_name_at(i));
25 } 26 }
26 return base::android::ToJavaArrayOfStrings(env, languages); 27 return base::android::ToJavaArrayOfStrings(env, languages);
27 } 28 }
28 29
29 ScopedJavaLocalRef<jobjectArray> TranslateUtils::GetJavaLanguageCodes( 30 ScopedJavaLocalRef<jobjectArray> TranslateUtils::GetJavaLanguageCodes(
30 JNIEnv* env, 31 JNIEnv* env,
31 translate::TranslateInfoBarDelegate* delegate) { 32 translate::TranslateInfoBarDelegate* delegate) {
32 std::vector<std::string> codes; 33 std::vector<std::string> codes;
33 codes.reserve(delegate->num_languages()); 34 codes.reserve(delegate->num_languages());
34 for (size_t i = 0; i < delegate->num_languages(); ++i) { 35 for (size_t i = 0; i < delegate->num_languages(); ++i) {
35 codes.push_back(delegate->language_code_at(i)); 36 codes.push_back(delegate->language_code_at(i));
36 } 37 }
37 return base::android::ToJavaArrayOfStrings(env, codes); 38 return base::android::ToJavaArrayOfStrings(env, codes);
38 } 39 }
40
41 ScopedJavaLocalRef<jintArray> TranslateUtils::GetJavaLanguageHashCodes(
42 JNIEnv* env,
43 translate::TranslateInfoBarDelegate* delegate) {
44 std::vector<int> hashCodes;
45 hashCodes.reserve(delegate->num_languages());
46 for (size_t i = 0; i < delegate->num_languages(); ++i) {
47 hashCodes.push_back(
48 metrics::MetricsLog::Hash(delegate->language_code_at(i)));
49 }
50 return base::android::ToJavaIntArray(env, hashCodes);
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698