Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / generated_credit_card_view.cc
blob38ce6adf0663cf5daeaf85207ecacd964d945d00
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) {
14 Update();
17 GeneratedCreditCardView::~GeneratedCreditCardView() {}
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);
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();
39 if (controller)
40 controller->OnAnchorClicked();
43 autofill::GeneratedCreditCardBubbleController* GeneratedCreditCardView::
44 GetController() const {
45 content::WebContents* wc = delegate_->GetWebContents();
46 if (!wc || delegate_->GetToolbarModel()->input_in_progress())
47 return NULL;
49 return autofill::GeneratedCreditCardBubbleController::FromWebContents(wc);