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

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, 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 2016 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/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 bool UpdatePasswordInfoBar::Register(JNIEnv* env) {
16 return RegisterNativesImpl(env);
17 }
18
19 UpdatePasswordInfoBar::UpdatePasswordInfoBar(
20 scoped_ptr<UpdatePasswordInfoBarDelegate> delegate)
21 : ConfirmInfoBar(std::move(delegate)) {}
22
23 UpdatePasswordInfoBar::~UpdatePasswordInfoBar() {}
24
25 int UpdatePasswordInfoBar::GetIdOfSelectedUsername() {
26 return Java_UpdatePasswordInfoBar_getSelectedUsername(
27 base::android::AttachCurrentThread(), java_infobar_.obj());
28 }
29
30 base::android::ScopedJavaLocalRef<jobject>
31 UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) {
32 using base::android::ConvertUTF16ToJavaString;
33 using base::android::ScopedJavaLocalRef;
34 UpdatePasswordInfoBarDelegate* update_password_delegate =
35 static_cast<UpdatePasswordInfoBarDelegate*>(delegate());
36 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString(
37 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
38 ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString(
39 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
40 ScopedJavaLocalRef<jstring> branding_text =
41 ConvertUTF16ToJavaString(env, update_password_delegate->branding());
42
43 std::vector<base::string16> usernames;
44 if (update_password_delegate->ShowMultipleAccounts()) {
45 for (auto password_form : update_password_delegate->GetCurrentForms())
46 usernames.push_back(password_form->username_value);
47 } else {
48 usernames.push_back(
49 update_password_delegate->GetUsernameForOneAccountCase());
50 }
51
52 base::android::ScopedJavaLocalRef<jobject> infobar;
53 infobar.Reset(Java_UpdatePasswordInfoBar_show(
54 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
55 base::android::ToJavaArrayOfStrings(env, usernames).obj(),
56 ok_button_text.obj(), cancel_button_text.obj(), branding_text.obj(),
57 update_password_delegate->ShowMultipleAccounts(),
58 update_password_delegate->is_smartlock_branding_enabled()));
59
60 java_infobar_.Reset(env, infobar.obj());
61 return infobar;
62 }
63
64 void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env,
65 const JavaParamRef<jobject>& obj) {
66 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698