OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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_AUTOCHECKOUT_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_INFOBAR_DELEGATE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/string16.h" |
| 12 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 13 #include "chrome/browser/autofill/autofill_metrics.h" |
| 14 #include "chrome/common/form_data.h" |
| 15 #include "googleurl/src/gurl.h" |
| 16 |
| 17 class AutofillManager; |
| 18 |
| 19 namespace content { |
| 20 struct LoadCommittedDetails; |
| 21 struct SSLStatus; |
| 22 } |
| 23 |
| 24 // An InfoBar delegate that enables the user to allow or deny storing credit |
| 25 // card information gathered from a form submission. |
| 26 class AutocheckoutInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 27 public: |
| 28 // Creates an autofillflow infobar delegate and adds it to |infobar_service|. |
| 29 static void Create(const AutofillMetrics& metric_logger, |
| 30 const GURL& source_url, |
| 31 const content::SSLStatus& ssl_status, |
| 32 AutofillManager* autofill_manager, |
| 33 InfoBarService* infobar_service); |
| 34 |
| 35 #if defined(UNIT_TEST) |
| 36 static scoped_ptr<ConfirmInfoBarDelegate> Create( |
| 37 const AutofillMetrics& metric_logger, |
| 38 const GURL& source_url, |
| 39 const content::SSLStatus& ssl_status, |
| 40 AutofillManager* autofill_manager) { |
| 41 return scoped_ptr<ConfirmInfoBarDelegate>(new AutocheckoutInfoBarDelegate( |
| 42 metric_logger, source_url, ssl_status, autofill_manager, NULL)); |
| 43 } |
| 44 #endif |
| 45 |
| 46 private: |
| 47 AutocheckoutInfoBarDelegate(const AutofillMetrics& metric_logger, |
| 48 const GURL& source_url, |
| 49 const content::SSLStatus& ssl_status, |
| 50 AutofillManager* autofill_manager, |
| 51 InfoBarService* infobar_service); |
| 52 |
| 53 virtual ~AutocheckoutInfoBarDelegate(); |
| 54 |
| 55 // Logs UMA metric for user action type. |
| 56 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); |
| 57 |
| 58 // ConfirmInfoBarDelegate: |
| 59 virtual void InfoBarDismissed() OVERRIDE; |
| 60 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 61 virtual Type GetInfoBarType() const OVERRIDE; |
| 62 virtual bool ShouldExpireInternal( |
| 63 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 64 virtual string16 GetMessageText() const OVERRIDE; |
| 65 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 66 virtual bool Accept() OVERRIDE; |
| 67 virtual bool Cancel() OVERRIDE; |
| 68 virtual string16 GetLinkText() const OVERRIDE; |
| 69 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 70 |
| 71 // For logging UMA metrics. |
| 72 // Weak reference. Owned by the AutofillManager that initiated this infobar. |
| 73 const AutofillMetrics& metric_logger_; |
| 74 |
| 75 // To callback AutofillManager's ShowAutocheckoutDialog. |
| 76 AutofillManager* autofill_manager_; |
| 77 |
| 78 // URL of the page which triggered infobar. |
| 79 GURL source_url_; |
| 80 |
| 81 // SSL status of the page which triggered infobar. |
| 82 content::SSLStatus ssl_status_; |
| 83 |
| 84 // Did the user ever explicitly accept or dismiss this infobar? |
| 85 bool had_user_interaction_; |
| 86 |
| 87 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, AutocheckoutInfoBar); |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(AutocheckoutInfoBarDelegate); |
| 90 }; |
| 91 |
| 92 #endif // CHROME_BROWSER_AUTOFILL_AUTOCHECKOUT_INFOBAR_DELEGATE_H_ |
OLD | NEW |