OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/autofill/autofill_cc_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 "base/histogram.h" | 9 #include "base/histogram.h" |
10 #include "chrome/browser/autofill/autofill_cc_infobar.h" | 10 #include "chrome/browser/autofill/autofill_cc_infobar.h" |
11 #include "chrome/browser/autofill/autofill_manager.h" | 11 #include "chrome/browser/autofill/autofill_manager.h" |
12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
14 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
17 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
19 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
21 | 21 |
22 AutoFillCCInfoBarDelegate::AutoFillCCInfoBarDelegate(TabContents* tab_contents, | 22 AutoFillCCInfoBarDelegate::AutoFillCCInfoBarDelegate(TabContents* tab_contents, |
23 AutoFillManager* host) | 23 AutoFillManager* host) |
24 : ConfirmInfoBarDelegate(tab_contents), | 24 : ConfirmInfoBarDelegate(tab_contents), |
25 host_(host) { | 25 host_(host) { |
26 if (tab_contents) | |
27 tab_contents->AddInfoBar(this); | |
28 } | 26 } |
29 | 27 |
30 AutoFillCCInfoBarDelegate::~AutoFillCCInfoBarDelegate() { | 28 AutoFillCCInfoBarDelegate::~AutoFillCCInfoBarDelegate() { |
31 } | 29 } |
32 | 30 |
33 bool AutoFillCCInfoBarDelegate::ShouldExpire( | 31 bool AutoFillCCInfoBarDelegate::ShouldExpire( |
34 const NavigationController::LoadCommittedDetails& details) const { | 32 const NavigationController::LoadCommittedDetails& details) const { |
35 // The user has submitted a form, causing the page to navigate elsewhere. We | 33 // The user has submitted a form, causing the page to navigate elsewhere. We |
36 // don't want the infobar to be expired at this point, because the user won't | 34 // don't want the infobar to be expired at this point, because the user won't |
37 // get a chance to answer the question. | 35 // get a chance to answer the question. |
38 return false; | 36 return false; |
39 } | 37 } |
40 | 38 |
41 void AutoFillCCInfoBarDelegate::InfoBarClosed() { | 39 void AutoFillCCInfoBarDelegate::InfoBarClosed() { |
42 if (host_) { | 40 if (host_) { |
43 host_->OnInfoBarClosed(false); | 41 host_->OnInfoBarClosed(false); |
44 host_ = NULL; | 42 host_ = NULL; |
45 } | 43 } |
46 | 44 delete this; |
47 // This will delete us. | |
48 ConfirmInfoBarDelegate::InfoBarClosed(); | |
49 } | 45 } |
50 | 46 |
51 string16 AutoFillCCInfoBarDelegate::GetMessageText() const { | 47 string16 AutoFillCCInfoBarDelegate::GetMessageText() const { |
52 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_TEXT); | 48 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_TEXT); |
53 } | 49 } |
54 | 50 |
55 SkBitmap* AutoFillCCInfoBarDelegate::GetIcon() const { | 51 SkBitmap* AutoFillCCInfoBarDelegate::GetIcon() const { |
56 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 52 return ResourceBundle::GetSharedInstance().GetBitmapNamed( |
57 IDR_INFOBAR_AUTOFILL); | 53 IDR_INFOBAR_AUTOFILL); |
58 } | 54 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 NEW_FOREGROUND_TAB, PageTransition::TYPED); | 96 NEW_FOREGROUND_TAB, PageTransition::TYPED); |
101 return false; | 97 return false; |
102 } | 98 } |
103 | 99 |
104 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
105 InfoBar* AutoFillCCInfoBarDelegate::CreateInfoBar() { | 101 InfoBar* AutoFillCCInfoBarDelegate::CreateInfoBar() { |
106 return CreateAutofillCcInfoBar(this); | 102 return CreateAutofillCcInfoBar(this); |
107 } | 103 } |
108 #endif // defined(OS_WIN) | 104 #endif // defined(OS_WIN) |
109 | 105 |
OLD | NEW |