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