File: passwords_model_delegate.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (228 lines) | stat: -rw-r--r-- 9,730 bytes parent folder | download | duplicates (5)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_PASSWORDS_PASSWORDS_MODEL_DELEGATE_H_
#define CHROME_BROWSER_UI_PASSWORDS_PASSWORDS_MODEL_DELEGATE_H_

#include <memory>
#include <vector>

#include "base/functional/callback.h"
#include "base/memory/weak_ptr.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/ui/passwords/passwords_leak_dialog_delegate.h"
#include "components/password_manager/core/browser/manage_passwords_referrer.h"
#include "components/password_manager/core/browser/ui/password_check_referrer.h"
#include "components/password_manager/core/common/credential_manager_types.h"
#include "components/password_manager/core/common/password_manager_ui.h"

namespace content {
class WebContents;
}
namespace password_manager {
struct InteractionsStats;
class PasswordFeatureManager;
class PasswordFormMetricsRecorder;
struct PasswordForm;
namespace metrics_util {
enum class CredentialSourceType;
enum class MoveToAccountStoreTrigger;
}  // namespace metrics_util
}  // namespace password_manager
class PasswordChangeDelegate;

// An interface for ManagePasswordsBubbleModel implemented by
// ManagePasswordsUIController. Allows to retrieve the current state of the tab
// and notify about user actions.
class PasswordsModelDelegate {
 public:
  using AvailabilityCallback = base::OnceCallback<void(bool)>;

  // Returns WebContents* the model is attached to.
  virtual content::WebContents* GetWebContents() const = 0;

  // Returns the password_manager::PasswordFormMetricsRecorder that is
  // associated with the PasswordFormManager that governs the password being
  // submitted.
  virtual password_manager::PasswordFormMetricsRecorder*
  GetPasswordFormMetricsRecorder() = 0;

  virtual password_manager::PasswordFeatureManager*
  GetPasswordFeatureManager() = 0;

  // Returns the URL of the site the current forms are retrieved for.
  virtual url::Origin GetOrigin() const = 0;

  // Returns the current tab state.
  virtual password_manager::ui::State GetState() const = 0;

  // Returns the pending password in PENDING_PASSWORD_STATE and
  // PENDING_PASSWORD_UPDATE_STATE, the saved password in
  // SAVE_CONFIRMATION_STATE, the returned credential in AUTO_SIGNIN_STATE.
  virtual const password_manager::PasswordForm& GetPendingPassword() const = 0;

  // Returns unsynced credentials being deleted upon signout.
  virtual const std::vector<password_manager::PasswordForm>&
  GetUnsyncedCredentials() const = 0;

  // Returns the source of the credential to be saved.
  virtual password_manager::metrics_util::CredentialSourceType
  GetCredentialSource() const = 0;

  // Returns current local forms for the current page.
  virtual const std::vector<std::unique_ptr<password_manager::PasswordForm>>&
  GetCurrentForms() const = 0;

  // Returns credential for the manage passwords bubble in the single credential
  // mode. Providing a form by this method allows to use the bubble to display
  // arbitrary password form details, not only those from the list of website
  // related credentials. When this method returns `nullopt`, a list of stored
  // credentials for the current origin are displayed in the bubble.
  virtual const std::optional<password_manager::PasswordForm>&
  GetManagePasswordsSingleCredentialDetailsModeCredential() const = 0;

  // For PENDING_PASSWORD_STATE state returns the current statistics for
  // the pending username.
  virtual const password_manager::InteractionsStats*
  GetCurrentInteractionStats() const = 0;

  // For PASSWORD_UPDATED_* return # compromised passwords in the store.
  virtual size_t GetTotalNumberCompromisedPasswords() const = 0;

  // Returns true iff the current bubble is the manual fallback for saving.
  virtual bool BubbleIsManualFallbackForSaving() const = 0;

  // Returns true if GPM pin was created during the most recent passkey creation
  // flow, applicable for PASSKEY_SAVED_CONFIRMATION_STATE only.
  virtual bool GpmPinCreatedDuringRecentPasskeyCreation() const = 0;

  // Returns the passkey relying party during the most recent passkey flow, or
  // the empty string if there isn't one.
  virtual const std::string& PasskeyRpId() const = 0;

  // Called from the model when the bubble is displayed.
  virtual void OnBubbleShown() = 0;

  // Called from the model when the bubble is hidden.
  virtual void OnBubbleHidden() = 0;

  // Called when the user didn't interact with UI.
  virtual void OnNoInteraction() = 0;

  // Called when the user chose not to update password.
  virtual void OnNopeUpdateClicked() = 0;

  // Called from the model when the user chooses to never save passwords.
  virtual void NeverSavePassword() = 0;

  // Called from the model when the user chooses "not now" in response to the
  // password-save prompt.
  virtual void OnNotNowClicked() = 0;

  // Called when the passwords are revealed to the user without obfuscation.
  virtual void OnPasswordsRevealed() = 0;

  // Called from the model when the user chooses to save a password. The
  // username and password seen on the ui is sent as a parameter, and
  // handled accordingly if user had edited them.
  virtual void SavePassword(const std::u16string& username,
                            const std::u16string& password) = 0;

  // Called when the user chooses to save locally some of the unsynced
  // credentials that were deleted from the account store on signout.
  virtual void SaveUnsyncedCredentialsInProfileStore(
      const std::vector<password_manager::PasswordForm>&
          selected_credentials) = 0;

  // Called when the user chooses not to save locally the unsynced credentials
  // deleted from the account store on signout (the ones returned by
  // GetUnsyncedCredentials()).
  virtual void DiscardUnsyncedCredentials() = 0;

  // Called from the dialog controller when a user confirms moving the recently
  // used or selected credential to their account store.
  virtual void MovePasswordToAccountStore() = 0;

  // Moves pending password to the account storage.
  virtual void MovePendingPasswordToAccountStoreUsingHelper(
      const password_manager::PasswordForm&,
      password_manager::metrics_util::MoveToAccountStoreTrigger) = 0;

  // Called from the dialog controller when a user rejects moving the recently
  // used credential to their account store.
  virtual void BlockMovingPasswordToAccountStore() = 0;

  // Called from the dialog controller when the user chooses a credential.
  // Controller can be destroyed inside the method.
  virtual void ChooseCredential(
      const password_manager::PasswordForm& form,
      password_manager::CredentialType credential_type) = 0;

  // Open a new tab, pointing to the password manager settings page.
  virtual void NavigateToPasswordManagerSettingsPage(
      password_manager::ManagePasswordsReferrer referrer) = 0;

  // Open a new tab, pointing to the password manager subpage with the
  // credential details for the `password_domain_name`.
  virtual void NavigateToPasswordDetailsPageInPasswordManager(
      const std::string& password_domain_name,
      password_manager::ManagePasswordsReferrer referrer) = 0;

  // Open a new tab, pointing to the password check in the settings page.
  virtual void NavigateToPasswordCheckup(
      password_manager::PasswordCheckReferrer referrer) = 0;

  // Called from the dialog controller when the dialog is hidden.
  virtual void OnDialogHidden() = 0;

  // Called from the UI bubble controllers when OS re-auth is needed to enable
  // feature. Runs callback with true parameter immediately if user
  // authentication is not available for the given platform. Otherwise, the
  // method schedules a task to show an authentication dialog.
  // `message`is the messages to be shown in the authentication dialog after the
  // prefix "Chromium is trying to".
  virtual void AuthenticateUserWithMessage(const std::u16string& message,
                                           AvailabilityCallback callback) = 0;

  // Called from Biometric Authentication promo dialog when the feature is
  // enabled.
  virtual void ShowBiometricActivationConfirmation() = 0;

  // Called from the Management bubble when user wants to save local password in
  // the account. It opens the Move bubble for the selected password.
  virtual void ShowMovePasswordBubble(
      const password_manager::PasswordForm& form) = 0;

  // Called when user clicked "No thanks" button on Biometric Authentication
  // before filling promo dialog.
  virtual void OnBiometricAuthBeforeFillingDeclined() = 0;

  // Called when user clicked "Add username" button in AddUsername bubble.
  virtual void OnAddUsernameSaveClicked(
      const std::u16string& username,
      const password_manager::PasswordForm& password_to_change) = 0;

  // Called from the Save/Update bubble controller to decide whether or not we
  // should show the user the Chrome for iOS promo.
  virtual void MaybeShowIOSPasswordPromo() = 0;

  // Called from the Relaunch Chrome bubble to gracefully restart the Chrome.
  virtual void RelaunchChrome() = 0;

  // Returns the delegate for the password change flow.
  virtual PasswordChangeDelegate* GetPasswordChangeDelegate() const = 0;

  virtual PasswordsLeakDialogDelegate* GetPasswordsLeakDialogDelegate() = 0;

  // Opens the password change settings page as a separate tab.
  virtual void NavigateToPasswordChangeSettings() = 0;

 protected:
  virtual ~PasswordsModelDelegate() = default;
};

base::WeakPtr<PasswordsModelDelegate> PasswordsModelDelegateFromWebContents(
    content::WebContents* web_contents);

#endif  // CHROME_BROWSER_UI_PASSWORDS_PASSWORDS_MODEL_DELEGATE_H_