autofill_cc_infobar_delegate.h revision ddb351dbec246cf1fab5ec20d2d5520909041de1
1// Copyright (c) 2011 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#ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ 6#define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ 7#pragma once 8 9#include "base/basictypes.h" 10#include "base/gtest_prod_util.h" 11#include "base/memory/scoped_ptr.h" 12#include "base/string16.h" 13#include "chrome/browser/autofill/autofill_metrics.h" 14#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 15#include "content/browser/tab_contents/navigation_controller.h" 16#include "webkit/glue/window_open_disposition.h" 17 18class CreditCard; 19class PersonalDataManager; 20class SkBitmap; 21class TabContents; 22 23// An InfoBar delegate that enables the user to allow or deny storing credit 24// card information gathered from a form submission. 25class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { 26 public: 27 AutofillCCInfoBarDelegate(TabContents* tab_contents, 28 const CreditCard* credit_card, 29 PersonalDataManager* personal_data, 30 const AutofillMetrics* metric_logger); 31 32 private: 33 virtual ~AutofillCCInfoBarDelegate(); 34 35 void LogUserAction(AutofillMetrics::CreditCardInfoBarMetric user_action); 36 37 // ConfirmInfoBarDelegate: 38 virtual bool ShouldExpire( 39 const NavigationController::LoadCommittedDetails& details) const; 40 virtual void InfoBarClosed(); 41 virtual void InfoBarDismissed(); 42 virtual SkBitmap* GetIcon() const; 43 virtual Type GetInfoBarType() const; 44 virtual string16 GetMessageText() const; 45 virtual string16 GetButtonLabel(InfoBarButton button) const; 46 virtual bool Accept(); 47 virtual bool Cancel(); 48 virtual string16 GetLinkText(); 49 virtual bool LinkClicked(WindowOpenDisposition disposition); 50 51 // The credit card that should be saved if the user accepts the infobar. 52 scoped_ptr<const CreditCard> credit_card_; 53 54 // The personal data manager to which the credit card should be saved. 55 // Weak reference. 56 PersonalDataManager* personal_data_; 57 58 // For logging UMA metrics. 59 // Weak reference. Owned by the AutofillManager that initiated this infobar. 60 const AutofillMetrics* metric_logger_; 61 62 // Did the user ever explicitly accept or dismiss this infobar? 63 bool had_user_interaction_; 64 65 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); 66 67 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); 68}; 69 70#endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ 71