| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_infobar_delegate.h" | 5 #include "chrome/browser/autofill/autofill_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "chrome/browser/autofill/autofill_manager.h" | 9 #include "chrome/browser/autofill/autofill_manager.h" |
| 10 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/pref_service.h" |
| 11 #include "grit/chromium_strings.h" | 14 #include "grit/chromium_strings.h" |
| 12 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 13 #include "grit/theme_resources.h" | 16 #include "grit/theme_resources.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 | 18 |
| 16 AutoFillInfoBarDelegate::AutoFillInfoBarDelegate(TabContents* tab_contents, | 19 AutoFillInfoBarDelegate::AutoFillInfoBarDelegate(TabContents* tab_contents, |
| 17 AutoFillManager* host) | 20 AutoFillManager* host) |
| 18 : ConfirmInfoBarDelegate(tab_contents), | 21 : ConfirmInfoBarDelegate(tab_contents), |
| 19 host_(host) { | 22 host_(host) { |
| 20 if (tab_contents) | 23 if (tab_contents) { |
| 24 PrefService* prefs = tab_contents->profile()->GetPrefs(); |
| 25 prefs->SetBoolean(prefs::kAutoFillInfoBarShown, true); |
| 21 tab_contents->AddInfoBar(this); | 26 tab_contents->AddInfoBar(this); |
| 27 } |
| 22 } | 28 } |
| 23 | 29 |
| 24 AutoFillInfoBarDelegate::~AutoFillInfoBarDelegate() { | 30 AutoFillInfoBarDelegate::~AutoFillInfoBarDelegate() { |
| 25 } | 31 } |
| 26 | 32 |
| 27 bool AutoFillInfoBarDelegate::ShouldExpire( | 33 bool AutoFillInfoBarDelegate::ShouldExpire( |
| 28 const NavigationController::LoadCommittedDetails& details) const { | 34 const NavigationController::LoadCommittedDetails& details) const { |
| 29 // The user has submitted a form, causing the page to navigate elsewhere. We | 35 // The user has submitted a form, causing the page to navigate elsewhere. We |
| 30 // don't want the infobar to be expired at this point, because the user won't | 36 // don't want the infobar to be expired at this point, because the user won't |
| 31 // get a chance to answer the question. | 37 // get a chance to answer the question. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 std::wstring AutoFillInfoBarDelegate::GetButtonLabel( | 60 std::wstring AutoFillInfoBarDelegate::GetButtonLabel( |
| 55 ConfirmInfoBarDelegate::InfoBarButton button) const { | 61 ConfirmInfoBarDelegate::InfoBarButton button) const { |
| 56 if (button == BUTTON_OK) | 62 if (button == BUTTON_OK) |
| 57 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_ACCEPT); | 63 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_ACCEPT); |
| 58 | 64 |
| 59 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_DENY); | 65 return l10n_util::GetString(IDS_AUTOFILL_INFOBAR_DENY); |
| 60 } | 66 } |
| 61 | 67 |
| 62 bool AutoFillInfoBarDelegate::Accept() { | 68 bool AutoFillInfoBarDelegate::Accept() { |
| 63 if (host_) { | 69 if (host_) { |
| 64 host_->SaveFormData(); | 70 host_->OnInfoBarAccepted(); |
| 65 host_ = NULL; | 71 host_ = NULL; |
| 66 } | 72 } |
| 67 return true; | 73 return true; |
| 68 } | 74 } |
| 69 | 75 |
| 70 bool AutoFillInfoBarDelegate::Cancel() { | 76 bool AutoFillInfoBarDelegate::Cancel() { |
| 71 if (host_) { | 77 if (host_) { |
| 72 host_->Reset(); | 78 host_->Reset(); |
| 73 host_ = NULL; | 79 host_ = NULL; |
| 74 } | 80 } |
| 75 return true; | 81 return true; |
| 76 } | 82 } |
| OLD | NEW |