File: password_accessory_controller.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (79 lines) | stat: -rw-r--r-- 3,606 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
// Copyright 2018 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_KEYBOARD_ACCESSORY_ANDROID_PASSWORD_ACCESSORY_CONTROLLER_H_
#define CHROME_BROWSER_KEYBOARD_ACCESSORY_ANDROID_PASSWORD_ACCESSORY_CONTROLLER_H_

#include "base/memory/weak_ptr.h"
#include "chrome/browser/keyboard_accessory/android/accessory_controller.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom-forward.h"
#include "components/autofill/core/common/password_generation_util.h"
#include "components/password_manager/core/browser/credential_cache.h"
#include "content/public/browser/web_contents.h"

class AffiliatedPlusProfilesProvider;

// Interface for password-specific keyboard accessory controller between the
// ManualFillingController and PasswordManagerClient.
//
// There is a single instance per WebContents that can be accessed by calling:
//     PasswordAccessoryController::GetOrCreate(web_contents);
// On the first call, an instance is attached to |web_contents|, so it can be
// returned by subsequent calls.
class PasswordAccessoryController : public AccessoryController {
 public:
  PasswordAccessoryController() = default;

  PasswordAccessoryController(const PasswordAccessoryController&) = delete;
  PasswordAccessoryController& operator=(const PasswordAccessoryController&) =
      delete;

  ~PasswordAccessoryController() override = default;

  // Returns a reference to the unique PasswordAccessoryController associated
  // with |web_contents|. A new instance is created if the first time this
  // function is called.
  static PasswordAccessoryController* GetOrCreate(
      content::WebContents* web_contents,
      password_manager::CredentialCache* credential_cache);

  // Adds a plus profiles provider to this controller that is used to generate
  // the plus profiles section for the frontend.
  virtual void RegisterPlusProfilesProvider(
      base::WeakPtr<AffiliatedPlusProfilesProvider> provider) = 0;

  // Returns a reference to the unique PasswordAccessoryController associated
  // with |web_contents|. Returns null if no such instance exists.
  static PasswordAccessoryController* GetIfExisting(
      content::WebContents* web_contents);

  // -----------------------------
  // Methods called by the client:
  // -----------------------------

  // Makes sure, that all shown suggestions are appropriate for the currently
  // focused field and for fields that lost the focus.
  // `is_field_eligible_for_manual_generation` is required to differentiate
  // fields where filling is not possible (password filling on text fields is
  // disabled), but manual generation is available for the user.
  virtual void RefreshSuggestionsForField(
      autofill::mojom::FocusedFieldType focused_field_type,
      bool is_field_eligible_for_manual_generation) = 0;

  // Signals that generation was requested from the accessory. |type|
  // indicates whether generation was requested via the manual fallback or from
  // the automatically provided button.
  virtual void OnGenerationRequested(
      autofill::password_generation::PasswordGenerationType type) = 0;

  // Asks the controller to update the UI allowing users to continue with the
  // CredMan conditional UI.
  virtual void UpdateCredManReentryUi(
      autofill::mojom::FocusedFieldType focused_field_type) = 0;

  // Returns a WeakPtr to the instance.
  virtual base::WeakPtr<PasswordAccessoryController> AsWeakPtr() = 0;
};

#endif  // CHROME_BROWSER_KEYBOARD_ACCESSORY_ANDROID_PASSWORD_ACCESSORY_CONTROLLER_H_