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