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_impl.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_impl.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_impl.h" | 18 #include "content/browser/tab_contents/navigation_entry_impl.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/browser/ssl_status.h" | 21 #include "content/public/browser/ssl_status.h" |
22 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
23 #include "net/base/cert_status_flags.h" | 23 #include "net/base/cert_status_flags.h" |
24 #include "net/base/ssl_info.h" | 24 #include "net/base/ssl_info.h" |
25 #include "webkit/glue/resource_type.h" | 25 #include "webkit/glue/resource_type.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 handler->CancelRequest(); | 85 handler->CancelRequest(); |
86 break; | 86 break; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 void SSLPolicy::DidRunInsecureContent(NavigationEntryImpl* entry, | 90 void SSLPolicy::DidRunInsecureContent(NavigationEntryImpl* entry, |
91 const std::string& security_origin) { | 91 const std::string& security_origin) { |
92 if (!entry) | 92 if (!entry) |
93 return; | 93 return; |
94 | 94 |
95 SiteInstance* site_instance = entry->site_instance(); | 95 content::SiteInstance* site_instance = entry->site_instance(); |
96 if (!site_instance) | 96 if (!site_instance) |
97 return; | 97 return; |
98 | 98 |
99 backend_->HostRanInsecureContent(GURL(security_origin).host(), | 99 backend_->HostRanInsecureContent(GURL(security_origin).host(), |
100 site_instance->GetProcess()->GetID()); | 100 site_instance->GetProcess()->GetID()); |
101 } | 101 } |
102 | 102 |
103 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { | 103 void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) { |
104 // TODO(abarth): This mechanism is wrong. What we should be doing is sending | 104 // TODO(abarth): This mechanism is wrong. What we should be doing is sending |
105 // this information back through WebKit and out some FrameLoaderClient | 105 // this information back through WebKit and out some FrameLoaderClient |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (net::IsCertStatusError(entry->GetSSL().cert_status)) { | 137 if (net::IsCertStatusError(entry->GetSSL().cert_status)) { |
138 // Minor errors don't lower the security style to | 138 // Minor errors don't lower the security style to |
139 // SECURITY_STYLE_AUTHENTICATION_BROKEN. | 139 // SECURITY_STYLE_AUTHENTICATION_BROKEN. |
140 if (!net::IsCertStatusMinorError(entry->GetSSL().cert_status)) { | 140 if (!net::IsCertStatusMinorError(entry->GetSSL().cert_status)) { |
141 entry->GetSSL().security_style = | 141 entry->GetSSL().security_style = |
142 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 142 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
143 } | 143 } |
144 return; | 144 return; |
145 } | 145 } |
146 | 146 |
147 SiteInstance* site_instance = entry->site_instance(); | 147 content::SiteInstance* site_instance = entry->site_instance(); |
148 // Note that |site_instance| can be NULL here because NavigationEntries don't | 148 // Note that |site_instance| can be NULL here because NavigationEntries don't |
149 // necessarily have site instances. Without a process, the entry can't | 149 // necessarily have site instances. Without a process, the entry can't |
150 // possibly have insecure content. See bug http://crbug.com/12423. | 150 // possibly have insecure content. See bug http://crbug.com/12423. |
151 if (site_instance && | 151 if (site_instance && |
152 backend_->DidHostRunInsecureContent( | 152 backend_->DidHostRunInsecureContent( |
153 entry->GetURL().host(), site_instance->GetProcess()->GetID())) { | 153 entry->GetURL().host(), site_instance->GetProcess()->GetID())) { |
154 entry->GetSSL().security_style = | 154 entry->GetSSL().security_style = |
155 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 155 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
156 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; | 156 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; |
157 return; | 157 return; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 entry->GetSSL().security_style = entry->GetURL().SchemeIsSecure() ? | 215 entry->GetSSL().security_style = entry->GetURL().SchemeIsSecure() ? |
216 content::SECURITY_STYLE_AUTHENTICATED : | 216 content::SECURITY_STYLE_AUTHENTICATED : |
217 content::SECURITY_STYLE_UNAUTHENTICATED; | 217 content::SECURITY_STYLE_UNAUTHENTICATED; |
218 } | 218 } |
219 | 219 |
220 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { | 220 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { |
221 GURL parsed_origin(origin); | 221 GURL parsed_origin(origin); |
222 if (parsed_origin.SchemeIsSecure()) | 222 if (parsed_origin.SchemeIsSecure()) |
223 backend_->HostRanInsecureContent(parsed_origin.host(), pid); | 223 backend_->HostRanInsecureContent(parsed_origin.host(), pid); |
224 } | 224 } |
OLD | NEW |