OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/infobars/insecure_content_infobar_delegate.h" | 5 #include "chrome/browser/infobars/insecure_content_infobar_delegate.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/api/infobars/infobar_service.h" | 8 #include "chrome/browser/api/infobars/infobar_service.h" |
9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
11 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
13 #include "content/public/common/page_transition_types.h" | 13 #include "content/public/common/page_transition_types.h" |
14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 | 16 |
17 using content::OpenURLParams; | 17 using content::OpenURLParams; |
18 | 18 |
| 19 // static |
| 20 void InsecureContentInfoBarDelegate::Create(InfoBarService* infobar_service, |
| 21 InfoBarType type) { |
| 22 scoped_ptr<InfoBarDelegate> new_infobar( |
| 23 new InsecureContentInfoBarDelegate(infobar_service, type)); |
| 24 |
| 25 // Only supsersede an existing insecure content infobar if we are upgrading |
| 26 // from DISPLAY to RUN. |
| 27 for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { |
| 28 InsecureContentInfoBarDelegate* delegate = infobar_service-> |
| 29 GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate(); |
| 30 if (delegate != NULL) { |
| 31 if ((type == RUN) && (delegate->type_ == DISPLAY)) |
| 32 return; |
| 33 infobar_service->ReplaceInfoBar(delegate, new_infobar.Pass()); |
| 34 break; |
| 35 } |
| 36 } |
| 37 if (new_infobar.get()) |
| 38 infobar_service->AddInfoBar(new_infobar.Pass()); |
| 39 |
| 40 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", |
| 41 (type == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, |
| 42 NUM_EVENTS); |
| 43 } |
| 44 |
19 InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( | 45 InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( |
20 InfoBarService* infobar_service, | 46 InfoBarService* infobar_service, |
21 InfoBarType type) | 47 InfoBarType type) |
22 : ConfirmInfoBarDelegate(infobar_service), | 48 : ConfirmInfoBarDelegate(infobar_service), |
23 type_(type) { | 49 type_(type) { |
24 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | |
25 (type_ == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, | |
26 NUM_EVENTS); | |
27 } | 50 } |
28 | 51 |
29 InsecureContentInfoBarDelegate::~InsecureContentInfoBarDelegate() { | 52 InsecureContentInfoBarDelegate::~InsecureContentInfoBarDelegate() { |
30 } | 53 } |
31 | 54 |
32 void InsecureContentInfoBarDelegate::InfoBarDismissed() { | 55 void InsecureContentInfoBarDelegate::InfoBarDismissed() { |
33 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | 56 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", |
34 (type_ == DISPLAY) ? DISPLAY_INFOBAR_DISMISSED : RUN_INFOBAR_DISMISSED, | 57 (type_ == DISPLAY) ? DISPLAY_INFOBAR_DISMISSED : RUN_INFOBAR_DISMISSED, |
35 NUM_EVENTS); | 58 NUM_EVENTS); |
36 ConfirmInfoBarDelegate::InfoBarDismissed(); | 59 ConfirmInfoBarDelegate::InfoBarDismissed(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 bool InsecureContentInfoBarDelegate::LinkClicked( | 111 bool InsecureContentInfoBarDelegate::LinkClicked( |
89 WindowOpenDisposition disposition) { | 112 WindowOpenDisposition disposition) { |
90 owner()->GetWebContents()->OpenURL(OpenURLParams( | 113 owner()->GetWebContents()->OpenURL(OpenURLParams( |
91 google_util::AppendGoogleLocaleParam(GURL( | 114 google_util::AppendGoogleLocaleParam(GURL( |
92 "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), | 115 "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), |
93 content::Referrer(), | 116 content::Referrer(), |
94 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 117 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
95 content::PAGE_TRANSITION_LINK, false)); | 118 content::PAGE_TRANSITION_LINK, false)); |
96 return false; | 119 return false; |
97 } | 120 } |
OLD | NEW |