summaryrefslogtreecommitdiffstats
path: root/chrome/browser/password_manager/account_chooser_dialog_android.h
blob: ed193caf6609e504733a10280f0894377ce7ac7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright 2015 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.

#ifndef CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_

#include <vector>

#include "base/android/jni_android.h"
#include "base/memory/scoped_vector.h"
#include "chrome/browser/ui/passwords/manage_passwords_state.h"

namespace content {
class WebContents;
}

namespace password_manager {
struct CredentialInfo;
}

// Native counterpart for the android dialog which allows users to select
// credentials which will be passed to the web site in order to log in the user.
class AccountChooserDialogAndroid {
 public:
  AccountChooserDialogAndroid(
      content::WebContents* web_contents,
      ScopedVector<autofill::PasswordForm> local_credentials,
      ScopedVector<autofill::PasswordForm> federated_credentials,
      const GURL& origin,
      const ManagePasswordsState::CredentialsCallback& callback);

  ~AccountChooserDialogAndroid();
  void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);

  void ShowDialog();

  // Closes the dialog and propagates that no credentials was chosen.
  void CancelDialog(JNIEnv* env,
                    const base::android::JavaParamRef<jobject>& obj);

  // Propagates the credentials chosen by the user.
  void OnCredentialClicked(JNIEnv* env,
                           const base::android::JavaParamRef<jobject>& obj,
                           jint credential_item,
                           jint credential_type);

  // Opens new tab with page which explains the Smart Lock branding.
  void OnLinkClicked(JNIEnv* env,
                     const base::android::JavaParamRef<jobject>& obj);

 private:
  const std::vector<const autofill::PasswordForm*>& local_credentials_forms()
      const;

  const std::vector<const autofill::PasswordForm*>&
  federated_credentials_forms() const;

  void ChooseCredential(size_t index, password_manager::CredentialType type);

  content::WebContents* web_contents_;
  ManagePasswordsState passwords_data_;

  DISALLOW_COPY_AND_ASSIGN(AccountChooserDialogAndroid);
};

// Native JNI methods
bool RegisterAccountChooserDialogAndroid(JNIEnv* env);

#endif  // CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_