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

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

Issue 1490193003: [Password Manager] Update Confirmation UI for saved password change for Chrome on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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.
vabr (Chromium) 2016/01/13 09:44:46 2016
melandory 2016/01/13 15:11:37 Done.
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/update_password_infobar.h"
6
7 #include <vector>
8
9 #include "base/android/jni_android.h"
10 #include "base/android/jni_array.h"
11 #include "base/android/jni_string.h"
12 #include "components/password_manager/core/common/credential_manager_types.h"
13 #include "jni/UpdatePasswordInfoBar_jni.h"
14
15 UpdatePasswordInfoBar::UpdatePasswordInfoBar(
16 scoped_ptr<UpdatePasswordInfoBarDelegate> delegate)
17 : ConfirmInfoBar(std::move(delegate)) {}
18
19 UpdatePasswordInfoBar::~UpdatePasswordInfoBar() {}
20
21 base::android::ScopedJavaLocalRef<jobject>
22 UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) {
23 using base::android::ConvertUTF16ToJavaString;
24 using base::android::ScopedJavaLocalRef;
25 UpdatePasswordInfoBarDelegate* update_password_delegate =
26 static_cast<UpdatePasswordInfoBarDelegate*>(delegate());
27 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString(
28 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
29 ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString(
30 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
31 ScopedJavaLocalRef<jstring> branding_text =
32 ConvertUTF16ToJavaString(env, update_password_delegate->branding());
33
34 std::vector<base::string16> usernames;
35 if (update_password_delegate->ShowMultipleAccounts()) {
36 for (auto password_form : update_password_delegate->GetCurrentForms()) {
37 usernames.push_back(password_form->username_value);
38 }
39 } else {
40 usernames.push_back(
41 update_password_delegate->GetUsernameForOneAccountCase());
42 }
43
44 base::android::ScopedJavaLocalRef<jobjectArray> java_usernames =
45 base::android::ToJavaArrayOfStrings(env, usernames);
46 return Java_UpdatePasswordInfoBar_show(
47 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
48 java_usernames.obj(), ok_button_text.obj(), cancel_button_text.obj(),
49 branding_text.obj(), update_password_delegate->ShowMultipleAccounts(),
50 update_password_delegate->is_smartlock_branding_enabled());
51 }
52
53 void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env,
54 const JavaParamRef<jobject>& obj) {
55 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB);
56 }
57
58 void UpdatePasswordInfoBar::OnUpdateClicked(
59 JNIEnv* env, jobject obj, jint form_id) {
60 UpdatePasswordInfoBarDelegate* update_password_delegate =
61 static_cast<UpdatePasswordInfoBarDelegate*>(delegate());
62 update_password_delegate->UpdatePasswordInternal(form_id);
63 RemoveSelf();
64 }
65
66 bool UpdatePasswordInfoBar::Register(JNIEnv* env) {
67 return RegisterNativesImpl(env);
68 }
69
70
71 scoped_ptr<infobars::InfoBar> CreateUpdatePasswordInfoBar(
72 scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) {
73 return make_scoped_ptr(new UpdatePasswordInfoBar(std::move(delegate)));
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698