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