| 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/password_manager/account_chooser_dialog_android.h" | 5 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 void AddElementsToJavaCredentialArray( | 37 void AddElementsToJavaCredentialArray( |
| 38 JNIEnv* env, | 38 JNIEnv* env, |
| 39 ScopedJavaLocalRef<jobjectArray> java_credentials_array, | 39 ScopedJavaLocalRef<jobjectArray> java_credentials_array, |
| 40 const std::vector<const autofill::PasswordForm*>& password_forms, | 40 const std::vector<const autofill::PasswordForm*>& password_forms, |
| 41 password_manager::CredentialType type, | 41 password_manager::CredentialType type, |
| 42 int indexStart = 0) { | 42 int indexStart = 0) { |
| 43 int index = indexStart; | 43 int index = indexStart; |
| 44 for (auto password_form : password_forms) { | 44 for (auto* password_form : password_forms) { |
| 45 ScopedJavaLocalRef<jobject> java_credential = CreateNativeCredential( | 45 ScopedJavaLocalRef<jobject> java_credential = CreateNativeCredential( |
| 46 env, *password_form, index - indexStart, static_cast<int>(type)); | 46 env, *password_form, index - indexStart, static_cast<int>(type)); |
| 47 env->SetObjectArrayElement(java_credentials_array.obj(), index, | 47 env->SetObjectArrayElement(java_credentials_array.obj(), index, |
| 48 java_credential.obj()); | 48 java_credential.obj()); |
| 49 index++; | 49 index++; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 class AvatarFetcherAndroid : public AccountAvatarFetcher { | 53 class AvatarFetcherAndroid : public AccountAvatarFetcher { |
| 54 public: | 54 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 AttachCurrentThread(), java_dialog_.obj(), index_, java_bitmap.obj()); | 86 AttachCurrentThread(), java_dialog_.obj(), index_, java_bitmap.obj()); |
| 87 } | 87 } |
| 88 delete this; | 88 delete this; |
| 89 } | 89 } |
| 90 | 90 |
| 91 void FetchAvatars( | 91 void FetchAvatars( |
| 92 const base::android::ScopedJavaGlobalRef<jobject>& java_dialog, | 92 const base::android::ScopedJavaGlobalRef<jobject>& java_dialog, |
| 93 const std::vector<const autofill::PasswordForm*>& password_forms, | 93 const std::vector<const autofill::PasswordForm*>& password_forms, |
| 94 int index, | 94 int index, |
| 95 net::URLRequestContextGetter* request_context) { | 95 net::URLRequestContextGetter* request_context) { |
| 96 for (auto password_form : password_forms) { | 96 for (auto* password_form : password_forms) { |
| 97 if (!password_form->icon_url.is_valid()) | 97 if (!password_form->icon_url.is_valid()) |
| 98 continue; | 98 continue; |
| 99 // Fetcher deletes itself once fetching is finished. | 99 // Fetcher deletes itself once fetching is finished. |
| 100 auto fetcher = | 100 auto* fetcher = |
| 101 new AvatarFetcherAndroid(password_form->icon_url, index, java_dialog); | 101 new AvatarFetcherAndroid(password_form->icon_url, index, java_dialog); |
| 102 fetcher->Start(request_context); | 102 fetcher->Start(request_context); |
| 103 ++index; | 103 ++index; |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 }; // namespace | 107 }; // namespace |
| 108 | 108 |
| 109 AccountChooserDialogAndroid::AccountChooserDialogAndroid( | 109 AccountChooserDialogAndroid::AccountChooserDialogAndroid( |
| 110 content::WebContents* web_contents, | 110 content::WebContents* web_contents, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 action); | 256 action); |
| 257 } else { | 257 } else { |
| 258 password_manager::metrics_util::LogAccountChooserUserActionManyAccounts( | 258 password_manager::metrics_util::LogAccountChooserUserActionManyAccounts( |
| 259 action); | 259 action); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 bool RegisterAccountChooserDialogAndroid(JNIEnv* env) { | 263 bool RegisterAccountChooserDialogAndroid(JNIEnv* env) { |
| 264 return RegisterNativesImpl(env); | 264 return RegisterNativesImpl(env); |
| 265 } | 265 } |
| OLD | NEW |