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

Unified 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: Replace browser tests with unit tests. Address reviewer comments. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/location_bar/save_credit_card_icon_view.cc
diff --git a/chrome/browser/ui/views/location_bar/save_credit_card_icon_view.cc b/chrome/browser/ui/views/location_bar/save_credit_card_icon_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4ef583fe65f4b14f060e60e44bf9abe22f2ddd15
--- /dev/null
+++ b/chrome/browser/ui/views/location_bar/save_credit_card_icon_view.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/location_bar/save_credit_card_icon_view.h"
+
+#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/view_ids.h"
+#include "chrome/browser/ui/views/autofill/save_card_bubble_views.h"
+#include "chrome/grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/color_palette.h"
Evan Stade 2015/10/23 01:39:41 you don't use this include
bondd 2015/10/23 03:32:34 Done.
+#include "ui/gfx/paint_vector_icon.h"
Evan Stade 2015/10/23 01:39:41 you don't use this include
bondd 2015/10/23 03:32:34 Done.
+#include "ui/gfx/vector_icons_public.h"
+
+SaveCreditCardIconView::SaveCreditCardIconView(CommandUpdater* command_updater,
+ Browser* browser)
+ : BubbleIconView(command_updater, IDC_SAVE_CREDIT_CARD_FOR_PAGE),
+ browser_(browser) {
+ set_id(VIEW_ID_SAVE_CREDIT_CARD_BUTTON);
+ SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_SAVE_CREDIT_CARD));
+ SetToggled(false);
+}
+
+SaveCreditCardIconView::~SaveCreditCardIconView() {}
+
+void SaveCreditCardIconView::SetToggled(bool on) {
+ SetImage(GetVectorIcon(gfx::VectorIconId::AUTOFILL, on));
+}
+
+void SaveCreditCardIconView::OnExecuting(
+ BubbleIconView::ExecuteSource execute_source) {}
+
+views::BubbleDelegateView* SaveCreditCardIconView::GetBubble() const {
+ if (!browser_)
+ return nullptr;
+ content::WebContents* web_contents =
+ browser_->tab_strip_model()->GetActiveWebContents();
+ if (!web_contents)
+ return nullptr;
+ autofill::SaveCardBubbleControllerImpl* controller =
+ autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents);
+ if (!controller)
+ return nullptr;
+
+ return static_cast<autofill::SaveCardBubbleViews*>(
+ controller->save_card_bubble_view());
+}

Powered by Google App Engine
This is Rietveld 408576698