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

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

Issue 7828022: Add a method to the HostContentSettings map to return the |Value| of a content setting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update example value of AutoSelectCertificate policy in policy_template.json Created 9 years, 3 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 <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h"
13 #include "chrome/browser/certificate_viewer.h" 14 #include "chrome/browser/certificate_viewer.h"
14 #include "chrome/browser/content_settings/host_content_settings_map.h" 15 #include "chrome/browser/content_settings/host_content_settings_map.h"
15 #include "chrome/browser/infobars/infobar_tab_helper.h" 16 #include "chrome/browser/infobars/infobar_tab_helper.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ssl/ssl_add_cert_handler.h" 18 #include "chrome/browser/ssl/ssl_add_cert_handler.h"
18 #include "chrome/browser/ssl_client_certificate_selector.h" 19 #include "chrome/browser/ssl_client_certificate_selector.h"
19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
20 #include "chrome/browser/tab_contents/infobar.h" 21 #include "chrome/browser/tab_contents/infobar.h"
21 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 22 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
23 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
25 #include "chrome/common/content_settings.h"
26 #include "content/browser/ssl/ssl_client_auth_handler.h" 26 #include "content/browser/ssl/ssl_client_auth_handler.h"
27 #include "content/common/notification_details.h" 27 #include "content/common/notification_details.h"
28 #include "content/common/notification_source.h" 28 #include "content/common/notification_source.h"
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 #include "grit/theme_resources_standard.h" 30 #include "grit/theme_resources_standard.h"
31 #include "net/base/net_errors.h" 31 #include "net/base/net_errors.h"
32 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 34
35 namespace { 35 namespace {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 189
190 void TabContentsSSLHelper::SelectClientCertificate( 190 void TabContentsSSLHelper::SelectClientCertificate(
191 scoped_refptr<SSLClientAuthHandler> handler) { 191 scoped_refptr<SSLClientAuthHandler> handler) {
192 net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info(); 192 net::SSLCertRequestInfo* cert_request_info = handler->cert_request_info();
193 GURL requesting_url("https://" + cert_request_info->host_and_port); 193 GURL requesting_url("https://" + cert_request_info->host_and_port);
194 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://" 194 DCHECK(requesting_url.is_valid()) << "Invalid URL string: https://"
195 << cert_request_info->host_and_port; 195 << cert_request_info->host_and_port;
196 196
197 HostContentSettingsMap* map = 197 HostContentSettingsMap* map =
198 tab_contents_->profile()->GetHostContentSettingsMap(); 198 tab_contents_->profile()->GetHostContentSettingsMap();
199 ContentSetting setting = map->GetContentSetting( 199 scoped_ptr<Value> cert_filter(map->GetContentSettingValue(
200 requesting_url, 200 requesting_url,
201 requesting_url, 201 requesting_url,
202 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, 202 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE,
203 std::string()); 203 std::string()));
204 DCHECK_NE(setting, CONTENT_SETTING_DEFAULT);
205 204
206 // TODO(markusheintz): Implement filter for matching specific certificate 205 // TODO(markusheintz): Implement filter for matching specific certificate
207 // criteria. 206 // criteria.
208 bool cert_matches_filter = true; 207 // A non NULL |cert_filter| is equvivalent to "allow certificate-auto-submit".
209 208 // If NULL is returned then the dialog to select a client certificate is
210 if (setting == CONTENT_SETTING_ALLOW && 209 // displayed.
211 cert_request_info->client_certs.size() == 1 && 210 if (cert_filter.get() &&
212 cert_matches_filter) { 211 cert_request_info->client_certs.size() == 1) {
213 net::X509Certificate* cert = cert_request_info->client_certs[0].get(); 212 net::X509Certificate* cert = cert_request_info->client_certs[0].get();
214 handler->CertificateSelected(cert); 213 handler->CertificateSelected(cert);
215 } else { 214 } else {
216 ShowClientCertificateRequestDialog(handler); 215 ShowClientCertificateRequestDialog(handler);
217 } 216 }
218 } 217 }
219 218
220 void TabContentsSSLHelper::ShowClientCertificateRequestDialog( 219 void TabContentsSSLHelper::ShowClientCertificateRequestDialog(
221 scoped_refptr<SSLClientAuthHandler> handler) { 220 scoped_refptr<SSLClientAuthHandler> handler) {
222 browser::ShowSSLClientCertificateSelector( 221 browser::ShowSSLClientCertificateSelector(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData( 266 TabContentsSSLHelper::SSLAddCertData* TabContentsSSLHelper::GetAddCertData(
268 SSLAddCertHandler* handler) { 267 SSLAddCertHandler* handler) {
269 // Find/create the slot. 268 // Find/create the slot.
270 linked_ptr<SSLAddCertData>& ptr_ref = 269 linked_ptr<SSLAddCertData>& ptr_ref =
271 request_id_to_add_cert_data_[handler->network_request_id()]; 270 request_id_to_add_cert_data_[handler->network_request_id()];
272 // Fill it if necessary. 271 // Fill it if necessary.
273 if (!ptr_ref.get()) 272 if (!ptr_ref.get())
274 ptr_ref.reset(new SSLAddCertData(tab_contents_)); 273 ptr_ref.reset(new SSLAddCertData(tab_contents_));
275 return ptr_ref.get(); 274 return ptr_ref.get();
276 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698