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

Unified Diff: chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.mm

Issue 40483003: [rAC, OSX] Add "generated CC" info bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove bad DCHECK Created 7 years, 1 month 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/cocoa/location_bar/generated_credit_card_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.mm b/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.mm
new file mode 100644
index 0000000000000000000000000000000000000000..aadfe4afd201c50761d4c4917aaae75ed16343ef
--- /dev/null
+++ b/chrome/browser/ui/cocoa/location_bar/generated_credit_card_decoration.mm
@@ -0,0 +1,61 @@
+// Copyright (c) 2013 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/cocoa/location_bar/generated_credit_card_decoration.h"
+
+#include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
+#import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
+#include "grit/theme_resources.h"
+
+using autofill::GeneratedCreditCardBubbleController;
+
+GeneratedCreditCardDecoration::GeneratedCreditCardDecoration(
+ LocationBarViewMac* owner) : owner_(owner) {
+}
+
+GeneratedCreditCardDecoration::~GeneratedCreditCardDecoration() {
+}
+
+void GeneratedCreditCardDecoration::Update() {
+ GeneratedCreditCardBubbleController* controller = GetController();
+ if (controller && !controller->AnchorIcon().IsEmpty()) {
+ SetVisible(true);
+ SetImage(controller->AnchorIcon().AsNSImage());
+ } else {
+ SetVisible(false);
+ SetImage(nil);
+ }
+}
+
+NSPoint GeneratedCreditCardDecoration::GetBubblePointInFrame(NSRect frame) {
+ const NSRect draw_frame = GetDrawRectInFrame(frame);
+ return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame));
+}
+
+bool GeneratedCreditCardDecoration::AcceptsMousePress() {
+ GeneratedCreditCardBubbleController* controller = GetController();
+ return controller && !controller->IsHiding();
+}
+
+bool GeneratedCreditCardDecoration::OnMousePressed(NSRect frame) {
+ GeneratedCreditCardBubbleController* controller = GetController();
+ if (!controller)
+ return false;
+
+ controller->OnAnchorClicked();
+ return true;
+}
+
+GeneratedCreditCardBubbleController* GeneratedCreditCardDecoration::
+ GetController() const {
+ content::WebContents* wc = owner_->GetWebContents();
+ if (!wc || owner_->GetToolbarModel()->input_in_progress()) {
+ return NULL;
+ }
+
+ GeneratedCreditCardBubbleController* controller =
+ GeneratedCreditCardBubbleController::FromWebContents(wc);
+ return controller;
+}
+

Powered by Google App Engine
This is Rietveld 408576698