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

Side by Side Diff: chrome/browser/ui/android/infobars/account_chooser_infobar.cc

Issue 861103002: Credentials chooser UI for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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
OLDNEW
(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/ui/android/infobars/account_chooser_infobar.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro id.h"
11 #include "components/password_manager/content/common/credential_manager_types.h"
12 #include "jni/AccountChooserInfoBar_jni.h"
13
14 namespace {
15
16 void NotifyDelegateAboutChoosenCredential(
Peter Kasting 2015/02/18 21:44:17 Nit: "Choosen" isn't a word. Why not just call th
melandory 2015/02/19 13:38:01 I'll remove this function, because with GetDelegat
17 infobars::InfoBarDelegate* delegate,
18 int credential_item,
19 password_manager::CredentialType credential_type) {
20 AccountChooserInfoBarDelegateAndroid* infobar_delegate =
21 static_cast<AccountChooserInfoBarDelegateAndroid*>(delegate);
Peter Kasting 2015/02/18 21:44:17 Nit: You do this twice in this file. If you defin
melandory 2015/02/19 13:38:01 Done.
22 infobar_delegate->ChooseCredential(credential_item, credential_type);
23 }
24
25 } // namespace
26
27 AccountChooserInfoBar::AccountChooserInfoBar(
28 scoped_ptr<AccountChooserInfoBarDelegateAndroid> delegate)
29 : InfoBarAndroid(delegate.Pass()) {
30 }
31
32 base::android::ScopedJavaLocalRef<jobject>
33 AccountChooserInfoBar::CreateRenderInfoBar(JNIEnv* env) {
34 AccountChooserInfoBarDelegateAndroid* infobar_delegate =
35 static_cast<AccountChooserInfoBarDelegateAndroid*>(delegate());
36 std::vector<base::string16> usernames;
37 // TODO(melandory): Federated credentials should be processed also.
38 for (auto password_form : infobar_delegate->local_credentials_forms())
39 usernames.push_back(password_form->username_value);
40 base::android::ScopedJavaLocalRef<jobjectArray> java_usernames =
41 base::android::ToJavaArrayOfStrings(env, usernames);
42 return Java_AccountChooserInfoBar_show(env, reinterpret_cast<intptr_t>(this),
43 GetEnumeratedIconId(),
44 java_usernames.obj());
45 }
46
47 void AccountChooserInfoBar::OnCredentialClicked(JNIEnv* env,
48 jobject obj,
49 jint credential_item,
50 jint credential_type) {
51 NotifyDelegateAboutChoosenCredential(
52 delegate(), credential_item,
53 static_cast<password_manager::CredentialType>(credential_type));
54 RemoveSelf();
55 }
56
57 void AccountChooserInfoBar::ProcessButton(int action,
58 const std::string& action_value) {
59 // We're closing; don't call anything, it might access
60 // the owner.
Peter Kasting 2015/02/18 21:44:17 Nit: This comment can all fit on one line, and sho
melandory 2015/02/19 13:38:01 Done.
61 if (!owner())
62 return;
63 NotifyDelegateAboutChoosenCredential(
64 delegate(), -1, password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY);
65 RemoveSelf();
66 }
67
68 bool RegisterAccountChooserInfoBar(JNIEnv* env) {
69 return RegisterNativesImpl(env);
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698