Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/ui/views/location_bar/save_credit_card_icon_view.cc

Issue 1396923003: Autofill: Replace "save credit card" infobar with a bubble (Views only). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change object lifecycles + add interface classes. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698