| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 
|  | 6 | 
|  | 7 #include "app/l10n_util.h" | 
|  | 8 #include "app/resource_bundle.h" | 
|  | 9 #include "chrome/browser/autofill/autofill_manager.h" | 
|  | 10 #include "chrome/browser/browser.h" | 
|  | 11 #include "chrome/browser/pref_service.h" | 
|  | 12 #include "chrome/browser/profile.h" | 
|  | 13 #include "chrome/browser/tab_contents/tab_contents.h" | 
|  | 14 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 
|  | 15 #include "chrome/common/pref_names.h" | 
|  | 16 #include "grit/chromium_strings.h" | 
|  | 17 #include "grit/generated_resources.h" | 
|  | 18 #include "grit/theme_resources.h" | 
|  | 19 #include "third_party/skia/include/core/SkBitmap.h" | 
|  | 20 | 
|  | 21 AutoFillCCInfoBarDelegate::AutoFillCCInfoBarDelegate(TabContents* tab_contents, | 
|  | 22                                                      AutoFillManager* host) | 
|  | 23     : ConfirmInfoBarDelegate(tab_contents), | 
|  | 24       browser_(NULL), | 
|  | 25       host_(host) { | 
|  | 26   if (tab_contents) { | 
|  | 27     // This is NULL for TestTabContents. | 
|  | 28     if (tab_contents->delegate()) | 
|  | 29       browser_ = tab_contents->delegate()->GetBrowser(); | 
|  | 30 | 
|  | 31     tab_contents->AddInfoBar(this); | 
|  | 32   } | 
|  | 33 } | 
|  | 34 | 
|  | 35 AutoFillCCInfoBarDelegate::~AutoFillCCInfoBarDelegate() { | 
|  | 36 } | 
|  | 37 | 
|  | 38 bool AutoFillCCInfoBarDelegate::ShouldExpire( | 
|  | 39     const NavigationController::LoadCommittedDetails& details) const { | 
|  | 40   // The user has submitted a form, causing the page to navigate elsewhere. We | 
|  | 41   // don't want the infobar to be expired at this point, because the user won't | 
|  | 42   // get a chance to answer the question. | 
|  | 43   return false; | 
|  | 44 } | 
|  | 45 | 
|  | 46 void AutoFillCCInfoBarDelegate::InfoBarClosed() { | 
|  | 47   if (host_) { | 
|  | 48     host_->OnInfoBarClosed(false); | 
|  | 49     host_ = NULL; | 
|  | 50   } | 
|  | 51 | 
|  | 52   // This will delete us. | 
|  | 53   ConfirmInfoBarDelegate::InfoBarClosed(); | 
|  | 54 } | 
|  | 55 | 
|  | 56 std::wstring AutoFillCCInfoBarDelegate::GetMessageText() const { | 
|  | 57   return l10n_util::GetString(IDS_AUTOFILL_CC_INFOBAR_TEXT); | 
|  | 58 } | 
|  | 59 | 
|  | 60 SkBitmap* AutoFillCCInfoBarDelegate::GetIcon() const { | 
|  | 61   return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 
|  | 62       IDR_INFOBAR_AUTOFILL); | 
|  | 63 } | 
|  | 64 | 
|  | 65 int AutoFillCCInfoBarDelegate::GetButtons() const { | 
|  | 66   return BUTTON_OK | BUTTON_CANCEL; | 
|  | 67 } | 
|  | 68 | 
|  | 69 std::wstring AutoFillCCInfoBarDelegate::GetButtonLabel( | 
|  | 70     ConfirmInfoBarDelegate::InfoBarButton button) const { | 
|  | 71   if (button == BUTTON_OK) | 
|  | 72     return l10n_util::GetString(IDS_AUTOFILL_CC_INFOBAR_ACCEPT); | 
|  | 73   else if (button == BUTTON_CANCEL) | 
|  | 74     return l10n_util::GetString(IDS_AUTOFILL_CC_INFOBAR_DENY); | 
|  | 75   else | 
|  | 76     NOTREACHED(); | 
|  | 77 | 
|  | 78   return std::wstring(); | 
|  | 79 } | 
|  | 80 | 
|  | 81 bool AutoFillCCInfoBarDelegate::Accept() { | 
|  | 82   if (host_) { | 
|  | 83     host_->OnInfoBarClosed(true); | 
|  | 84     host_ = NULL; | 
|  | 85   } | 
|  | 86   return true; | 
|  | 87 } | 
|  | 88 | 
|  | 89 bool AutoFillCCInfoBarDelegate::Cancel() { | 
|  | 90   if (host_) { | 
|  | 91     host_->OnInfoBarClosed(false); | 
|  | 92     host_ = NULL; | 
|  | 93   } | 
|  | 94   return true; | 
|  | 95 } | 
|  | 96 | 
|  | 97 std::wstring AutoFillCCInfoBarDelegate::GetLinkText() { | 
|  | 98   return l10n_util::GetString(IDS_AUTOFILL_CC_LEARN_MORE); | 
|  | 99 } | 
|  | 100 | 
|  | 101 bool AutoFillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | 
|  | 102   browser_->OpenURL(GURL(kAutoFillLearnMoreUrl), GURL(), NEW_FOREGROUND_TAB, | 
|  | 103                     PageTransition::TYPED); | 
|  | 104   return false; | 
|  | 105 } | 
|  | 106 | 
| OLD | NEW | 
|---|