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
|
// Copyright 2020 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_BUBBLE_CONTROLLERS_SAVE_UPDATE_BUBBLE_CONTROLLER_H_
#define CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_SAVE_UPDATE_BUBBLE_CONTROLLER_H_
#include "chrome/browser/ui/passwords/bubble_controllers/common_saved_account_manager_bubble_controller.h"
namespace base {
class Clock;
}
// This controller provides data and actions for the PasswordSaveUpdateView.
class SaveUpdateBubbleController
: public CommonSavedAccountManagerBubbleController {
public:
explicit SaveUpdateBubbleController(
base::WeakPtr<PasswordsModelDelegate> delegate,
DisplayReason display_reason);
~SaveUpdateBubbleController() override;
// Called by the view code when the save/update button is clicked by the user.
void OnSaveClicked();
// Called by the view code when the "Never for this site." button in clicked
// by the user.
void OnNeverForThisSiteClicked();
// Called by the view when the "Not now" button is clicked.
void OnNotNowClicked();
// The password bubble can switch its state between "save" and "update"
// depending on the user input. |state_| only captures the correct state on
// creation. This method returns true iff the current state is "update".
bool IsCurrentStateUpdate() const;
// Returns true iff the bubble is supposed to show the footer about syncing
// to Google account.
bool ShouldShowFooter() const;
// This method returns true iff the current state is "save" or "update" to a
// password that is synced to the Google Account. This method covers
// non-syncing account-store users as well as syncing users.
bool IsCurrentStateAffectingPasswordsStoredInTheGoogleAccount();
// Invokes `callback` with true if passwords revealing is not locked or
// re-authentication is not available on the given platform. Otherwise, the
// method schedules re-authentication and invokes `callback` with the result
// // of authentication.
void ShouldRevealPasswords(
PasswordsModelDelegate::AvailabilityCallback callback);
// Returns true iff the password account store is used.
bool IsUsingAccountStore();
// PasswordBubbleControllerBase methods:
std::u16string GetTitle() const override;
#if defined(UNIT_TEST)
void set_clock(base::Clock* clock) { clock_ = clock; }
bool password_revealing_requires_reauth() const {
return password_revealing_requires_reauth_;
}
#endif
private:
void ReportInteractions() override;
password_manager::InteractionsStats interaction_stats_;
// True iff password revealing should require re-auth for privacy reasons.
bool password_revealing_requires_reauth_;
// Used to retrieve the current time, in base::Time units.
raw_ptr<base::Clock> clock_;
std::vector<password_manager::PasswordForm> existing_credentials_;
std::u16string original_username_;
base::WeakPtrFactory<SaveUpdateBubbleController> weak_ptr_factory_{this};
};
#endif // CHROME_BROWSER_UI_PASSWORDS_BUBBLE_CONTROLLERS_SAVE_UPDATE_BUBBLE_CONTROLLER_H_
|