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/google/google_util.h" | 8 #include "chrome/browser/google/google_util.h" |
9 #include "chrome/browser/infobars/infobar.h" | |
10 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
12 #include "content/public/browser/render_view_host.h" | 11 #include "content/public/browser/render_view_host.h" |
13 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
14 #include "content/public/common/page_transition_types.h" | 13 #include "content/public/common/page_transition_types.h" |
15 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
17 | 16 |
18 | 17 |
19 // static | 18 // static |
20 void InsecureContentInfoBarDelegate::Create(InfoBarService* infobar_service, | 19 void InsecureContentInfoBarDelegate::Create(InfoBarService* infobar_service, |
21 InfoBarType type) { | 20 InfoBarType type) { |
22 scoped_ptr<InfoBar> new_infobar(ConfirmInfoBarDelegate::CreateInfoBar( | 21 scoped_ptr<InfoBarDelegate> new_infobar( |
23 scoped_ptr<ConfirmInfoBarDelegate>( | 22 new InsecureContentInfoBarDelegate(infobar_service, type)); |
24 new InsecureContentInfoBarDelegate(type)))); | |
25 | 23 |
26 // Only supsersede an existing insecure content infobar if we are upgrading | 24 // Only supsersede an existing insecure content infobar if we are upgrading |
27 // from DISPLAY to RUN. | 25 // from DISPLAY to RUN. |
28 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 26 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
29 InfoBar* old_infobar = infobar_service->infobar_at(i); | |
30 InsecureContentInfoBarDelegate* delegate = | 27 InsecureContentInfoBarDelegate* delegate = |
31 old_infobar->delegate()->AsInsecureContentInfoBarDelegate(); | 28 infobar_service->infobar_at(i)->AsInsecureContentInfoBarDelegate(); |
32 if (delegate != NULL) { | 29 if (delegate != NULL) { |
33 if ((type == RUN) && (delegate->type_ == DISPLAY)) | 30 if ((type == RUN) && (delegate->type_ == DISPLAY)) |
34 return; | 31 return; |
35 infobar_service->ReplaceInfoBar(old_infobar, new_infobar.Pass()); | 32 infobar_service->ReplaceInfoBar(delegate, new_infobar.Pass()); |
36 break; | 33 break; |
37 } | 34 } |
38 } | 35 } |
39 if (new_infobar.get()) | 36 if (new_infobar.get()) |
40 infobar_service->AddInfoBar(new_infobar.Pass()); | 37 infobar_service->AddInfoBar(new_infobar.Pass()); |
41 | 38 |
42 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | 39 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", |
43 (type == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, | 40 (type == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, |
44 NUM_EVENTS); | 41 NUM_EVENTS); |
45 } | 42 } |
46 | 43 |
47 InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate(InfoBarType type) | 44 InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( |
48 : ConfirmInfoBarDelegate(), | 45 InfoBarService* infobar_service, |
| 46 InfoBarType type) |
| 47 : ConfirmInfoBarDelegate(infobar_service), |
49 type_(type) { | 48 type_(type) { |
50 } | 49 } |
51 | 50 |
52 InsecureContentInfoBarDelegate::~InsecureContentInfoBarDelegate() { | 51 InsecureContentInfoBarDelegate::~InsecureContentInfoBarDelegate() { |
53 } | 52 } |
54 | 53 |
55 void InsecureContentInfoBarDelegate::InfoBarDismissed() { | 54 void InsecureContentInfoBarDelegate::InfoBarDismissed() { |
56 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | 55 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", |
57 (type_ == DISPLAY) ? DISPLAY_INFOBAR_DISMISSED : RUN_INFOBAR_DISMISSED, | 56 (type_ == DISPLAY) ? DISPLAY_INFOBAR_DISMISSED : RUN_INFOBAR_DISMISSED, |
58 NUM_EVENTS); | 57 NUM_EVENTS); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 bool InsecureContentInfoBarDelegate::LinkClicked( | 105 bool InsecureContentInfoBarDelegate::LinkClicked( |
107 WindowOpenDisposition disposition) { | 106 WindowOpenDisposition disposition) { |
108 web_contents()->OpenURL(content::OpenURLParams( | 107 web_contents()->OpenURL(content::OpenURLParams( |
109 google_util::AppendGoogleLocaleParam(GURL("https://www.google.com/" | 108 google_util::AppendGoogleLocaleParam(GURL("https://www.google.com/" |
110 "support/chrome/bin/answer.py?answer=1342714")), | 109 "support/chrome/bin/answer.py?answer=1342714")), |
111 content::Referrer(), | 110 content::Referrer(), |
112 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 111 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
113 content::PAGE_TRANSITION_LINK, false)); | 112 content::PAGE_TRANSITION_LINK, false)); |
114 return false; | 113 return false; |
115 } | 114 } |
OLD | NEW |