18bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
28bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
38bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)// found in the LICENSE file.
48bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
58bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_controller.h"
68bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
78bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "chrome/browser/ui/autofill/test_generated_credit_card_bubble_view.h"
88bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "content/public/browser/web_contents.h"
98bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
108bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
118bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)namespace autofill {
128bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
138bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TestGeneratedCreditCardBubbleController::
148bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    TestGeneratedCreditCardBubbleController(content::WebContents* contents)
158bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    : GeneratedCreditCardBubbleController(contents),
168bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      bubbles_shown_(0) {
178bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  contents->SetUserData(UserDataKey(), this);
188bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
198bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
208bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TestGeneratedCreditCardBubbleController::
218bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    ~TestGeneratedCreditCardBubbleController() {}
228bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
238bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)bool TestGeneratedCreditCardBubbleController::IsInstalled() const {
248bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  return web_contents()->GetUserData(UserDataKey()) == this;
258bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
268bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
278bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)TestGeneratedCreditCardBubbleView* TestGeneratedCreditCardBubbleController::
288bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    GetTestingBubble() {
298bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  return static_cast<TestGeneratedCreditCardBubbleView*>(
308bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)      GeneratedCreditCardBubbleController::bubble().get());
318bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
328bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
338bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)base::WeakPtr<GeneratedCreditCardBubbleView>
348bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    TestGeneratedCreditCardBubbleController::CreateBubble() {
358bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  return TestGeneratedCreditCardBubbleView::Create(GetWeakPtr());
368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
378bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
388bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)bool TestGeneratedCreditCardBubbleController::CanShow() const {
398bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  return true;
408bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
418bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
428bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)void TestGeneratedCreditCardBubbleController::SetupAndShow(
438bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    const base::string16& fronting_card_name,
448bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)    const base::string16& backing_card_name) {
458bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  GeneratedCreditCardBubbleController::SetupAndShow(fronting_card_name,
468bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)                                                    backing_card_name);
478bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)  ++bubbles_shown_;
488bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}
498bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)
508bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles)}  // namespace autofill
51