| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/ui/passwords/manage_passwords_state.h" | 14 #include "chrome/browser/ui/passwords/manage_passwords_state.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 class WebContents; | 18 class WebContents; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace password_manager { | |
| 22 struct CredentialInfo; | |
| 23 } | |
| 24 | |
| 25 // Native counterpart for the android dialog which allows users to select | 21 // Native counterpart for the android dialog which allows users to select |
| 26 // credentials which will be passed to the web site in order to log in the user. | 22 // credentials which will be passed to the web site in order to log in the user. |
| 27 class AccountChooserDialogAndroid : public content::WebContentsObserver { | 23 class AccountChooserDialogAndroid : public content::WebContentsObserver { |
| 28 public: | 24 public: |
| 29 AccountChooserDialogAndroid( | 25 AccountChooserDialogAndroid( |
| 30 content::WebContents* web_contents, | 26 content::WebContents* web_contents, |
| 31 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 27 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 32 std::vector<std::unique_ptr<autofill::PasswordForm>> federation_providers, | |
| 33 const GURL& origin, | 28 const GURL& origin, |
| 34 const ManagePasswordsState::CredentialsCallback& callback); | 29 const ManagePasswordsState::CredentialsCallback& callback); |
| 35 | 30 |
| 36 ~AccountChooserDialogAndroid() override; | 31 ~AccountChooserDialogAndroid() override; |
| 37 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); | 32 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
| 38 | 33 |
| 39 void ShowDialog(); | 34 void ShowDialog(); |
| 40 | 35 |
| 41 // Closes the dialog and propagates that no credentials was chosen. | 36 // Closes the dialog and propagates that no credentials was chosen. |
| 42 void CancelDialog(JNIEnv* env, | 37 void CancelDialog(JNIEnv* env, |
| 43 const base::android::JavaParamRef<jobject>& obj); | 38 const base::android::JavaParamRef<jobject>& obj); |
| 44 | 39 |
| 45 // Propagates the credentials chosen by the user. | 40 // Propagates the credentials chosen by the user. |
| 46 void OnCredentialClicked(JNIEnv* env, | 41 void OnCredentialClicked(JNIEnv* env, |
| 47 const base::android::JavaParamRef<jobject>& obj, | 42 const base::android::JavaParamRef<jobject>& obj, |
| 48 jint credential_item, | 43 jint credential_item, |
| 49 jint credential_type, | |
| 50 jboolean sign_button_clicked); | 44 jboolean sign_button_clicked); |
| 51 | 45 |
| 52 // Opens new tab with page which explains the Smart Lock branding. | 46 // Opens new tab with page which explains the Smart Lock branding. |
| 53 void OnLinkClicked(JNIEnv* env, | 47 void OnLinkClicked(JNIEnv* env, |
| 54 const base::android::JavaParamRef<jobject>& obj); | 48 const base::android::JavaParamRef<jobject>& obj); |
| 55 | 49 |
| 56 // content::WebContentsObserver overrides: | 50 // content::WebContentsObserver overrides: |
| 57 void WebContentsDestroyed() override; | 51 void WebContentsDestroyed() override; |
| 58 void WasHidden() override; | 52 void WasHidden() override; |
| 59 | 53 |
| 60 private: | 54 private: |
| 61 void OnDialogCancel(); | 55 void OnDialogCancel(); |
| 62 | 56 |
| 63 const std::vector<std::unique_ptr<autofill::PasswordForm>>& | 57 const std::vector<std::unique_ptr<autofill::PasswordForm>>& |
| 64 local_credentials_forms() const; | 58 local_credentials_forms() const; |
| 65 | 59 |
| 66 const std::vector<std::unique_ptr<autofill::PasswordForm>>& | |
| 67 federation_providers_forms() const; | |
| 68 | |
| 69 void ChooseCredential(size_t index, | 60 void ChooseCredential(size_t index, |
| 70 password_manager::CredentialType type, | 61 password_manager::CredentialType type, |
| 71 bool sign_button_clicked); | 62 bool sign_button_clicked); |
| 72 | 63 |
| 73 content::WebContents* web_contents_; | 64 content::WebContents* web_contents_; |
| 74 ManagePasswordsState passwords_data_; | 65 ManagePasswordsState passwords_data_; |
| 75 GURL origin_; | 66 GURL origin_; |
| 76 base::android::ScopedJavaGlobalRef<jobject> dialog_jobject_; | 67 base::android::ScopedJavaGlobalRef<jobject> dialog_jobject_; |
| 77 | 68 |
| 78 DISALLOW_COPY_AND_ASSIGN(AccountChooserDialogAndroid); | 69 DISALLOW_COPY_AND_ASSIGN(AccountChooserDialogAndroid); |
| 79 }; | 70 }; |
| 80 | 71 |
| 81 // Native JNI methods | 72 // Native JNI methods |
| 82 bool RegisterAccountChooserDialogAndroid(JNIEnv* env); | 73 bool RegisterAccountChooserDialogAndroid(JNIEnv* env); |
| 83 | 74 |
| 84 #endif // CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_ | 75 #endif // CHROME_BROWSER_PASSWORD_MANAGER_ACCOUNT_CHOOSER_DIALOG_ANDROID_H_ |
| OLD | NEW |