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