| OLD | NEW |
| 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 "content/browser/ssl/ssl_policy.h" | 5 #include "content/browser/ssl/ssl_policy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "content/browser/renderer_host/render_process_host.h" | 13 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 14 #include "content/browser/renderer_host/render_view_host.h" | 14 #include "content/browser/renderer_host/render_view_host.h" |
| 15 #include "content/browser/site_instance.h" | 15 #include "content/browser/site_instance.h" |
| 16 #include "content/browser/ssl/ssl_cert_error_handler.h" | 16 #include "content/browser/ssl/ssl_cert_error_handler.h" |
| 17 #include "content/browser/ssl/ssl_request_info.h" | 17 #include "content/browser/ssl/ssl_request_info.h" |
| 18 #include "content/browser/tab_contents/navigation_entry.h" | 18 #include "content/browser/tab_contents/navigation_entry.h" |
| 19 #include "content/browser/tab_contents/tab_contents.h" | 19 #include "content/browser/tab_contents/tab_contents.h" |
| 20 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/common/url_constants.h" | 21 #include "content/public/common/url_constants.h" |
| 22 #include "net/base/cert_status_flags.h" | 22 #include "net/base/cert_status_flags.h" |
| 23 #include "net/base/ssl_info.h" | 23 #include "net/base/ssl_info.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void SSLPolicy::DidRunInsecureContent(NavigationEntry* entry, | 86 void SSLPolicy::DidRunInsecureContent(NavigationEntry* entry, |
| 87 const std::string& security_origin) { | 87 const std::string& security_origin) { |
| 88 if (!entry) | 88 if (!entry) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 SiteInstance* site_instance = entry->site_instance(); | 91 SiteInstance* site_instance = entry->site_instance(); |
| 92 if (!site_instance) | 92 if (!site_instance) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 backend_->HostRanInsecureContent(GURL(security_origin).host(), | 95 backend_->HostRanInsecureContent(GURL(security_origin).host(), |
| 96 site_instance->GetProcess()->id()); | 96 site_instance->GetProcess()->GetID()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { | 99 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { |
| 100 // TODO(abarth): This mechanism is wrong. What we should be doing is sending | 100 // TODO(abarth): This mechanism is wrong. What we should be doing is sending |
| 101 // this information back through WebKit and out some FrameLoaderClient | 101 // this information back through WebKit and out some FrameLoaderClient |
| 102 // methods. | 102 // methods. |
| 103 | 103 |
| 104 if (net::IsCertStatusError(info->ssl_cert_status())) | 104 if (net::IsCertStatusError(info->ssl_cert_status())) |
| 105 backend_->HostRanInsecureContent(info->url().host(), info->child_id()); | 105 backend_->HostRanInsecureContent(info->url().host(), info->child_id()); |
| 106 } | 106 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 content::SECURITY_STYLE_AUTHENTICATION_BROKEN); | 138 content::SECURITY_STYLE_AUTHENTICATION_BROKEN); |
| 139 } | 139 } |
| 140 return; | 140 return; |
| 141 } | 141 } |
| 142 | 142 |
| 143 SiteInstance* site_instance = entry->site_instance(); | 143 SiteInstance* site_instance = entry->site_instance(); |
| 144 // Note that |site_instance| can be NULL here because NavigationEntries don't | 144 // Note that |site_instance| can be NULL here because NavigationEntries don't |
| 145 // necessarily have site instances. Without a process, the entry can't | 145 // necessarily have site instances. Without a process, the entry can't |
| 146 // possibly have insecure content. See bug http://crbug.com/12423. | 146 // possibly have insecure content. See bug http://crbug.com/12423. |
| 147 if (site_instance && | 147 if (site_instance && |
| 148 backend_->DidHostRunInsecureContent(entry->url().host(), | 148 backend_->DidHostRunInsecureContent( |
| 149 site_instance->GetProcess()->id())) { | 149 entry->url().host(), site_instance->GetProcess()->GetID())) { |
| 150 entry->ssl().set_security_style( | 150 entry->ssl().set_security_style( |
| 151 content::SECURITY_STYLE_AUTHENTICATION_BROKEN); | 151 content::SECURITY_STYLE_AUTHENTICATION_BROKEN); |
| 152 entry->ssl().set_ran_insecure_content(); | 152 entry->ssl().set_ran_insecure_content(); |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 | 155 |
| 156 if (tab_contents->displayed_insecure_content()) | 156 if (tab_contents->displayed_insecure_content()) |
| 157 entry->ssl().set_displayed_insecure_content(); | 157 entry->ssl().set_displayed_insecure_content(); |
| 158 } | 158 } |
| 159 | 159 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 entry->ssl().set_security_style(entry->url().SchemeIsSecure() ? | 211 entry->ssl().set_security_style(entry->url().SchemeIsSecure() ? |
| 212 content::SECURITY_STYLE_AUTHENTICATED : | 212 content::SECURITY_STYLE_AUTHENTICATED : |
| 213 content::SECURITY_STYLE_UNAUTHENTICATED); | 213 content::SECURITY_STYLE_UNAUTHENTICATED); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { | 216 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { |
| 217 GURL parsed_origin(origin); | 217 GURL parsed_origin(origin); |
| 218 if (parsed_origin.SchemeIsSecure()) | 218 if (parsed_origin.SchemeIsSecure()) |
| 219 backend_->HostRanInsecureContent(parsed_origin.host(), pid); | 219 backend_->HostRanInsecureContent(parsed_origin.host(), pid); |
| 220 } | 220 } |
| OLD | NEW |