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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_ssl_helper.cc

Issue 7006010: Change InfoBar-related notifications to be sourced from a TabContentsWrapper, not a TabContents. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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/tab_contents/tab_contents_ssl_helper.h" 5 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/certificate_viewer.h" 10 #include "chrome/browser/certificate_viewer.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 InfoBarDelegate* infobar_delegate_; 121 InfoBarDelegate* infobar_delegate_;
122 NotificationRegistrar registrar_; 122 NotificationRegistrar registrar_;
123 123
124 DISALLOW_COPY_AND_ASSIGN(SSLAddCertData); 124 DISALLOW_COPY_AND_ASSIGN(SSLAddCertData);
125 }; 125 };
126 126
127 TabContentsSSLHelper::SSLAddCertData::SSLAddCertData( 127 TabContentsSSLHelper::SSLAddCertData::SSLAddCertData(
128 TabContentsWrapper* tab_contents) 128 TabContentsWrapper* tab_contents)
129 : tab_contents_(tab_contents), 129 : tab_contents_(tab_contents),
130 infobar_delegate_(NULL) { 130 infobar_delegate_(NULL) {
131 Source<TabContents> source(tab_contents_->tab_contents()); 131 Source<TabContentsWrapper> source(tab_contents_);
132 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source); 132 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source);
133 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, source); 133 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, source);
134 } 134 }
135 135
136 TabContentsSSLHelper::SSLAddCertData::~SSLAddCertData() { 136 TabContentsSSLHelper::SSLAddCertData::~SSLAddCertData() {
137 } 137 }
138 138
139 void TabContentsSSLHelper::SSLAddCertData::ShowInfoBar( 139 void TabContentsSSLHelper::SSLAddCertData::ShowInfoBar(
140 InfoBarDelegate* delegate) { 140 InfoBarDelegate* delegate) {
141 if (infobar_delegate_) 141 if (infobar_delegate_)
142 tab_contents_->ReplaceInfoBar(infobar_delegate_, delegate); 142 tab_contents_->ReplaceInfoBar(infobar_delegate_, delegate);
143 else 143 else
144 tab_contents_->AddInfoBar(delegate); 144 tab_contents_->AddInfoBar(delegate);
145 infobar_delegate_ = delegate; 145 infobar_delegate_ = delegate;
146 } 146 }
147 147
148 void TabContentsSSLHelper::SSLAddCertData::ShowErrorInfoBar( 148 void TabContentsSSLHelper::SSLAddCertData::ShowErrorInfoBar(
149 const string16& message) { 149 const string16& message) {
150 ShowInfoBar(new SimpleAlertInfoBarDelegate( 150 ShowInfoBar(new SimpleAlertInfoBarDelegate(
151 tab_contents_->tab_contents(), GetCertIcon(), message, true)); 151 tab_contents_->tab_contents(), GetCertIcon(), message, true));
152 } 152 }
153 153
154 void TabContentsSSLHelper::SSLAddCertData::Observe( 154 void TabContentsSSLHelper::SSLAddCertData::Observe(
155 NotificationType type, 155 NotificationType type,
156 const NotificationSource& source, 156 const NotificationSource& source,
157 const NotificationDetails& details) { 157 const NotificationDetails& details) {
158 typedef std::pair<InfoBarDelegate*, InfoBarDelegate*> InfoBarDelegatePair; 158 DCHECK(type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED ||
159 type.value == NotificationType::TAB_CONTENTS_INFOBAR_REPLACED);
159 if (infobar_delegate_ == 160 if (infobar_delegate_ ==
160 ((type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) ? 161 ((type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) ?
161 Details<InfoBarDelegate>(details).ptr() : 162 Details<std::pair<InfoBarDelegate*, bool> >(details)->first :
162 Details<InfoBarDelegatePair>(details).ptr()->first)) 163 Details<std::pair<InfoBarDelegate*, InfoBar*> >(details)->first))
163 infobar_delegate_ = NULL; 164 infobar_delegate_ = NULL;
164 } 165 }
165 166
166 167
167 // TabContentsSSLHelper ------------------------------------------------------- 168 // TabContentsSSLHelper -------------------------------------------------------
168 169
169 TabContentsSSLHelper::TabContentsSSLHelper(TabContentsWrapper* tab_contents) 170 TabContentsSSLHelper::TabContentsSSLHelper(TabContentsWrapper* tab_contents)
170 : tab_contents_(tab_contents) { 171 : tab_contents_(tab_contents) {
171 } 172 }
172 173
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( 224 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData(
224 SSLAddCertHandler* handler) { 225 SSLAddCertHandler* handler) {
225 // Find/create the slot. 226 // Find/create the slot.
226 linked_ptr<SSLAddCertData>& ptr_ref = 227 linked_ptr<SSLAddCertData>& ptr_ref =
227 request_id_to_add_cert_data_[handler->network_request_id()]; 228 request_id_to_add_cert_data_[handler->network_request_id()];
228 // Fill it if necessary. 229 // Fill it if necessary.
229 if (!ptr_ref.get()) 230 if (!ptr_ref.get())
230 ptr_ref.reset(new SSLAddCertData(tab_contents_)); 231 ptr_ref.reset(new SSLAddCertData(tab_contents_));
231 return ptr_ref.get(); 232 return ptr_ref.get();
232 } 233 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/infobar_container.cc ('k') | chrome/browser/translate/translate_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698