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

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: Tweak SaveCardBubbleControllerImpl::DidNavigateMainFrame logic. 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/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 SetImage(GetVectorIcon(gfx::VectorIconId::AUTOFILL, 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);
sky 2015/10/26 20:56:26 Can this ever be null?
bondd 2015/10/27 01:06:39 controller is created lazily in chrome_autofill_cl
sky 2015/10/27 20:58:25 Acknowledged.
44 if (!controller)
45 return nullptr;
46
47 return static_cast<autofill::SaveCardBubbleViews*>(
48 controller->save_card_bubble_view());
49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698