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

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: Addresses Peter's input over use of WeakPtr<>. Created 5 years, 12 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) 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_driver.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"
21 17
22 namespace autofill { 18 namespace autofill {
23 19
24 // static 20 // static
25 void AutofillCCInfoBarDelegate::Create( 21 void AutofillCCInfoBarDelegate::Create(
26 InfoBarService* infobar_service, 22 infobars::InfoBarManager* infobar_manager,
23 AutofillDriver* autofill_driver,
27 const base::Closure& save_card_callback) { 24 const base::Closure& save_card_callback) {
28 infobar_service->AddInfoBar( 25 infobar_manager->AddInfoBar(
29 infobar_service->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( 26 infobar_manager->CreateConfirmInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
30 new AutofillCCInfoBarDelegate(save_card_callback)))); 27 new AutofillCCInfoBarDelegate(autofill_driver, save_card_callback))));
31 } 28 }
32 29
33 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate( 30 AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
31 AutofillDriver* autofill_driver,
34 const base::Closure& save_card_callback) 32 const base::Closure& save_card_callback)
35 : ConfirmInfoBarDelegate(), 33 : ConfirmInfoBarDelegate(),
34 autofill_driver_(autofill_driver->AsWeakPtr()),
36 save_card_callback_(save_card_callback), 35 save_card_callback_(save_card_callback),
37 had_user_interaction_(false) { 36 had_user_interaction_(false) {
38 AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN); 37 AutofillMetrics::LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN);
39 } 38 }
40 39
41 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() { 40 AutofillCCInfoBarDelegate::~AutofillCCInfoBarDelegate() {
42 if (!had_user_interaction_) 41 if (!had_user_interaction_)
43 LogUserAction(AutofillMetrics::INFOBAR_IGNORED); 42 LogUserAction(AutofillMetrics::INFOBAR_IGNORED);
44 } 43 }
45 44
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 bool AutofillCCInfoBarDelegate::Cancel() { 91 bool AutofillCCInfoBarDelegate::Cancel() {
93 LogUserAction(AutofillMetrics::INFOBAR_DENIED); 92 LogUserAction(AutofillMetrics::INFOBAR_DENIED);
94 return true; 93 return true;
95 } 94 }
96 95
97 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const { 96 base::string16 AutofillCCInfoBarDelegate::GetLinkText() const {
98 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 97 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
99 } 98 }
100 99
101 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { 100 bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
102 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( 101 if (autofill_driver_) {
103 content::OpenURLParams( 102 autofill_driver_->LinkClicked(
104 GURL(autofill::kHelpURL), content::Referrer(), 103 GURL(autofill::kHelpURL),
Peter Kasting 2014/12/29 22:24:30 If this is the only call to LinkClicked(), I would
Pritam Nikam 2014/12/30 13:22:13 This is modified to address Ilya's comment earlier
Ilya Sherman 2015/01/06 02:54:59 The goal is to share as much code as possible with
105 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 104 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition);
106 ui::PAGE_TRANSITION_LINK, false)); 105 }
106
107 return false; 107 return false;
108 } 108 }
109 109
110 } // namespace autofill 110 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698