OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/profiles/profile_downloader_android.h" | 5 #include "chrome/browser/android/profiles/profile_downloader_android.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/profiles/profile_android.h" | 10 #include "chrome/browser/profiles/profile_android.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // static | 109 // static |
110 jstring GetCachedNameForPrimaryAccount(JNIEnv* env, | 110 jstring GetCachedNameForPrimaryAccount(JNIEnv* env, |
111 jclass clazz, | 111 jclass clazz, |
112 jobject jprofile) { | 112 jobject jprofile) { |
113 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); | 113 Profile* profile = ProfileAndroid::FromProfileAndroid(jprofile); |
114 ProfileInfoInterface& info = | 114 ProfileInfoInterface& info = |
115 g_browser_process->profile_manager()->GetProfileInfoCache(); | 115 g_browser_process->profile_manager()->GetProfileInfoCache(); |
116 const size_t index = info.GetIndexOfProfileWithPath(profile->GetPath()); | 116 const size_t index = info.GetIndexOfProfileWithPath(profile->GetPath()); |
117 | 117 |
118 base::string16 name; | 118 base::string16 name; |
119 if (index != std::string::npos) { | 119 |
| 120 if (index != std::string::npos && |
| 121 !info.ProfileIsUsingDefaultNameAtIndex(index)) { |
120 name = info.GetGAIANameOfProfileAtIndex(index); | 122 name = info.GetGAIANameOfProfileAtIndex(index); |
121 if (name.empty()) | 123 if (name.empty()) |
122 name = info.GetNameOfProfileAtIndex(index); | 124 name = info.GetNameOfProfileAtIndex(index); |
123 } | 125 } |
124 | 126 |
125 return base::android::ConvertUTF16ToJavaString(env, name).Release(); | 127 return base::android::ConvertUTF16ToJavaString(env, name).Release(); |
126 } | 128 } |
127 | 129 |
128 // static | 130 // static |
129 jobject GetCachedAvatarForPrimaryAccount(JNIEnv* env, | 131 jobject GetCachedAvatarForPrimaryAccount(JNIEnv* env, |
(...skipping 30 matching lines...) Expand all Loading... |
160 base::android::ConvertJavaStringToUTF8(env, jaccount_id); | 162 base::android::ConvertJavaStringToUTF8(env, jaccount_id); |
161 AccountInfoRetriever* retriever = | 163 AccountInfoRetriever* retriever = |
162 new AccountInfoRetriever(profile, account_id, image_side_pixels); | 164 new AccountInfoRetriever(profile, account_id, image_side_pixels); |
163 retriever->Start(); | 165 retriever->Start(); |
164 } | 166 } |
165 | 167 |
166 // static | 168 // static |
167 bool ProfileDownloaderAndroid::Register(JNIEnv* env) { | 169 bool ProfileDownloaderAndroid::Register(JNIEnv* env) { |
168 return RegisterNativesImpl(env); | 170 return RegisterNativesImpl(env); |
169 } | 171 } |
OLD | NEW |