1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h"
7 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
8 #include "chrome/browser/ui/toolbar/toolbar_model.h"
9 #include "ui/gfx/image/image.h"
11 GeneratedCreditCardView::GeneratedCreditCardView(
12 LocationBarView::Delegate
* delegate
)
13 : delegate_(delegate
) {
17 GeneratedCreditCardView::~GeneratedCreditCardView() {}
19 void GeneratedCreditCardView::Update() {
20 autofill::GeneratedCreditCardBubbleController
* controller
= GetController();
21 if (controller
&& !controller
->AnchorIcon().IsEmpty()) {
23 SetImage(controller
->AnchorIcon().AsImageSkia());
30 // TODO(dbeam): figure out what to do for a tooltip and accessibility.
32 bool GeneratedCreditCardView::CanHandleClick() const {
33 autofill::GeneratedCreditCardBubbleController
* controller
= GetController();
34 return controller
&& !controller
->IsHiding();
37 void GeneratedCreditCardView::OnClick() {
38 autofill::GeneratedCreditCardBubbleController
* controller
= GetController();
40 controller
->OnAnchorClicked();
43 autofill::GeneratedCreditCardBubbleController
* GeneratedCreditCardView::
44 GetController() const {
45 content::WebContents
* wc
= delegate_
->GetWebContents();
46 if (!wc
|| delegate_
->GetToolbarModel()->input_in_progress())
49 return autofill::GeneratedCreditCardBubbleController::FromWebContents(wc
);