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

Unified Diff: components/autofill/content/browser/autofill_cc_infobar_delegate.cc

Issue 710453002: [Autofill] Componentize AutofillCCInfoBarDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modified AutofillCCInfoBarDelegate unit-tests. Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/content/browser/autofill_cc_infobar_delegate.cc
diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/components/autofill/content/browser/autofill_cc_infobar_delegate.cc
similarity index 76%
rename from chrome/browser/autofill/autofill_cc_infobar_delegate.cc
rename to components/autofill/content/browser/autofill_cc_infobar_delegate.cc
index f2fd9ea8d0e636e17b3b0e6409ad247c578504f4..7338214b2b9b9f4def2f44e36b496b74409ac22c 100644
--- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc
+++ b/components/autofill/content/browser/autofill_cc_infobar_delegate.cc
@@ -2,39 +2,40 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/autofill/autofill_cc_infobar_delegate.h"
+#include "components/autofill/content/browser/autofill_cc_infobar_delegate.h"
#include "base/logging.h"
-#include "chrome/browser/infobars/infobar_service.h"
-#include "chrome/grit/generated_resources.h"
-#include "chrome/grit/google_chrome_strings.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/common/autofill_constants.h"
#include "components/infobars/core/infobar.h"
+#include "components/infobars/core/infobar_manager.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
+#include "grit/components_scaled_resources.h"
#include "grit/components_strings.h"
-#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
namespace autofill {
// static
void AutofillCCInfoBarDelegate::Create(
- InfoBarService* infobar_service,
+ content::WebContents* web_contents,
+ infobars::InfoBarManager* infobar_manager,
const AutofillMetrics* metric_logger,
const base::Closure& save_card_callback) {
- infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
+ infobar_manager->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar(
scoped_ptr<ConfirmInfoBarDelegate>(new AutofillCCInfoBarDelegate(
- metric_logger, save_card_callback))));
+ web_contents, metric_logger, save_card_callback))));
}
AutofillCCInfoBarDelegate::AutofillCCInfoBarDelegate(
+ content::WebContents* web_contents,
const AutofillMetrics* metric_logger,
const base::Closure& save_card_callback)
: ConfirmInfoBarDelegate(),
+ web_contents_(web_contents),
metric_logger_(metric_logger),
save_card_callback_(save_card_callback),
had_user_interaction_(false) {
@@ -81,8 +82,9 @@ base::string16 AutofillCCInfoBarDelegate::GetMessageText() const {
base::string16 AutofillCCInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
- return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
- IDS_AUTOFILL_CC_INFOBAR_ACCEPT : IDS_AUTOFILL_CC_INFOBAR_DENY);
+ return l10n_util::GetStringUTF16((button == BUTTON_OK)
+ ? IDS_AUTOFILL_CC_INFOBAR_ACCEPT
+ : IDS_AUTOFILL_CC_INFOBAR_DENY);
}
bool AutofillCCInfoBarDelegate::Accept() {
@@ -102,11 +104,13 @@ base::string16 AutofillCCInfoBarDelegate::GetLinkText() const {
}
bool AutofillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) {
- InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL(
- content::OpenURLParams(
- GURL(autofill::kHelpURL), content::Referrer(),
- (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
- ui::PAGE_TRANSITION_LINK, false));
+ if (web_contents_) {
Ilya Sherman 2014/11/19 21:22:46 Why can the web_contents_ be null?
Pritam Nikam 2014/11/21 08:26:25 Done.
+ web_contents_->OpenURL(content::OpenURLParams(
+ GURL(autofill::kHelpURL), content::Referrer(),
+ (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
+ ui::PAGE_TRANSITION_LINK, false));
+ }
+
return false;
}

Powered by Google App Engine
This is Rietveld 408576698