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

Side by Side Diff: chrome/browser/android/firstrun/variations/variations_seed_bridge.cc

Issue 1417733008: Java code for fetching variations first run seed after receiving chrome.TOS_ACKED broadcast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/firstrun/variations/variations_seed_bridge.h"
6
7 #include <jni.h>
8 #include <vector>
9
10 #include "base/android/build_info.h"
11 #include "base/android/jni_android.h"
12 #include "base/android/jni_array.h"
13 #include "base/android/jni_string.h"
14 #include "base/android/jni_weak_ref.h"
15 #include "jni/VariationsSeedBridge_jni.h"
16
17 using base::android::AttachCurrentThread;
18 using base::android::CheckException;
Alexei Svitkine (slow) 2015/11/05 16:38:26 I don't see this being used. Please update the lis
Alexander Agulenko 2015/11/06 08:09:01 Done.
19 using base::android::ConvertJavaStringToUTF8;
20 using base::android::ConvertUTF8ToJavaString;
21 using base::android::GetApplicationContext;
22 using base::android::ScopedJavaLocalRef;
23
24 namespace {
25
26 std::string JavaByteArrayToString(JNIEnv* env, jbyteArray byte_array) {
27 if (!byte_array)
28 return std::string();
29 std::vector<uint8> array_data;
30 base::android::JavaByteArrayToByteVector(env, byte_array, &array_data);
31 return std::string(array_data.begin(), array_data.end());
32 }
33
34 } // namespace
35
36 // static
37 bool VariationsSeedBridge::RegisterVariationsSeedBridge(JNIEnv* env) {
38 return RegisterNativesImpl(env);
39 }
40
41 // static
42 void VariationsSeedBridge::GetVariationsFirstRunSeed(
43 std::string* seed_data,
44 std::string* seed_signature,
45 std::string* seed_country) {
46 JNIEnv* env = AttachCurrentThread();
47 ScopedJavaLocalRef<jbyteArray> j_seed_data =
48 Java_VariationsSeedBridge_getVariationsFirstRunSeedData(
49 env, GetApplicationContext());
50 ScopedJavaLocalRef<jstring> j_seed_signature =
51 Java_VariationsSeedBridge_getVariationsFirstRunSeedSignature(
52 env, GetApplicationContext());
53 ScopedJavaLocalRef<jstring> j_seed_country =
54 Java_VariationsSeedBridge_getVariationsFirstRunSeedCountry(
55 env, GetApplicationContext());
56 *seed_data = JavaByteArrayToString(env, j_seed_data.obj());
57 *seed_signature = ConvertJavaStringToUTF8(j_seed_signature);
58 *seed_country = ConvertJavaStringToUTF8(j_seed_country);
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698