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/signin/account_tracker_service_android.h" | 5 #include "chrome/browser/android/signin/account_tracker_service_android.h" |
6 | 6 |
7 #include "base/android/jni_array.h" | 7 #include "base/android/jni_array.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/signin/account_fetcher_service_factory.h" | |
9 #include "chrome/browser/signin/account_tracker_service_factory.h" | 10 #include "chrome/browser/signin/account_tracker_service_factory.h" |
10 #include "components/signin/core/browser/account_info.h" | 11 #include "components/signin/core/browser/account_fetcher_service.h" |
12 #include "components/signin/core/browser/account_tracker_service.h" | |
11 #include "jni/AccountTrackerService_jni.h" | 13 #include "jni/AccountTrackerService_jni.h" |
12 | 14 |
13 AccountTrackerServiceAndroid::AccountTrackerServiceAndroid(JNIEnv* env, | 15 namespace signin { |
14 jobject obj) { | 16 namespace android { |
15 java_account_tracker_service_.Reset(env, obj); | |
16 } | |
17 | 17 |
18 void AccountTrackerServiceAndroid::SeedAccountsInfo(JNIEnv* env, | 18 void SeedAccountsInfo(JNIEnv* env, |
19 jobject obj, | 19 const JavaParamRef<jclass>& jcaller, |
20 jobjectArray gaiaIds, | 20 const JavaParamRef<jobjectArray>& gaiaIds, |
21 jobjectArray accountNames) { | 21 const JavaParamRef<jobjectArray>& accountNames) { |
22 std::vector<std::string> gaia_ids; | 22 std::vector<std::string> gaia_ids; |
23 std::vector<std::string> account_names; | 23 std::vector<std::string> account_names; |
24 base::android::AppendJavaStringArrayToStringVector(env, gaiaIds, &gaia_ids); | 24 base::android::AppendJavaStringArrayToStringVector(env, gaiaIds, &gaia_ids); |
25 base::android::AppendJavaStringArrayToStringVector(env, accountNames, | 25 base::android::AppendJavaStringArrayToStringVector(env, accountNames, |
26 &account_names); | 26 &account_names); |
27 DCHECK_EQ(gaia_ids.size(), account_names.size()); | 27 DCHECK_EQ(gaia_ids.size(), account_names.size()); |
28 | 28 |
29 DVLOG(1) << "AccountTrackerServiceAndroid::SeedAccountsInfo: " | 29 DVLOG(1) << "AccountTrackerServiceAndroid::SeedAccountsInfo: " |
30 << " number of accounts " << gaia_ids.size(); | 30 << " number of accounts " << gaia_ids.size(); |
31 Profile* profile = ProfileManager::GetActiveUserProfile(); | 31 Profile* profile = ProfileManager::GetActiveUserProfile(); |
32 AccountTrackerService* account_tracker_service_ = | 32 AccountTrackerService* account_tracker_service_ = |
33 AccountTrackerServiceFactory::GetForProfile(profile); | 33 AccountTrackerServiceFactory::GetForProfile(profile); |
34 | 34 |
35 for (unsigned int i = 0; i < gaia_ids.size(); i++) { | 35 for (size_t i = 0; i < gaia_ids.size(); i++) { |
36 account_tracker_service_->SeedAccountInfo(gaia_ids[i], account_names[i]); | 36 account_tracker_service_->SeedAccountInfo(gaia_ids[i], account_names[i]); |
37 } | 37 } |
38 AccountFetcherServiceFactory::GetForProfile(profile)->OnAccountsSeeded(); | |
anthonyvd
2015/10/05 16:05:50
The idea behind splitting the AFS into the tracker
knn
2015/10/05 16:35:55
That ordering is still maintained (ATS does not kn
anthonyvd
2015/10/05 20:45:21
My bad, I thought the AccountTrackerServiceAndroid
| |
38 } | 39 } |
39 | 40 |
40 static jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 41 jboolean AreAllAccountsSeeded(JNIEnv* env, |
41 AccountTrackerServiceAndroid* account_tracker_service_android = | 42 const JavaParamRef<jclass>& jcaller) { |
42 new AccountTrackerServiceAndroid(env, obj); | 43 Profile* profile = ProfileManager::GetActiveUserProfile(); |
43 return reinterpret_cast<intptr_t>(account_tracker_service_android); | 44 return AccountFetcherServiceFactory::GetForProfile(profile) |
45 ->AreAllAccountsSeeded(); | |
44 } | 46 } |
45 | 47 |
46 // static | 48 bool RegisterAccountTrackerService(JNIEnv* env) { |
47 bool AccountTrackerServiceAndroid::Register(JNIEnv* env) { | |
48 return RegisterNativesImpl(env); | 49 return RegisterNativesImpl(env); |
49 } | 50 } |
51 | |
52 } // namespace android | |
53 } // namespace signin | |
OLD | NEW |