blob: 1681316b25597ec0432eae5584931fb312583088 [file] [log] [blame]
// Copyright 2013 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_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_delegate_view_base.h"
#include "ui/views/controls/styled_label_listener.h"
// The ManagePasswordsBubbleView controls the contents of the bubble which
// pops up when Chrome offers to save a user's password, or when the user
// interacts with the Omnibox icon. It has two distinct states:
//
// 1. PendingView: Offers the user the possibility of saving credentials.
// 2. ManageView: Displays the current page's saved credentials.
// 3. BlacklistedView: Informs the user that the current page is blacklisted.
class ManagePasswordsBubbleView : public ManagePasswordsBubbleDelegateViewBase,
public views::StyledLabelListener {
public:
static constexpr int kDesiredBubbleWidth = 370;
ManagePasswordsBubbleView(content::WebContents* web_contents,
views::View* anchor_view,
const gfx::Point& anchor_point,
DisplayReason reason);
#if defined(UNIT_TEST)
const View* initially_focused_view() const {
return initially_focused_view_;
}
static void set_auto_signin_toast_timeout(int seconds) {
auto_signin_toast_timeout_ = seconds;
}
#endif
private:
class AutoSigninView;
class PendingView;
class SaveConfirmationView;
class SignInPromoView;
class UpdatePendingView;
~ManagePasswordsBubbleView() override;
// DialogDelegate:
bool ShouldSnapFrameWidth() const override;
// LocationBarBubbleDelegateView:
int GetDialogButtons() const override;
views::View* GetInitiallyFocusedView() override;
void Init() override;
void AddedToWidget() override;
gfx::ImageSkia GetWindowIcon() override;
bool ShouldShowWindowIcon() const override;
bool ShouldShowCloseButton() const override;
// views::StyledLabelListener:
void StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) override;
// Refreshes the bubble's state.
void Refresh();
// Updates |title_view|'s text and link styling from |model_|.
void UpdateTitleText(views::StyledLabel* title_view);
// Sets up a child view according to the model state.
void CreateChild();
void set_initially_focused_view(views::View* view) {
DCHECK(!initially_focused_view_);
initially_focused_view_ = view;
}
// The timeout in seconds for the auto sign-in toast.
static int auto_signin_toast_timeout_;
views::View* initially_focused_view_;
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_VIEW_H_