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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/android/infobars/update_password_infobar.cc
diff --git a/chrome/browser/ui/android/infobars/update_password_infobar.cc b/chrome/browser/ui/android/infobars/update_password_infobar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..037d7559770a5822abb6a74b29ac401b0d7f378e
--- /dev/null
+++ b/chrome/browser/ui/android/infobars/update_password_infobar.cc
@@ -0,0 +1,74 @@
+// 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.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/android/infobars/update_password_infobar.h"
+
+#include <vector>
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_array.h"
+#include "base/android/jni_string.h"
+#include "components/password_manager/core/common/credential_manager_types.h"
+#include "jni/UpdatePasswordInfoBar_jni.h"
+
+UpdatePasswordInfoBar::UpdatePasswordInfoBar(
+ scoped_ptr<UpdatePasswordInfoBarDelegate> delegate)
+ : ConfirmInfoBar(std::move(delegate)) {}
+
+UpdatePasswordInfoBar::~UpdatePasswordInfoBar() {}
+
+base::android::ScopedJavaLocalRef<jobject>
+UpdatePasswordInfoBar::CreateRenderInfoBar(JNIEnv* env) {
+ using base::android::ConvertUTF16ToJavaString;
+ using base::android::ScopedJavaLocalRef;
+ UpdatePasswordInfoBarDelegate* update_password_delegate =
+ static_cast<UpdatePasswordInfoBarDelegate*>(delegate());
+ ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString(
+ env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK));
+ ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString(
+ env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL));
+ ScopedJavaLocalRef<jstring> branding_text =
+ ConvertUTF16ToJavaString(env, update_password_delegate->branding());
+
+ std::vector<base::string16> usernames;
+ if (update_password_delegate->ShowMultipleAccounts()) {
+ for (auto password_form : update_password_delegate->GetCurrentForms()) {
+ usernames.push_back(password_form->username_value);
+ }
+ } else {
+ usernames.push_back(
+ update_password_delegate->GetUsernameForOneAccountCase());
+ }
+
+ base::android::ScopedJavaLocalRef<jobjectArray> java_usernames =
+ base::android::ToJavaArrayOfStrings(env, usernames);
+ return Java_UpdatePasswordInfoBar_show(
+ env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
+ java_usernames.obj(), ok_button_text.obj(), cancel_button_text.obj(),
+ branding_text.obj(), update_password_delegate->ShowMultipleAccounts(),
+ update_password_delegate->is_smartlock_branding_enabled());
+}
+
+void UpdatePasswordInfoBar::OnLinkClicked(JNIEnv* env,
+ const JavaParamRef<jobject>& obj) {
+ GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB);
+}
+
+void UpdatePasswordInfoBar::OnUpdateClicked(
+ JNIEnv* env, jobject obj, jint form_id) {
+ UpdatePasswordInfoBarDelegate* update_password_delegate =
+ static_cast<UpdatePasswordInfoBarDelegate*>(delegate());
+ update_password_delegate->UpdatePasswordInternal(form_id);
+ RemoveSelf();
+}
+
+bool UpdatePasswordInfoBar::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+
+scoped_ptr<infobars::InfoBar> CreateUpdatePasswordInfoBar(
+ scoped_ptr<UpdatePasswordInfoBarDelegate> delegate) {
+ return make_scoped_ptr(new UpdatePasswordInfoBar(std::move(delegate)));
+}

Powered by Google App Engine
This is Rietveld 408576698