Chromium Code Reviews| 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/color_palette.h" | |
| 16 #include "ui/gfx/paint_vector_icon.h" | |
| 17 #include "ui/gfx/vector_icons_public.h" | |
| 18 | |
| 19 SaveCreditCardIconView::SaveCreditCardIconView(CommandUpdater* command_updater, | |
| 20 Browser* browser) | |
| 21 : BubbleIconView(command_updater, IDC_SAVE_CREDIT_CARD_FOR_PAGE), | |
| 22 browser_(browser) { | |
| 23 set_id(VIEW_ID_SAVE_CREDIT_CARD_BUTTON); | |
| 24 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_SAVE_CREDIT_CARD)); | |
| 25 SetToggled(false); | |
| 26 } | |
| 27 | |
| 28 SaveCreditCardIconView::~SaveCreditCardIconView() {} | |
| 29 | |
| 30 void SaveCreditCardIconView::SetToggled(bool on) { | |
| 31 SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::AUTOFILL, 16, | |
| 32 on ? gfx::kGoogleBlue : gfx::kChromeIconGrey)); | |
| 33 } | |
| 34 | |
| 35 void SaveCreditCardIconView::OnExecuting( | |
| 36 BubbleIconView::ExecuteSource execute_source) {} | |
| 37 | |
| 38 views::BubbleDelegateView* SaveCreditCardIconView::GetBubble() const { | |
| 39 if (!browser_) | |
|
hcarmona
2015/10/16 21:16:35
Why allow browser to be nullptr if that means you
bondd
2015/10/22 02:15:17
SaveCreditCardIconView is instantiated in the Loca
| |
| 40 return nullptr; | |
| 41 content::WebContents* web_contents = | |
| 42 browser_->tab_strip_model()->GetActiveWebContents(); | |
| 43 if (!web_contents) | |
| 44 return nullptr; | |
| 45 autofill::SaveCardBubbleControllerImpl* controller = | |
| 46 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); | |
| 47 if (!controller) | |
| 48 return nullptr; | |
| 49 | |
| 50 return static_cast<autofill::SaveCardBubbleViews*>( | |
| 51 controller->save_card_bubble_view()); | |
| 52 } | |
| OLD | NEW |