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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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"
11 #include "chrome/browser/ssl/ssl_add_cert_handler.h" 11 #include "chrome/browser/ssl/ssl_add_cert_handler.h"
12 #include "chrome/browser/ssl_client_certificate_selector.h" 12 #include "chrome/browser/ssl_client_certificate_selector.h"
13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
14 #include "chrome/browser/tab_contents/infobar.h" 14 #include "chrome/browser/tab_contents/infobar.h"
15 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 15 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
17 #include "chrome/common/chrome_notification_types.h"
17 #include "content/browser/ssl/ssl_client_auth_handler.h" 18 #include "content/browser/ssl/ssl_client_auth_handler.h"
18 #include "content/common/notification_details.h" 19 #include "content/common/notification_details.h"
19 #include "content/common/notification_source.h" 20 #include "content/common/notification_source.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "grit/theme_resources_standard.h" 22 #include "grit/theme_resources_standard.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
25 26
26 namespace { 27 namespace {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Displays |delegate| as an infobar in |tab_|, replacing our current one if 108 // Displays |delegate| as an infobar in |tab_|, replacing our current one if
108 // still active. 109 // still active.
109 void ShowInfoBar(InfoBarDelegate* delegate); 110 void ShowInfoBar(InfoBarDelegate* delegate);
110 111
111 // Same as above, for the common case of wanting to show a simple alert 112 // Same as above, for the common case of wanting to show a simple alert
112 // message. 113 // message.
113 void ShowErrorInfoBar(const string16& message); 114 void ShowErrorInfoBar(const string16& message);
114 115
115 private: 116 private:
116 // NotificationObserver: 117 // NotificationObserver:
117 virtual void Observe(NotificationType type, 118 virtual void Observe(int type,
118 const NotificationSource& source, 119 const NotificationSource& source,
119 const NotificationDetails& details); 120 const NotificationDetails& details);
120 121
121 TabContentsWrapper* tab_contents_; 122 TabContentsWrapper* tab_contents_;
122 InfoBarDelegate* infobar_delegate_; 123 InfoBarDelegate* infobar_delegate_;
123 NotificationRegistrar registrar_; 124 NotificationRegistrar registrar_;
124 125
125 DISALLOW_COPY_AND_ASSIGN(SSLAddCertData); 126 DISALLOW_COPY_AND_ASSIGN(SSLAddCertData);
126 }; 127 };
127 128
128 TabContentsSSLHelper::SSLAddCertData::SSLAddCertData( 129 TabContentsSSLHelper::SSLAddCertData::SSLAddCertData(
129 TabContentsWrapper* tab_contents) 130 TabContentsWrapper* tab_contents)
130 : tab_contents_(tab_contents), 131 : tab_contents_(tab_contents),
131 infobar_delegate_(NULL) { 132 infobar_delegate_(NULL) {
132 Source<TabContentsWrapper> source(tab_contents_); 133 Source<TabContentsWrapper> source(tab_contents_);
133 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, source); 134 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
134 registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, source); 135 source);
136 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED,
137 source);
135 } 138 }
136 139
137 TabContentsSSLHelper::SSLAddCertData::~SSLAddCertData() { 140 TabContentsSSLHelper::SSLAddCertData::~SSLAddCertData() {
138 } 141 }
139 142
140 void TabContentsSSLHelper::SSLAddCertData::ShowInfoBar( 143 void TabContentsSSLHelper::SSLAddCertData::ShowInfoBar(
141 InfoBarDelegate* delegate) { 144 InfoBarDelegate* delegate) {
142 if (infobar_delegate_) 145 if (infobar_delegate_)
143 tab_contents_->ReplaceInfoBar(infobar_delegate_, delegate); 146 tab_contents_->ReplaceInfoBar(infobar_delegate_, delegate);
144 else 147 else
145 tab_contents_->AddInfoBar(delegate); 148 tab_contents_->AddInfoBar(delegate);
146 infobar_delegate_ = delegate; 149 infobar_delegate_ = delegate;
147 } 150 }
148 151
149 void TabContentsSSLHelper::SSLAddCertData::ShowErrorInfoBar( 152 void TabContentsSSLHelper::SSLAddCertData::ShowErrorInfoBar(
150 const string16& message) { 153 const string16& message) {
151 ShowInfoBar(new SimpleAlertInfoBarDelegate( 154 ShowInfoBar(new SimpleAlertInfoBarDelegate(
152 tab_contents_->tab_contents(), GetCertIcon(), message, true)); 155 tab_contents_->tab_contents(), GetCertIcon(), message, true));
153 } 156 }
154 157
155 void TabContentsSSLHelper::SSLAddCertData::Observe( 158 void TabContentsSSLHelper::SSLAddCertData::Observe(
156 NotificationType type, 159 int type,
157 const NotificationSource& source, 160 const NotificationSource& source,
158 const NotificationDetails& details) { 161 const NotificationDetails& details) {
159 DCHECK(type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED || 162 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED ||
160 type.value == NotificationType::TAB_CONTENTS_INFOBAR_REPLACED); 163 type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REPLACED);
161 if (infobar_delegate_ == 164 if (infobar_delegate_ ==
162 ((type.value == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) ? 165 ((type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED) ?
163 Details<InfoBarRemovedDetails>(details)->first : 166 Details<InfoBarRemovedDetails>(details)->first :
164 Details<InfoBarReplacedDetails>(details)->first)) 167 Details<InfoBarReplacedDetails>(details)->first))
165 infobar_delegate_ = NULL; 168 infobar_delegate_ = NULL;
166 } 169 }
167 170
168 171
169 // TabContentsSSLHelper ------------------------------------------------------- 172 // TabContentsSSLHelper -------------------------------------------------------
170 173
171 TabContentsSSLHelper::TabContentsSSLHelper(TabContentsWrapper* tab_contents) 174 TabContentsSSLHelper::TabContentsSSLHelper(TabContentsWrapper* tab_contents)
172 : tab_contents_(tab_contents) { 175 : tab_contents_(tab_contents) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( 228 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData(
226 SSLAddCertHandler* handler) { 229 SSLAddCertHandler* handler) {
227 // Find/create the slot. 230 // Find/create the slot.
228 linked_ptr<SSLAddCertData>& ptr_ref = 231 linked_ptr<SSLAddCertData>& ptr_ref =
229 request_id_to_add_cert_data_[handler->network_request_id()]; 232 request_id_to_add_cert_data_[handler->network_request_id()];
230 // Fill it if necessary. 233 // Fill it if necessary.
231 if (!ptr_ref.get()) 234 if (!ptr_ref.get())
232 ptr_ref.reset(new SSLAddCertData(tab_contents_)); 235 ptr_ref.reset(new SSLAddCertData(tab_contents_));
233 return ptr_ref.get(); 236 return ptr_ref.get();
234 } 237 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/popup_menu_helper_mac.mm ('k') | chrome/browser/tab_contents/tab_contents_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698