Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/infobars/insecure_content_infobar_delegate.cc

Issue 14241006: Eliminate InfoBarTabHelper. Make InfoBarService a concrete class. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/render_messages.h"
11 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/public/common/page_transition_types.h" 13 #include "content/public/common/page_transition_types.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 16
17 using content::OpenURLParams; 17 using content::OpenURLParams;
18 18
19 // static 19 // static
20 void InsecureContentInfoBarDelegate::Create(InfoBarService* infobar_service, 20 void InsecureContentInfoBarDelegate::Create(InfoBarService* infobar_service,
21 InfoBarType type) { 21 InfoBarType type) {
22 scoped_ptr<InfoBarDelegate> new_infobar( 22 scoped_ptr<InfoBarDelegate> new_infobar(
23 new InsecureContentInfoBarDelegate(infobar_service, type)); 23 new InsecureContentInfoBarDelegate(infobar_service, type));
24 24
25 // Only supsersede an existing insecure content infobar if we are upgrading 25 // Only supsersede an existing insecure content infobar if we are upgrading
26 // from DISPLAY to RUN. 26 // from DISPLAY to RUN.
27 for (size_t i = 0; i < infobar_service->GetInfoBarCount(); ++i) { 27 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) {
28 InsecureContentInfoBarDelegate* delegate = infobar_service-> 28 InsecureContentInfoBarDelegate* delegate =
29 GetInfoBarDelegateAt(i)->AsInsecureContentInfoBarDelegate(); 29 infobar_service->infobar_at(i)->AsInsecureContentInfoBarDelegate();
30 if (delegate != NULL) { 30 if (delegate != NULL) {
31 if ((type == RUN) && (delegate->type_ == DISPLAY)) 31 if ((type == RUN) && (delegate->type_ == DISPLAY))
32 return; 32 return;
33 infobar_service->ReplaceInfoBar(delegate, new_infobar.Pass()); 33 infobar_service->ReplaceInfoBar(delegate, new_infobar.Pass());
34 break; 34 break;
35 } 35 }
36 } 36 }
37 if (new_infobar.get()) 37 if (new_infobar.get())
38 infobar_service->AddInfoBar(new_infobar.Pass()); 38 infobar_service->AddInfoBar(new_infobar.Pass());
39 39
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 86
87 // Cancel button is labelled "load anyways". It triggers Cancel(), but really 87 // Cancel button is labelled "load anyways". It triggers Cancel(), but really
88 // means become insecure, so do the work of reloading the page. 88 // means become insecure, so do the work of reloading the page.
89 bool InsecureContentInfoBarDelegate::Cancel() { 89 bool InsecureContentInfoBarDelegate::Cancel() {
90 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2", 90 UMA_HISTOGRAM_ENUMERATION("InsecureContentInfoBarDelegateV2",
91 (type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE, 91 (type_ == DISPLAY) ? DISPLAY_USER_OVERRIDE : RUN_USER_OVERRIDE,
92 NUM_EVENTS); 92 NUM_EVENTS);
93 93
94 content::WebContents* web_contents = owner()->GetWebContents(); 94 content::WebContents* web_contents = owner()->web_contents();
95 if (web_contents) { 95 if (web_contents) {
96 int32 routing_id = web_contents->GetRoutingID(); 96 int32 routing_id = web_contents->GetRoutingID();
97 web_contents->Send((type_ == DISPLAY) ? 97 web_contents->Send((type_ == DISPLAY) ?
98 static_cast<IPC::Message*>( 98 static_cast<IPC::Message*>(
99 new ChromeViewMsg_SetAllowDisplayingInsecureContent( 99 new ChromeViewMsg_SetAllowDisplayingInsecureContent(
100 routing_id, true)) : 100 routing_id, true)) :
101 new ChromeViewMsg_SetAllowRunningInsecureContent( 101 new ChromeViewMsg_SetAllowRunningInsecureContent(
102 routing_id, true)); 102 routing_id, true));
103 } 103 }
104 return true; 104 return true;
105 } 105 }
106 106
107 string16 InsecureContentInfoBarDelegate::GetLinkText() const { 107 string16 InsecureContentInfoBarDelegate::GetLinkText() const {
108 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); 108 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
109 } 109 }
110 110
111 bool InsecureContentInfoBarDelegate::LinkClicked( 111 bool InsecureContentInfoBarDelegate::LinkClicked(
112 WindowOpenDisposition disposition) { 112 WindowOpenDisposition disposition) {
113 owner()->GetWebContents()->OpenURL(OpenURLParams( 113 owner()->web_contents()->OpenURL(OpenURLParams(
114 google_util::AppendGoogleLocaleParam(GURL( 114 google_util::AppendGoogleLocaleParam(GURL(
115 "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")), 115 "https://www.google.com/support/chrome/bin/answer.py?answer=1342714")),
116 content::Referrer(), 116 content::Referrer(),
117 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 117 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
118 content::PAGE_TRANSITION_LINK, false)); 118 content::PAGE_TRANSITION_LINK, false));
119 return false; 119 return false;
120 } 120 }
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobars_browsertest.cc ('k') | chrome/browser/managed_mode/managed_mode_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698