OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/browser/ui/views/location_bar/autofill_credit_card_view.h" | |
6 | |
7 #include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h" | |
8 #include "chrome/browser/ui/toolbar/toolbar_model.h" | |
9 #include "ui/gfx/image/image.h" | |
10 | |
11 AutofillCreditCardView::AutofillCreditCardView( | |
12 ToolbarModel* toolbar_model, | |
13 LocationBarView::Delegate* delegate) | |
14 : toolbar_model_(toolbar_model), | |
15 delegate_(delegate) { | |
16 Update(); | |
17 } | |
18 | |
19 AutofillCreditCardView::~AutofillCreditCardView() {} | |
20 | |
21 void AutofillCreditCardView::Update() { | |
22 autofill::AutofillCreditCardBubbleController* controller = GetController(); | |
23 if (controller && !controller->AnchorIcon().IsEmpty()) { | |
24 SetVisible(true); | |
25 SetImage(controller->AnchorIcon().AsImageSkia()); | |
26 } else { | |
27 SetVisible(false); | |
28 SetImage(NULL); | |
29 } | |
30 } | |
31 | |
32 // TODO(dbeam): figure out what to do for a tooltip and accessibility. | |
33 | |
34 bool AutofillCreditCardView::CanHandleClick() const { | |
35 autofill::AutofillCreditCardBubbleController* controller = GetController(); | |
36 return controller && !controller->IsHiding(); | |
37 } | |
38 | |
39 void AutofillCreditCardView::OnClick() { | |
40 autofill::AutofillCreditCardBubbleController* controller = GetController(); | |
41 if (controller) | |
42 controller->OnAnchorClicked(); | |
43 } | |
44 | |
45 autofill::AutofillCreditCardBubbleController* AutofillCreditCardView:: | |
46 GetController() const { | |
47 content::WebContents* wc = delegate_->GetWebContents(); | |
48 if (!wc || toolbar_model_->GetInputInProgress()) | |
49 return NULL; | |
50 | |
51 return autofill::AutofillCreditCardBubbleController::FromWebContents(wc); | |
52 } | |
OLD | NEW |