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