blob: 47e954f9281488b5899b20d43d6ddd693c09f3fd [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2021 The Chromium Authors
Mohamed Amir Yosefe62de00f2021-01-30 04:18:132// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/ui/autofill/autofill_bubble_controller_base.h"
6
7#include "chrome/browser/ui/autofill/autofill_bubble_base.h"
8#include "chrome/browser/ui/browser_finder.h"
Mohamed Amir Yosefe62de00f2021-01-30 04:18:139#include "components/autofill/core/common/autofill_clock.h"
10#include "components/autofill/core/common/autofill_payments_features.h"
11
Vishwas Uppoor93470c62022-02-22 17:30:1312#if !BUILDFLAG(IS_ANDROID)
13#include "chrome/browser/ui/browser_window.h"
14#endif // !BUILDFLAG(IS_ANDROID)
15
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1316namespace autofill {
17
18AutofillBubbleControllerBase::AutofillBubbleControllerBase(
19 content::WebContents* web_contents)
20 : content::WebContentsObserver(web_contents) {}
21
22AutofillBubbleControllerBase::~AutofillBubbleControllerBase() {
23 HideBubble();
24}
25void AutofillBubbleControllerBase::Show() {
26 UpdatePageActionIcon();
27 DoShowBubble();
28 UpdatePageActionIcon();
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1329}
30
31void AutofillBubbleControllerBase::OnVisibilityChanged(
32 content::Visibility visibility) {
Peter Kastinga4863242024-12-23 00:19:4333 if (visibility == content::Visibility::HIDDEN) {
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1334 HideBubble();
Peter Kastinga4863242024-12-23 00:19:4335 }
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1336}
37
38void AutofillBubbleControllerBase::WebContentsDestroyed() {
39 HideBubble();
40}
41
42void AutofillBubbleControllerBase::UpdatePageActionIcon() {
Vishwas Uppoor93470c62022-02-22 17:30:1343// Page action icons do not exist for Android.
44#if !BUILDFLAG(IS_ANDROID)
Avi Drissman82d9bb02023-10-09 21:05:4545 Browser* browser = chrome::FindBrowserWithTab(web_contents());
Peter Kastinga4863242024-12-23 00:19:4346 if (browser) {
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1347 browser->window()->UpdatePageActionIcon(GetPageActionIconType());
Peter Kastinga4863242024-12-23 00:19:4348 }
Vishwas Uppoor93470c62022-02-22 17:30:1349#endif // !BUILDFLAG(IS_ANDROID)
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1350}
51
Mohamed Amir Yosefe62de00f2021-01-30 04:18:1352void AutofillBubbleControllerBase::HideBubble() {
53 if (bubble_view_) {
54 bubble_view_->Hide();
55 bubble_view_ = nullptr;
56 }
57}
58
59} // namespace autofill