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

Unified 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: Rebaised on top of master. Created 5 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/account_chooser_infobar.cc
diff --git a/chrome/browser/ui/android/infobars/account_chooser_infobar.cc b/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..350b0976db5f07901826329bec97ea92cb582ad4
--- /dev/null
+++ b/chrome/browser/ui/android/infobars/account_chooser_infobar.cc
@@ -0,0 +1,75 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// 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/account_chooser_infobar.h"
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_array.h"
+#include "base/android/jni_string.h"
+#include "chrome/browser/infobars/infobar_service.h"
+#include "chrome/browser/password_manager/account_chooser_infobar_delegate_android.h"
+#include "components/password_manager/content/common/credential_manager_types.h"
+#include "content/public/browser/web_contents.h"
+#include "jni/AccountChooserInfoBar_jni.h"
+
+// static
+void AccountChooserInfoBarDelegateAndroid::Create(
+ content::WebContents* web_contents,
+ ManagePasswordsUIController* ui_controller) {
+ InfoBarService::FromWebContents(web_contents)
+ ->AddInfoBar(make_scoped_ptr(new AccountChooserInfoBar(make_scoped_ptr(
+ new AccountChooserInfoBarDelegateAndroid(ui_controller)))));
+}
+
+AccountChooserInfoBar::AccountChooserInfoBar(
+ scoped_ptr<AccountChooserInfoBarDelegateAndroid> delegate)
+ : InfoBarAndroid(delegate.Pass()) {
+}
+
+base::android::ScopedJavaLocalRef<jobject>
+AccountChooserInfoBar::CreateRenderInfoBar(JNIEnv* env) {
+ AccountChooserInfoBarDelegateAndroid* infobar_delegate =
+ static_cast<AccountChooserInfoBarDelegateAndroid*>(delegate());
+ std::vector<base::string16> usernames;
+ // TODO(melandory): Federated credentials should be processed also.
+ for (auto password_form : infobar_delegate->local_credentials_forms()) {
+ usernames.push_back(password_form->username_value);
+ }
+ base::android::ScopedJavaLocalRef<jobjectArray> java_usernames =
+ base::android::ToJavaArrayOfStrings(env, usernames);
+ return Java_AccountChooserInfoBar_show(env, reinterpret_cast<intptr_t>(this),
+ GetEnumeratedIconId(),
+ java_usernames.obj());
+}
+
+void AccountChooserInfoBar::ProcessButton(int action,
+ const std::string& action_value) {
+ if (!owner())
+ return;
+
+ RemoveSelf();
+}
+
+void AccountChooserInfoBar::OnCredentialClicked(JNIEnv* env,
+ jobject obj,
+ jint credential_item,
+ jint credential_type) {
+ ChooseCredential(credential_item, credential_type);
+}
+
+void AccountChooserInfoBar::ChooseCredential(int credential_item,
+ int credential_type) {
+ AccountChooserInfoBarDelegateAndroid* delegate = GetDelegate();
+ delegate->choose_credential(
+ credential_item, (password_manager::CredentialType)credential_type);
+ RemoveSelf();
+}
+
+bool RegisterAccountChooserInfoBar(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+AccountChooserInfoBarDelegateAndroid* AccountChooserInfoBar::GetDelegate() {
+ return delegate()->AsAccountChooserInfoBarDelegateAndroid();
+}

Powered by Google App Engine
This is Rietveld 408576698