| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2015 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/save_credit_card_icon_view.h" |
| 6 |
| 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/browser/ui/view_ids.h" |
| 12 #include "chrome/browser/ui/views/autofill/save_card_bubble_views.h" |
| 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/vector_icons_public.h" |
| 16 |
| 17 SaveCreditCardIconView::SaveCreditCardIconView(CommandUpdater* command_updater, |
| 18 Browser* browser) |
| 19 : BubbleIconView(command_updater, IDC_SAVE_CREDIT_CARD_FOR_PAGE), |
| 20 browser_(browser) { |
| 21 set_id(VIEW_ID_SAVE_CREDIT_CARD_BUTTON); |
| 22 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_SAVE_CREDIT_CARD)); |
| 23 SetToggled(false); |
| 24 } |
| 25 |
| 26 SaveCreditCardIconView::~SaveCreditCardIconView() {} |
| 27 |
| 28 void SaveCreditCardIconView::SetToggled(bool on) { |
| 29 SetActiveInternal(on); |
| 30 } |
| 31 |
| 32 void SaveCreditCardIconView::OnExecuting( |
| 33 BubbleIconView::ExecuteSource execute_source) {} |
| 34 |
| 35 views::BubbleDelegateView* SaveCreditCardIconView::GetBubble() const { |
| 36 if (!browser_) |
| 37 return nullptr; |
| 38 content::WebContents* web_contents = |
| 39 browser_->tab_strip_model()->GetActiveWebContents(); |
| 40 if (!web_contents) |
| 41 return nullptr; |
| 42 autofill::SaveCardBubbleControllerImpl* controller = |
| 43 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); |
| 44 if (!controller) |
| 45 return nullptr; |
| 46 |
| 47 return static_cast<autofill::SaveCardBubbleViews*>( |
| 48 controller->save_card_bubble_view()); |
| 49 } |
| 50 |
| 51 gfx::VectorIconId SaveCreditCardIconView::GetVectorIcon() const { |
| 52 return gfx::VectorIconId::AUTOFILL; |
| 53 } |
| OLD | NEW |