OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/tab_contents/insecure_content_infobar_delegate.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "chrome/browser/google/google_util.h" | |
9 #include "chrome/browser/infobars/infobar_tab_helper.h" | |
10 #include "chrome/common/render_messages.h" | |
11 #include "content/public/browser/web_contents.h" | |
12 #include "content/public/common/page_transition_types.h" | |
13 #include "grit/generated_resources.h" | |
14 #include "ui/base/l10n/l10n_util.h" | |
15 | |
16 using content::OpenURLParams; | |
17 | |
18 InsecureContentInfoBarDelegate::InsecureContentInfoBarDelegate( | |
19 InfoBarTabHelper* infobar_helper, | |
20 InfoBarType type) | |
21 : ConfirmInfoBarDelegate(infobar_helper), | |
22 type_(type) { | |
23 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | |
24 (type_ == DISPLAY) ? DISPLAY_INFOBAR_SHOWN : RUN_INFOBAR_SHOWN, | |
25 NUM_EVENTS); | |
26 } | |
27 | |
28 InsecureContentInfoBarDelegate::~InsecureContentInfoBarDelegate() { | |
29 } | |
30 | |
31 void InsecureContentInfoBarDelegate::InfoBarDismissed() { | |
32 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | |
33 (type_ == DISPLAY) ? DISPLAY_INFOBAR_DISMISSED : RUN_INFOBAR_DISMISSED, | |
34 NUM_EVENTS); | |
35 ConfirmInfoBarDelegate::InfoBarDismissed(); | |
36 } | |
37 | |
38 InsecureContentInfoBarDelegate* | |
39 InsecureContentInfoBarDelegate::AsInsecureContentInfoBarDelegate() { | |
40 return this; | |
41 } | |
42 | |
43 string16 InsecureContentInfoBarDelegate::GetMessageText() const { | |
44 return l10n_util::GetStringUTF16(IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT); | |
45 } | |
46 | |
47 string16 InsecureContentInfoBarDelegate::GetButtonLabel( | |
48 InfoBarButton button) const { | |
49 return l10n_util::GetStringUTF16(button == BUTTON_OK ? | |
50 IDS_BLOCK_INSECURE_CONTENT_BUTTON : IDS_ALLOW_INSECURE_CONTENT_BUTTON); | |
51 } | |
52 | |
53 // OK button is labelled "don't load". It triggers Accept(), but really | |
54 // means stay secure, so do nothing but count the event and dismiss. | |
55 bool InsecureContentInfoBarDelegate::Accept() { | |
56 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | |
57 (type_ == DISPLAY) ? DISPLAY_USER_DID_NOT_LOAD : RUN_USER_DID_NOT_LOAD, | |
58 NUM_EVENTS); | |
59 return true; | |
60 } | |
61 | |
62 | |
63 // Cancel button is labelled "load anyways". It triggers Cancel(), but really | |
64 // means become insecure, so do the work of reloading the page. | |
65 bool InsecureContentInfoBarDelegate::Cancel() { | |
66 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", | |
67 (type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE, | |
68 NUM_EVENTS); | |
69 | |
70 int32 routing_id = owner()->routing_id(); | |
71 owner()->Send((type_ == DISPLAY) ? static_cast<IPC::Message*>( | |
72 new ChromeViewMsg_SetAllowDisplayingInsecureContent(routing_id, true)) : | |
73 new ChromeViewMsg_SetAllowRunningInsecureContent(routing_id, true)); | |
74 return true; | |
75 } | |
76 | |
77 string16 InsecureContentInfoBarDelegate::GetLinkText() const { | |
78 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | |
79 } | |
80 | |
81 bool InsecureContentInfoBarDelegate::LinkClicked( | |
82 WindowOpenDisposition disposition) { | |
83 owner()->web_contents()->OpenURL(OpenURLParams( | |
84 google_util::AppendGoogleLocaleParam(GURL( | |
85 "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), | |
86 content::Referrer(), | |
87 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | |
88 content::PAGE_TRANSITION_LINK, false)); | |
89 return false; | |
90 } | |
OLD | NEW |