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

Side by Side Diff: chrome/browser/password_manager/account_chooser_dialog_android.cc

Issue 2476633004: [Smart Lock] Account chooser assign correct avatar to profile. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 const SkBitmap* bitmap) { 83 const SkBitmap* bitmap) {
84 if (bitmap) { 84 if (bitmap) {
85 base::android::ScopedJavaLocalRef<jobject> java_bitmap = 85 base::android::ScopedJavaLocalRef<jobject> java_bitmap =
86 gfx::ConvertToJavaBitmap(bitmap); 86 gfx::ConvertToJavaBitmap(bitmap);
87 Java_AccountChooserDialog_imageFetchComplete( 87 Java_AccountChooserDialog_imageFetchComplete(
88 AttachCurrentThread(), java_dialog_, index_, java_bitmap); 88 AttachCurrentThread(), java_dialog_, index_, java_bitmap);
89 } 89 }
90 delete this; 90 delete this;
91 } 91 }
92 92
93 void FetchAvatars( 93 void FetchAvatar(const base::android::ScopedJavaGlobalRef<jobject>& java_dialog,
94 const base::android::ScopedJavaGlobalRef<jobject>& java_dialog, 94 const autofill::PasswordForm* password_form,
95 const std::vector<std::unique_ptr<autofill::PasswordForm>>& password_forms, 95 int index,
96 int index, 96 net::URLRequestContextGetter* request_context) {
97 net::URLRequestContextGetter* request_context) { 97 if (!password_form->icon_url.is_valid())
98 for (const auto& password_form : password_forms) { 98 return;
99 if (!password_form->icon_url.is_valid()) 99 // Fetcher deletes itself once fetching is finished.
100 continue; 100 auto* fetcher =
101 // Fetcher deletes itself once fetching is finished. 101 new AvatarFetcherAndroid(password_form->icon_url, index, java_dialog);
102 auto* fetcher = 102 fetcher->Start(request_context);
103 new AvatarFetcherAndroid(password_form->icon_url, index, java_dialog);
104 fetcher->Start(request_context);
105 ++index;
106 }
107 } 103 }
108 104
109 }; // namespace 105 }; // namespace
110 106
111 AccountChooserDialogAndroid::AccountChooserDialogAndroid( 107 AccountChooserDialogAndroid::AccountChooserDialogAndroid(
112 content::WebContents* web_contents, 108 content::WebContents* web_contents,
113 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, 109 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
114 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials, 110 std::vector<std::unique_ptr<autofill::PasswordForm>> federated_credentials,
115 const GURL& origin, 111 const GURL& origin,
116 const ManagePasswordsState::CredentialsCallback& callback) 112 const ManagePasswordsState::CredentialsCallback& callback)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 dialog_jobject_.Reset(Java_AccountChooserDialog_createAndShowAccountChooser( 155 dialog_jobject_.Reset(Java_AccountChooserDialog_createAndShowAccountChooser(
160 env, native_window->GetJavaObject(), reinterpret_cast<intptr_t>(this), 156 env, native_window->GetJavaObject(), reinterpret_cast<intptr_t>(this),
161 java_credentials_array, 157 java_credentials_array,
162 base::android::ConvertUTF16ToJavaString(env, title), 158 base::android::ConvertUTF16ToJavaString(env, title),
163 title_link_range.start(), title_link_range.end(), 159 title_link_range.start(), title_link_range.end(),
164 base::android::ConvertUTF8ToJavaString(env, origin), 160 base::android::ConvertUTF8ToJavaString(env, origin),
165 base::android::ConvertUTF16ToJavaString(env, signin_button))); 161 base::android::ConvertUTF16ToJavaString(env, signin_button)));
166 net::URLRequestContextGetter* request_context = 162 net::URLRequestContextGetter* request_context =
167 Profile::FromBrowserContext(web_contents_->GetBrowserContext()) 163 Profile::FromBrowserContext(web_contents_->GetBrowserContext())
168 ->GetRequestContext(); 164 ->GetRequestContext();
169 FetchAvatars(dialog_jobject_, local_credentials_forms(), 0, request_context); 165 int avatar_index = 0;
170 FetchAvatars(dialog_jobject_, federation_providers_forms(), 166 for (const auto& form : local_credentials_forms())
171 local_credentials_forms().size(), request_context); 167 FetchAvatar(dialog_jobject_, form.get(), avatar_index++, request_context);
168 for (const auto& form : federation_providers_forms())
169 FetchAvatar(dialog_jobject_, form.get(), avatar_index++, request_context);
172 } 170 }
173 171
174 void AccountChooserDialogAndroid::OnCredentialClicked( 172 void AccountChooserDialogAndroid::OnCredentialClicked(
175 JNIEnv* env, 173 JNIEnv* env,
176 const JavaParamRef<jobject>& obj, 174 const JavaParamRef<jobject>& obj,
177 jint credential_item, 175 jint credential_item,
178 jint credential_type, 176 jint credential_type,
179 jboolean signin_button_clicked) { 177 jboolean signin_button_clicked) {
180 ChooseCredential( 178 ChooseCredential(
181 credential_item, 179 credential_item,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 action); 256 action);
259 } else { 257 } else {
260 password_manager::metrics_util::LogAccountChooserUserActionManyAccounts( 258 password_manager::metrics_util::LogAccountChooserUserActionManyAccounts(
261 action); 259 action);
262 } 260 }
263 } 261 }
264 262
265 bool RegisterAccountChooserDialogAndroid(JNIEnv* env) { 263 bool RegisterAccountChooserDialogAndroid(JNIEnv* env) {
266 return RegisterNativesImpl(env); 264 return RegisterNativesImpl(env);
267 } 265 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698