OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/location_bar/autofill_credit_card_view.h" | 5 #include "chrome/browser/ui/views/location_bar/generated_credit_card_view.h" |
6 | 6 |
7 #include "chrome/browser/ui/autofill/autofill_credit_card_bubble_controller.h" | 7 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" |
8 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 8 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
9 #include "ui/gfx/image/image.h" | 9 #include "ui/gfx/image/image.h" |
10 | 10 |
11 AutofillCreditCardView::AutofillCreditCardView( | 11 GeneratedCreditCardView::GeneratedCreditCardView( |
12 ToolbarModel* toolbar_model, | 12 ToolbarModel* toolbar_model, |
13 LocationBarView::Delegate* delegate) | 13 LocationBarView::Delegate* delegate) |
14 : toolbar_model_(toolbar_model), | 14 : toolbar_model_(toolbar_model), |
15 delegate_(delegate) { | 15 delegate_(delegate) { |
16 Update(); | 16 Update(); |
17 } | 17 } |
18 | 18 |
19 AutofillCreditCardView::~AutofillCreditCardView() {} | 19 GeneratedCreditCardView::~GeneratedCreditCardView() {} |
20 | 20 |
21 void AutofillCreditCardView::Update() { | 21 void GeneratedCreditCardView::Update() { |
22 autofill::AutofillCreditCardBubbleController* controller = GetController(); | 22 autofill::GeneratedCreditCardBubbleController* controller = GetController(); |
23 if (controller && !controller->AnchorIcon().IsEmpty()) { | 23 if (controller && !controller->AnchorIcon().IsEmpty()) { |
24 SetVisible(true); | 24 SetVisible(true); |
25 SetImage(controller->AnchorIcon().AsImageSkia()); | 25 SetImage(controller->AnchorIcon().AsImageSkia()); |
26 } else { | 26 } else { |
27 SetVisible(false); | 27 SetVisible(false); |
28 SetImage(NULL); | 28 SetImage(NULL); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 // TODO(dbeam): figure out what to do for a tooltip and accessibility. | 32 // TODO(dbeam): figure out what to do for a tooltip and accessibility. |
33 | 33 |
34 bool AutofillCreditCardView::CanHandleClick() const { | 34 bool GeneratedCreditCardView::CanHandleClick() const { |
35 autofill::AutofillCreditCardBubbleController* controller = GetController(); | 35 autofill::GeneratedCreditCardBubbleController* controller = GetController(); |
36 return controller && !controller->IsHiding(); | 36 return controller && !controller->IsHiding(); |
37 } | 37 } |
38 | 38 |
39 void AutofillCreditCardView::OnClick() { | 39 void GeneratedCreditCardView::OnClick() { |
40 autofill::AutofillCreditCardBubbleController* controller = GetController(); | 40 autofill::GeneratedCreditCardBubbleController* controller = GetController(); |
41 if (controller) | 41 if (controller) |
42 controller->OnAnchorClicked(); | 42 controller->OnAnchorClicked(); |
43 } | 43 } |
44 | 44 |
45 autofill::AutofillCreditCardBubbleController* AutofillCreditCardView:: | 45 autofill::GeneratedCreditCardBubbleController* GeneratedCreditCardView:: |
46 GetController() const { | 46 GetController() const { |
47 content::WebContents* wc = delegate_->GetWebContents(); | 47 content::WebContents* wc = delegate_->GetWebContents(); |
48 if (!wc || toolbar_model_->GetInputInProgress()) | 48 if (!wc || toolbar_model_->GetInputInProgress()) |
49 return NULL; | 49 return NULL; |
50 | 50 |
51 return autofill::AutofillCreditCardBubbleController::FromWebContents(wc); | 51 return autofill::GeneratedCreditCardBubbleController::FromWebContents(wc); |
52 } | 52 } |
OLD | NEW |