| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_WALLET_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_WALLET_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/string16.h" | 11 #include "base/string16.h" |
| 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 13 #include "chrome/browser/autofill/autofill_manager.h" |
| 13 #include "chrome/browser/autofill/autofill_metrics.h" | 14 #include "chrome/browser/autofill/autofill_metrics.h" |
| 15 #include "chrome/common/form_data.h" |
| 14 #include "webkit/glue/window_open_disposition.h" | 16 #include "webkit/glue/window_open_disposition.h" |
| 15 | 17 |
| 16 class CreditCard; | |
| 17 class PersonalDataManager; | 18 class PersonalDataManager; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 struct LoadCommittedDetails; | 21 struct LoadCommittedDetails; |
| 22 struct SSLStatus; |
| 21 } | 23 } |
| 22 | 24 |
| 23 // An InfoBar delegate that enables the user to allow or deny storing credit | 25 // An InfoBar delegate that enables the user to allow or deny storing credit |
| 24 // card information gathered from a form submission. | 26 // card information gathered from a form submission. |
| 25 class AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate { | 27 class WalletInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 26 public: | 28 public: |
| 27 AutofillCCInfoBarDelegate(InfoBarService* infobar_service, | 29 WalletInfoBarDelegate(InfoBarService* infobar_service, |
| 28 const CreditCard* credit_card, | 30 AutofillManager* autofill_manager, |
| 29 PersonalDataManager* personal_data, | 31 const AutofillMetrics* metric_logger, |
| 30 const AutofillMetrics* metric_logger); | 32 const GURL& source_url, |
| 33 const content::SSLStatus& ssl_status); |
| 31 | 34 |
| 32 private: | 35 private: |
| 33 virtual ~AutofillCCInfoBarDelegate(); | 36 virtual ~WalletInfoBarDelegate(); |
| 34 | 37 |
| 35 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); | 38 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); |
| 36 | 39 |
| 37 // ConfirmInfoBarDelegate: | 40 // ConfirmInfoBarDelegate: |
| 38 virtual bool ShouldExpire( | 41 virtual bool ShouldExpire( |
| 39 const content::LoadCommittedDetails& details) const OVERRIDE; | 42 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 40 virtual void InfoBarDismissed() OVERRIDE; | 43 virtual void InfoBarDismissed() OVERRIDE; |
| 41 virtual gfx::Image* GetIcon() const OVERRIDE; | 44 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 42 virtual Type GetInfoBarType() const OVERRIDE; | 45 virtual Type GetInfoBarType() const OVERRIDE; |
| 43 virtual string16 GetMessageText() const OVERRIDE; | 46 virtual string16 GetMessageText() const OVERRIDE; |
| 44 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 47 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 45 virtual bool Accept() OVERRIDE; | 48 virtual bool Accept() OVERRIDE; |
| 46 virtual bool Cancel() OVERRIDE; | 49 virtual bool Cancel() OVERRIDE; |
| 47 virtual string16 GetLinkText() const OVERRIDE; | 50 virtual string16 GetLinkText() const OVERRIDE; |
| 48 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 51 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 49 | 52 |
| 50 // The credit card that should be saved if the user accepts the infobar. | |
| 51 scoped_ptr<const CreditCard> credit_card_; | |
| 52 | |
| 53 // The personal data manager to which the credit card should be saved. | |
| 54 // Weak reference. | |
| 55 PersonalDataManager* personal_data_; | |
| 56 | |
| 57 // For logging UMA metrics. | 53 // For logging UMA metrics. |
| 58 // Weak reference. Owned by the AutofillManager that initiated this infobar. | 54 // Weak reference. Owned by the AutofillManager that initiated this infobar. |
| 59 const AutofillMetrics* metric_logger_; | 55 const AutofillMetrics* metric_logger_; |
| 60 | 56 |
| 57 // To callback AutofillManager's ShowWalletDialog. |
| 58 AutofillManager* autofill_manager_; |
| 59 |
| 60 // URL of the page which triggered infobar. |
| 61 GURL source_url_; |
| 62 |
| 63 // SSL status of the page which triggered infobar. |
| 64 content::SSLStatus ssl_status_; |
| 65 |
| 61 // Did the user ever explicitly accept or dismiss this infobar? | 66 // Did the user ever explicitly accept or dismiss this infobar? |
| 62 bool had_user_interaction_; | 67 bool had_user_interaction_; |
| 63 | 68 |
| 64 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); | 69 DISALLOW_COPY_AND_ASSIGN(WalletInfoBarDelegate); |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); | |
| 67 }; | 70 }; |
| 68 | 71 |
| 69 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ | 72 #endif // CHROME_BROWSER_AUTOFILL_WALLET_INFOBAR_DELEGATE_H_ |
| OLD | NEW |