| OLD | NEW |
| (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/signin/account_tracker_service_android.h" |
| 6 |
| 7 #include "base/android/jni_array.h" |
| 8 #include "chrome/browser/profiles/profile_manager.h" |
| 9 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 10 #include "components/signin/core/browser/account_info.h" |
| 11 #include "jni/AccountTrackerService_jni.h" |
| 12 |
| 13 AccountTrackerServiceAndroid::AccountTrackerServiceAndroid(JNIEnv* env, |
| 14 jobject obj) { |
| 15 java_account_tracker_service_.Reset(env, obj); |
| 16 } |
| 17 |
| 18 void AccountTrackerServiceAndroid::SeedAccountsInfo(JNIEnv* env, |
| 19 jobject obj, |
| 20 jobjectArray gaiaIds, |
| 21 jobjectArray accountNames) { |
| 22 std::vector<std::string> gaia_ids; |
| 23 std::vector<std::string> account_names; |
| 24 base::android::AppendJavaStringArrayToStringVector(env, gaiaIds, &gaia_ids); |
| 25 base::android::AppendJavaStringArrayToStringVector(env, accountNames, |
| 26 &account_names); |
| 27 DCHECK_EQ(gaia_ids.size(), account_names.size()); |
| 28 |
| 29 DVLOG(1) << "AccountTrackerServiceAndroid::SeedAccountsInfo: " |
| 30 << " number of accounts " << gaia_ids.size(); |
| 31 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 32 AccountTrackerService* account_tracker_service_ = |
| 33 AccountTrackerServiceFactory::GetForProfile(profile); |
| 34 |
| 35 for (unsigned int i = 0; i < gaia_ids.size(); i++) { |
| 36 account_tracker_service_->SeedAccountInfo(gaia_ids[i], account_names[i]); |
| 37 } |
| 38 } |
| 39 |
| 40 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
| 41 AccountTrackerServiceAndroid* account_tracker_service_android = |
| 42 new AccountTrackerServiceAndroid(env, obj); |
| 43 return reinterpret_cast<intptr_t>(account_tracker_service_android); |
| 44 } |
| 45 |
| 46 // static |
| 47 bool AccountTrackerServiceAndroid::Register(JNIEnv* env) { |
| 48 return RegisterNativesImpl(env); |
| 49 } |
| OLD | NEW |