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

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

Issue 710453002: [Autofill] Componentize AutofillCCInfoBarDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years 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) 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" 9 #include "components/autofill/core/browser/autofill_driver.h"
10 #include "chrome/grit/google_chrome_strings.h" 10 #include "components/autofill/core/browser/autofill_manager.h"
11 #include "components/autofill/core/browser/credit_card.h" 11 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/browser/personal_data_manager.h" 12 #include "components/autofill/core/browser/personal_data_manager.h"
13 #include "components/autofill/core/common/autofill_constants.h" 13 #include "components/autofill/core/common/autofill_constants.h"
14 #include "components/infobars/core/infobar.h" 14 #include "components/infobars/core/infobar.h"
15 #include "content/public/browser/page_navigator.h" 15 #include "components/infobars/core/infobar_manager.h"
16 #include "content/public/browser/web_contents.h" 16 #include "grit/components_scaled_resources.h"
17 #include "content/public/browser/web_contents_delegate.h"
18 #include "grit/components_strings.h" 17 #include "grit/components_strings.h"
19 #include "grit/theme_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
21 19
22 namespace autofill { 20 namespace autofill {
23 21
24 // static 22 // static
25 void AutofillCCInfoBarDelegate::Create( 23 void AutofillCCInfoBarDelegate::Create(
26 InfoBarService* infobar_service, 24 infobars::InfoBarManager* infobar_manager,
25 AutofillManager* autofill_manager,
27 const base::Closure& save_card_callback) { 26 const base::Closure& save_card_callback) {
28 infobar_service->AddInfoBar( 27 infobar_manager->AddInfoBar(autofill_manager->client()->CreateInfoBar(
29 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( 28 scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate(
30 new AutofillCCInfoBarDelegate(save_card_callback)))); 29 autofill_manager->driver(), save_card_callback))));
31 } 30 }
32 31
33 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( 32 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
33 AutofillDriver* autofill_driver,
34 const base::Closure& save_card_callback) 34 const base::Closure& save_card_callback)
35 : ConfirmInfoBarDelegate(), 35 : ConfirmInfoBarDelegate(),
36 autofill_driver_(autofill_driver),
36 save_card_callback_(save_card_callback), 37 save_card_callback_(save_card_callback),
37 had_user_interaction_(false) { 38 had_user_interaction_(false) {
38 AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); 39 AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
39 } 40 }
40 41
41 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() { 42 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
42 if (!had_user_interaction_) 43 if (!had_user_interaction_)
43 LogUserAction(AutofillMetrics::INFOBAR_IGNORED); 44 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
44 } 45 }
45 46
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool AutofillCCInfoBarDelegate::Cancel() { 93 bool AutofillCCInfoBarDelegate::Cancel() {
93 LogUserAction(AutofillMetrics::INFOBAR_DENIED); 94 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
94 return true; 95 return true;
95 } 96 }
96 97
97 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const { 98 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const {
98 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 99 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
99 } 100 }
100 101
101 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 102 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
102 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( 103 autofill_driver_->LinkClicked(
103 content::OpenURLParams( 104 GURL(autofill::kHelpURL),
104 GURL(autofill::kHelpURL), content::Referrer(), 105 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition);
105 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
106 ui::PAGE_TRANSITION_LINK, false));
107 return false; 106 return false;
108 } 107 }
109 108
110 } // namespace autofill 109 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698