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

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 "chrome/browser/password_manager/update_password_infobar_delegate.h"
13 #include "components/password_manager/core/common/credential_manager_types.h"
14 #include "jni/UpdatePasswordInfoBar_jni.h"
15
16 UpdatePasswordInfoBar::UpdatePasswordInfoBar(
17 scoped_ptr<UpdatePasswordInfoBarDelegate> delegate)
18 : ConfirmInfoBar(std::move(delegate)) {}
19
20 UpdatePasswordInfoBar::~UpdatePasswordInfoBar() {}
21
22 bool UpdatePasswordInfoBar::Register(JNIEnv* env) {
23 return RegisterNativesImpl(env);
24 }
25
26 int UpdatePasswordInfoBar::GetIdOfSelectedUsername() const {
27 return Java_UpdatePasswordInfoBar_getSelectedUsername(
28 base::android::AttachCurrentThread(), java_infobar_.obj());
29 }
30
31 base::android::ScopedJavaLocalRef<jobject>
32 UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) {
33 using base::android::ConvertUTF16ToJavaString;
34 using base::android::ScopedJavaLocalRef;
35 UpdatePasswordInfoBarDelegate* update_password_delegate =
36 static_cast<UpdatePasswordInfoBarDelegate*>(delegate());
37 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString(
38 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
39 ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString(
40 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
41 ScopedJavaLocalRef<jstring> branding_text =
42 ConvertUTF16ToJavaString(env, update_password_delegate->GetBranding());
43
44 std::vector<base::string16> usernames;
45 if (update_password_delegate->ShowMultipleAccounts()) {
46 for (auto password_form : update_password_delegate->GetCurrentForms())
47 usernames.push_back(password_form->username_value);
48 } else {
49 usernames.push_back(
50 update_password_delegate->get_username_for_single_account());
51 }
52
53 base::android::ScopedJavaLocalRef<jobject> infobar;
54 infobar.Reset(Java_UpdatePasswordInfoBar_show(
55 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
56 base::android::ToJavaArrayOfStrings(env, usernames).obj(),
57 ok_button_text.obj(), cancel_button_text.obj(), branding_text.obj(),
58 update_password_delegate->ShowMultipleAccounts(),
59 update_password_delegate->is_smartlock_branding_enabled()));
60
61 java_infobar_.Reset(env, infobar.obj());
62 return infobar;
63 }
64
65 void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env,
66 const JavaParamRef<jobject>& obj) {
67 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB);
68 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/update_password_infobar.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698