Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: components/autofill/core/browser/autofill_cc_infobar_delegate.h

Issue 710453002: [Autofill] Componentize AutofillCCInfoBarDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Abstracting the call to WebContents::OpenURL() through the AutofillClient. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "components/autofill/core/browser/autofill_metrics.h" 13 #include "components/autofill/core/browser/autofill_metrics.h"
14 #include "components/infobars/core/confirm_infobar_delegate.h" 14 #include "components/infobars/core/confirm_infobar_delegate.h"
15 #include "ui/base/window_open_disposition.h" 15 #include "ui/base/window_open_disposition.h"
16 16
17 class CreditCard; 17 namespace infobars {
18 class PersonalDataManager; 18 class InfoBarManager;
19 class InfoBarService; 19 }
20 20
21 namespace autofill { 21 namespace autofill {
22 22
23 class AutofillClient;
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 AutofillCCInfoBarDelegate : public ConfirmInfoBarDelegate {
26 public: 28 public:
27 // Creates an autofill credit card infobar and delegate and adds the infobar 29 // Creates an autofill credit card infobar and delegate and add the infobar
Ilya Sherman 2015/01/07 01:58:54 nit: "add" -> "adds"
Ilya Sherman 2015/01/07 01:58:54 nit: "delegate" -> "client"
Pritam Nikam 2015/01/07 05:35:13 Here "delegate" is an infobar delegate.
Pritam Nikam 2015/01/07 05:35:13 Done.
28 // to |infobar_service|. 30 // to |infobar_manager|.
Ilya Sherman 2015/01/07 01:58:54 Please document the lifetime expectation, i.e. tha
Pritam Nikam 2015/01/07 05:35:13 Done. I've rephrased it to: "Creates an autofill
29 static void Create(InfoBarService* infobar_service, 31 static void Create(infobars::InfoBarManager* infobar_manager,
32 AutofillClient* autofill_client,
30 const base::Closure& save_card_callback); 33 const base::Closure& save_card_callback);
31 34
32 #if defined(UNIT_TEST) 35 #if defined(UNIT_TEST)
33 static scoped_ptr<ConfirmInfoBarDelegate> Create( 36 static scoped_ptr<ConfirmInfoBarDelegate> Create(
37 AutofillClient* autofill_client,
34 const base::Closure& save_card_callback) { 38 const base::Closure& save_card_callback) {
35 return scoped_ptr<ConfirmInfoBarDelegate>( 39 return scoped_ptr<ConfirmInfoBarDelegate>(
36 new AutofillCCInfoBarDelegate(save_card_callback)); 40 new AutofillCCInfoBarDelegate(autofill_client, save_card_callback));
37 } 41 }
38 #endif 42 #endif
Ilya Sherman 2015/01/06 23:20:17 nit: Please leave a blank line after this one.
Pritam Nikam 2015/01/07 05:35:13 Done.
39
40 private: 43 private:
41 explicit AutofillCCInfoBarDelegate(const base::Closure& save_card_callback); 44 AutofillCCInfoBarDelegate(AutofillClient* autofill_client,
45 const base::Closure& save_card_callback);
42 ~AutofillCCInfoBarDelegate() override; 46 ~AutofillCCInfoBarDelegate() override;
43 47
44 void LogUserAction(AutofillMetrics::InfoBarMetric user_action); 48 void LogUserAction(AutofillMetrics::InfoBarMetric user_action);
45 49
46 // ConfirmInfoBarDelegate: 50 // ConfirmInfoBarDelegate:
47 void InfoBarDismissed() override; 51 void InfoBarDismissed() override;
48 int GetIconID() const override; 52 int GetIconID() const override;
49 Type GetInfoBarType() const override; 53 Type GetInfoBarType() const override;
50 bool ShouldExpireInternal(const NavigationDetails& details) const override; 54 bool ShouldExpireInternal(const NavigationDetails& details) const override;
51 base::string16 GetMessageText() const override; 55 base::string16 GetMessageText() const override;
52 base::string16 GetButtonLabel(InfoBarButton button) const override; 56 base::string16 GetButtonLabel(InfoBarButton button) const override;
53 bool Accept() override; 57 bool Accept() override;
54 bool Cancel() override; 58 bool Cancel() override;
55 base::string16 GetLinkText() const override; 59 base::string16 GetLinkText() const override;
56 bool LinkClicked(WindowOpenDisposition disposition) override; 60 bool LinkClicked(WindowOpenDisposition disposition) override;
57 61
62 // Performs navigation to handle any link click. |autofill_client_| outlives
63 // the lifetime of |this| object.
64 AutofillClient* autofill_client_;
Ilya Sherman 2015/01/07 01:58:54 nit: Please change the type to "AutofillClient* co
Pritam Nikam 2015/01/07 05:35:13 Done.
65
58 // The callback to save credit card if the user accepts the infobar. 66 // The callback to save credit card if the user accepts the infobar.
59 base::Closure save_card_callback_; 67 base::Closure save_card_callback_;
60 68
61 // Did the user ever explicitly accept or dismiss this infobar? 69 // Did the user ever explicitly accept or dismiss this infobar?
62 bool had_user_interaction_; 70 bool had_user_interaction_;
63 71
64 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar); 72 FRIEND_TEST_ALL_PREFIXES(AutofillMetricsTest, CreditCardInfoBar);
65 73
66 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate); 74 DISALLOW_COPY_AND_ASSIGN(AutofillCCInfoBarDelegate);
67 }; 75 };
68 76
69 } // namespace autofill 77 } // namespace autofill
70 78
71 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_CC_INFOBAR_DELEGATE_H_ 79 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_CC_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/DEPS ('k') | components/autofill/core/browser/autofill_cc_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698