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

Side by Side Diff: content/browser/ssl/ssl_manager.cc

Issue 2400673003: Remove SSLStatus::security_style member and content::SecurityStyle (Closed)
Patch Set: more curly braces Created 4 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/ssl/ssl_manager.h" 5 #include "content/browser/ssl/ssl_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/supports_user_data.h" 13 #include "base/supports_user_data.h"
14 #include "content/browser/frame_host/navigation_entry_impl.h" 14 #include "content/browser/frame_host/navigation_entry_impl.h"
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" 15 #include "content/browser/loader/resource_dispatcher_host_impl.h"
16 #include "content/browser/loader/resource_request_info_impl.h" 16 #include "content/browser/loader/resource_request_info_impl.h"
17 #include "content/browser/ssl/ssl_error_handler.h" 17 #include "content/browser/ssl/ssl_error_handler.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/common/security_style_util.h"
20 #include "content/public/browser/browser_context.h" 19 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/certificate_request_result_type.h" 21 #include "content/public/browser/certificate_request_result_type.h"
23 #include "content/public/browser/content_browser_client.h" 22 #include "content/public/browser/content_browser_client.h"
24 #include "content/public/browser/navigation_details.h" 23 #include "content/public/browser/navigation_details.h"
25 #include "content/public/browser/ssl_host_state_delegate.h" 24 #include "content/public/browser/ssl_host_state_delegate.h"
26 #include "content/public/browser/ssl_status.h" 25 #include "content/public/browser/ssl_status.h"
27 #include "net/url_request/url_request.h" 26 #include "net/url_request/url_request.h"
28 27
29 namespace content { 28 namespace content {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 ssl_host_state_delegate_)); 335 ssl_host_state_delegate_));
337 } 336 }
338 337
339 void SSLManager::UpdateEntry(NavigationEntryImpl* entry) { 338 void SSLManager::UpdateEntry(NavigationEntryImpl* entry) {
340 // We don't always have a navigation entry to update, for example in the 339 // We don't always have a navigation entry to update, for example in the
341 // case of the Web Inspector. 340 // case of the Web Inspector.
342 if (!entry) 341 if (!entry)
343 return; 342 return;
344 343
345 SSLStatus original_ssl_status = entry->GetSSL(); // Copy! 344 SSLStatus original_ssl_status = entry->GetSSL(); // Copy!
346 345 entry->GetSSL().initialized = true;
347 // Initialize the entry with an initial SecurityStyle if needed.
348 if (entry->GetSSL().security_style == SECURITY_STYLE_UNKNOWN) {
349 entry->GetSSL().security_style = GetSecurityStyleForResource(
350 entry->GetURL(), !!entry->GetSSL().certificate,
351 entry->GetSSL().cert_status);
352 }
353 346
354 WebContentsImpl* web_contents_impl = 347 WebContentsImpl* web_contents_impl =
355 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 348 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
356 349
357 // For sensitive inputs (password, credit card) on HTTP, do not clear 350 // For sensitive inputs (password, credit card) on HTTP, do not clear
358 // the |content_status| flag when the WebContents no longer has the 351 // the |content_status| flag when the WebContents no longer has the
359 // flag set. This is different from how DISPLAYED_INSECURE_CONTENT and 352 // flag set. This is different from how DISPLAYED_INSECURE_CONTENT and
360 // DISPLAYED_CONTENT_WITH_CERT_ERRORS are handled below. For sensitive 353 // DISPLAYED_CONTENT_WITH_CERT_ERRORS are handled below. For sensitive
361 // inputs on HTTP, once the NavigationEntry has been marked as having 354 // inputs on HTTP, once the NavigationEntry has been marked as having
362 // displayed a sensitive input, it stays that way, even if the 355 // displayed a sensitive input, it stays that way, even if the
363 // sensitive input is subsequently removed from the page. 356 // sensitive input is subsequently removed from the page.
364 if (web_contents_impl->DisplayedPasswordFieldOnHttp()) { 357 if (web_contents_impl->DisplayedPasswordFieldOnHttp()) {
365 entry->GetSSL().content_status |= 358 entry->GetSSL().content_status |=
366 SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP; 359 SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP;
367 } 360 }
368 361
369 if (web_contents_impl->DisplayedCreditCardFieldOnHttp()) { 362 if (web_contents_impl->DisplayedCreditCardFieldOnHttp()) {
370 entry->GetSSL().content_status |= 363 entry->GetSSL().content_status |=
371 SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP; 364 SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP;
372 } 365 }
373 366
374 if (entry->GetSSL().security_style == SECURITY_STYLE_UNAUTHENTICATED) 367 // Do not record information about insecure subresources if the main
368 // page is HTTP or HTTPS without a certificate.
369 if (!entry->GetURL().SchemeIsCryptographic() || !entry->GetSSL().certificate)
375 return; 370 return;
376 371
377 // Update the entry's flags for insecure content. 372 // Update the entry's flags for insecure content.
378 if (!web_contents_impl->DisplayedInsecureContent()) 373 if (!web_contents_impl->DisplayedInsecureContent())
379 entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT; 374 entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT;
380 if (web_contents_impl->DisplayedInsecureContent()) 375 if (web_contents_impl->DisplayedInsecureContent())
381 entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT; 376 entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT;
382 if (!web_contents_impl->DisplayedContentWithCertErrors()) { 377 if (!web_contents_impl->DisplayedContentWithCertErrors()) {
383 entry->GetSSL().content_status &= 378 entry->GetSSL().content_status &=
384 ~SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS; 379 ~SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
385 } 380 }
386 if (web_contents_impl->DisplayedContentWithCertErrors()) { 381 if (web_contents_impl->DisplayedContentWithCertErrors()) {
387 entry->GetSSL().content_status |= 382 entry->GetSSL().content_status |=
388 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS; 383 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
389 } 384 }
390 385
391 SiteInstance* site_instance = entry->site_instance(); 386 SiteInstance* site_instance = entry->site_instance();
392 // Note that |site_instance| can be NULL here because NavigationEntries don't 387 // Note that |site_instance| can be NULL here because NavigationEntries don't
393 // necessarily have site instances. Without a process, the entry can't 388 // necessarily have site instances. Without a process, the entry can't
394 // possibly have insecure content. See bug http://crbug.com/12423. 389 // possibly have insecure content. See bug http://crbug.com/12423.
395 if (site_instance && ssl_host_state_delegate_ && 390 if (site_instance && ssl_host_state_delegate_ &&
396 ssl_host_state_delegate_->DidHostRunInsecureContent( 391 ssl_host_state_delegate_->DidHostRunInsecureContent(
397 entry->GetURL().host(), site_instance->GetProcess()->GetID(), 392 entry->GetURL().host(), site_instance->GetProcess()->GetID(),
398 SSLHostStateDelegate::MIXED_CONTENT)) { 393 SSLHostStateDelegate::MIXED_CONTENT)) {
399 entry->GetSSL().security_style = SECURITY_STYLE_AUTHENTICATION_BROKEN;
400 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; 394 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT;
401 } 395 }
402 396
403 if (site_instance && ssl_host_state_delegate_ && 397 if (site_instance && ssl_host_state_delegate_ &&
404 ssl_host_state_delegate_->DidHostRunInsecureContent( 398 ssl_host_state_delegate_->DidHostRunInsecureContent(
405 entry->GetURL().host(), site_instance->GetProcess()->GetID(), 399 entry->GetURL().host(), site_instance->GetProcess()->GetID(),
406 SSLHostStateDelegate::CERT_ERRORS_CONTENT)) { 400 SSLHostStateDelegate::CERT_ERRORS_CONTENT)) {
407 entry->GetSSL().security_style = SECURITY_STYLE_AUTHENTICATION_BROKEN;
408 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS; 401 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
409 } 402 }
410 403
411 if (!entry->GetSSL().Equals(original_ssl_status)) 404 if (!entry->GetSSL().Equals(original_ssl_status))
412 NotifyDidChangeVisibleSSLState(); 405 NotifyDidChangeVisibleSSLState();
413 } 406 }
414 407
415 void SSLManager::NotifyDidChangeVisibleSSLState() { 408 void SSLManager::NotifyDidChangeVisibleSSLState() {
416 WebContentsImpl* contents = 409 WebContentsImpl* contents =
417 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 410 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
418 contents->DidChangeVisibleSSLState(); 411 contents->DidChangeVisibleSSLState();
419 } 412 }
420 413
421 } // namespace content 414 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.cc ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698