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/browser.h" | |
13 #include "chrome/browser/pref_service.h" | 12 #include "chrome/browser/pref_service.h" |
14 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
16 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
17 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
18 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
19 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
20 #include "grit/theme_resources.h" | 19 #include "grit/theme_resources.h" |
21 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
22 | 21 |
23 AutoFillCCInfoBarDelegate::AutoFillCCInfoBarDelegate(TabContents* tab_contents, | 22 AutoFillCCInfoBarDelegate::AutoFillCCInfoBarDelegate(TabContents* tab_contents, |
24 AutoFillManager* host) | 23 AutoFillManager* host) |
25 : ConfirmInfoBarDelegate(tab_contents), | 24 : ConfirmInfoBarDelegate(tab_contents), |
26 browser_(NULL), | |
27 host_(host) { | 25 host_(host) { |
28 if (tab_contents) { | 26 if (tab_contents) |
29 // This is NULL for TestTabContents. | |
30 if (tab_contents->delegate()) | |
31 browser_ = tab_contents->delegate()->GetBrowser(); | |
32 | |
33 tab_contents->AddInfoBar(this); | 27 tab_contents->AddInfoBar(this); |
34 } | |
35 } | 28 } |
36 | 29 |
37 AutoFillCCInfoBarDelegate::~AutoFillCCInfoBarDelegate() { | 30 AutoFillCCInfoBarDelegate::~AutoFillCCInfoBarDelegate() { |
38 } | 31 } |
39 | 32 |
40 bool AutoFillCCInfoBarDelegate::ShouldExpire( | 33 bool AutoFillCCInfoBarDelegate::ShouldExpire( |
41 const NavigationController::LoadCommittedDetails& details) const { | 34 const NavigationController::LoadCommittedDetails& details) const { |
42 // 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 |
43 // 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 |
44 // get a chance to answer the question. | 37 // get a chance to answer the question. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 host_ = NULL; | 89 host_ = NULL; |
97 } | 90 } |
98 return true; | 91 return true; |
99 } | 92 } |
100 | 93 |
101 std::wstring AutoFillCCInfoBarDelegate::GetLinkText() { | 94 std::wstring AutoFillCCInfoBarDelegate::GetLinkText() { |
102 return l10n_util::GetString(IDS_AUTOFILL_CC_LEARN_MORE); | 95 return l10n_util::GetString(IDS_AUTOFILL_CC_LEARN_MORE); |
103 } | 96 } |
104 | 97 |
105 bool AutoFillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | 98 bool AutoFillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
106 browser_->OpenURL(GURL(kAutoFillLearnMoreUrl), GURL(), NEW_FOREGROUND_TAB, | 99 host_->tab_contents()->OpenURL(GURL(kAutoFillLearnMoreUrl), GURL(), |
107 PageTransition::TYPED); | 100 NEW_FOREGROUND_TAB, PageTransition::TYPED); |
108 return false; | 101 return false; |
109 } | 102 } |
110 | 103 |
111 #if defined(OS_WIN) | 104 #if defined(OS_WIN) |
112 InfoBar* AutoFillCCInfoBarDelegate::CreateInfoBar() { | 105 InfoBar* AutoFillCCInfoBarDelegate::CreateInfoBar() { |
113 return CreateAutofillCcInfoBar(this); | 106 return CreateAutofillCcInfoBar(this); |
114 } | 107 } |
115 #endif // defined(OS_WIN) | 108 #endif // defined(OS_WIN) |
116 | 109 |
OLD | NEW |