OLD | NEW |
1 // Copyright (c) 2012 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 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 5 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "components/autofill/core/browser/autofill_client.h" |
9 #include "chrome/grit/generated_resources.h" | |
10 #include "chrome/grit/google_chrome_strings.h" | |
11 #include "components/autofill/core/browser/credit_card.h" | 9 #include "components/autofill/core/browser/credit_card.h" |
12 #include "components/autofill/core/browser/personal_data_manager.h" | 10 #include "components/autofill/core/browser/personal_data_manager.h" |
13 #include "components/autofill/core/common/autofill_constants.h" | 11 #include "components/autofill/core/common/autofill_constants.h" |
14 #include "components/infobars/core/infobar.h" | 12 #include "components/infobars/core/infobar.h" |
15 #include "content/public/browser/page_navigator.h" | 13 #include "components/infobars/core/infobar_manager.h" |
16 #include "content/public/browser/web_contents.h" | 14 #include "grit/components_scaled_resources.h" |
17 #include "content/public/browser/web_contents_delegate.h" | |
18 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
19 #include "grit/theme_resources.h" | |
20 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "url/gurl.h" |
21 | 18 |
22 namespace autofill { | 19 namespace autofill { |
23 | 20 |
24 // static | 21 // static |
25 void AutofillCCInfoBarDelegate::Create( | 22 void AutofillCCInfoBarDelegate::Create( |
26 InfoBarService* infobar_service, | 23 infobars::InfoBarManager* infobar_manager, |
| 24 AutofillClient* autofill_client, |
27 const base::Closure& save_card_callback) { | 25 const base::Closure& save_card_callback) { |
28 infobar_service->AddInfoBar( | 26 infobar_manager->AddInfoBar( |
29 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( | 27 infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( |
30 new AutofillCCInfoBarDelegate(save_card_callback)))); | 28 new AutofillCCInfoBarDelegate(autofill_client, save_card_callback)))); |
31 } | 29 } |
32 | 30 |
33 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( | 31 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( |
| 32 AutofillClient* autofill_client, |
34 const base::Closure& save_card_callback) | 33 const base::Closure& save_card_callback) |
35 : ConfirmInfoBarDelegate(), | 34 : ConfirmInfoBarDelegate(), |
| 35 autofill_client_(autofill_client), |
36 save_card_callback_(save_card_callback), | 36 save_card_callback_(save_card_callback), |
37 had_user_interaction_(false) { | 37 had_user_interaction_(false) { |
38 AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); | 38 AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); |
39 } | 39 } |
40 | 40 |
41 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() { | 41 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() { |
42 if (!had_user_interaction_) | 42 if (!had_user_interaction_) |
43 LogUserAction(AutofillMetrics::INFOBAR_IGNORED); | 43 LogUserAction(AutofillMetrics::INFOBAR_IGNORED); |
44 } | 44 } |
45 | 45 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 bool AutofillCCInfoBarDelegate::Cancel() { | 92 bool AutofillCCInfoBarDelegate::Cancel() { |
93 LogUserAction(AutofillMetrics::INFOBAR_DENIED); | 93 LogUserAction(AutofillMetrics::INFOBAR_DENIED); |
94 return true; | 94 return true; |
95 } | 95 } |
96 | 96 |
97 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const { | 97 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const { |
98 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 98 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
99 } | 99 } |
100 | 100 |
101 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | 101 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
102 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( | 102 autofill_client_->LinkClicked( |
103 content::OpenURLParams( | 103 GURL(autofill::kHelpURL), |
104 GURL(autofill::kHelpURL), content::Referrer(), | 104 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition); |
105 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 105 |
106 ui::PAGE_TRANSITION_LINK, false)); | |
107 return false; | 106 return false; |
108 } | 107 } |
109 | 108 |
110 } // namespace autofill | 109 } // namespace autofill |
OLD | NEW |