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