OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 return "XMLHttpRequest endpoint"; | 133 return "XMLHttpRequest endpoint"; |
134 case WebURLRequest::kRequestContextXSLT: | 134 case WebURLRequest::kRequestContextXSLT: |
135 return "XSLT"; | 135 return "XSLT"; |
136 } | 136 } |
137 NOTREACHED(); | 137 NOTREACHED(); |
138 return "resource"; | 138 return "resource"; |
139 } | 139 } |
140 | 140 |
141 } // namespace | 141 } // namespace |
142 | 142 |
143 static void MeasureStricterVersionOfIsMixedContent(Frame* frame, | 143 static void MeasureStricterVersionOfIsMixedContent(Frame& frame, |
144 const KURL& url) { | 144 const KURL& url) { |
145 // We're currently only checking for mixed content in `https://*` contexts. | 145 // We're currently only checking for mixed content in `https://*` contexts. |
146 // What about other "secure" contexts the SchemeRegistry knows about? We'll | 146 // What about other "secure" contexts the SchemeRegistry knows about? We'll |
147 // use this method to measure the occurrence of non-webby mixed content to | 147 // use this method to measure the occurrence of non-webby mixed content to |
148 // make sure we're not breaking the world without realizing it. | 148 // make sure we're not breaking the world without realizing it. |
149 SecurityOrigin* origin = frame->GetSecurityContext()->GetSecurityOrigin(); | 149 SecurityOrigin* origin = frame.GetSecurityContext()->GetSecurityOrigin(); |
150 if (MixedContentChecker::IsMixedContent(origin, url)) { | 150 if (MixedContentChecker::IsMixedContent(origin, url)) { |
151 if (origin->Protocol() != "https") { | 151 if (origin->Protocol() != "https") { |
152 UseCounter::Count( | 152 UseCounter::Count( |
153 frame, | 153 &frame, |
154 UseCounter::kMixedContentInNonHTTPSFrameThatRestrictsMixedContent); | 154 UseCounter::kMixedContentInNonHTTPSFrameThatRestrictsMixedContent); |
155 } | 155 } |
156 } else if (!SecurityOrigin::IsSecure(url) && | 156 } else if (!SecurityOrigin::IsSecure(url) && |
157 SchemeRegistry::ShouldTreatURLSchemeAsSecure(origin->Protocol())) { | 157 SchemeRegistry::ShouldTreatURLSchemeAsSecure(origin->Protocol())) { |
158 UseCounter::Count( | 158 UseCounter::Count( |
159 frame, | 159 &frame, |
160 UseCounter::kMixedContentInSecureFrameThatDoesNotRestrictMixedContent); | 160 UseCounter::kMixedContentInSecureFrameThatDoesNotRestrictMixedContent); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 bool RequestIsSubframeSubresource(Frame* frame, | 164 bool RequestIsSubframeSubresource(Frame* frame, |
165 WebURLRequest::FrameType frame_type) { | 165 WebURLRequest::FrameType frame_type) { |
166 return (frame && frame != frame->Tree().Top() && | 166 return (frame && frame != frame->Tree().Top() && |
167 frame_type != WebURLRequest::kFrameTypeNested); | 167 frame_type != WebURLRequest::kFrameTypeNested); |
168 } | 168 } |
169 | 169 |
(...skipping 25 matching lines...) Expand all Loading... |
195 Frame* MixedContentChecker::InWhichFrameIsContentMixed( | 195 Frame* MixedContentChecker::InWhichFrameIsContentMixed( |
196 Frame* frame, | 196 Frame* frame, |
197 WebURLRequest::FrameType frame_type, | 197 WebURLRequest::FrameType frame_type, |
198 const KURL& url) { | 198 const KURL& url) { |
199 // We only care about subresource loads; top-level navigations cannot be mixed | 199 // We only care about subresource loads; top-level navigations cannot be mixed |
200 // content. Neither can frameless requests. | 200 // content. Neither can frameless requests. |
201 if (frame_type == WebURLRequest::kFrameTypeTopLevel || !frame) | 201 if (frame_type == WebURLRequest::kFrameTypeTopLevel || !frame) |
202 return nullptr; | 202 return nullptr; |
203 | 203 |
204 // Check the top frame first. | 204 // Check the top frame first. |
205 if (Frame* top = frame->Tree().Top()) { | 205 Frame& top = frame->Tree().Top(); |
206 MeasureStricterVersionOfIsMixedContent(top, url); | 206 MeasureStricterVersionOfIsMixedContent(top, url); |
207 if (IsMixedContent(top->GetSecurityContext()->GetSecurityOrigin(), url)) | 207 if (IsMixedContent(top.GetSecurityContext()->GetSecurityOrigin(), url)) |
208 return top; | 208 return ⊤ |
209 } | |
210 | 209 |
211 MeasureStricterVersionOfIsMixedContent(frame, url); | 210 MeasureStricterVersionOfIsMixedContent(*frame, url); |
212 if (IsMixedContent(frame->GetSecurityContext()->GetSecurityOrigin(), url)) | 211 if (IsMixedContent(frame->GetSecurityContext()->GetSecurityOrigin(), url)) |
213 return frame; | 212 return frame; |
214 | 213 |
215 // No mixed content, no problem. | 214 // No mixed content, no problem. |
216 return nullptr; | 215 return nullptr; |
217 } | 216 } |
218 | 217 |
219 // static | 218 // static |
220 void MixedContentChecker::LogToConsoleAboutFetch( | 219 void MixedContentChecker::LogToConsoleAboutFetch( |
221 LocalFrame* frame, | 220 LocalFrame* frame, |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 } | 632 } |
634 | 633 |
635 bool strict_mixed_content_checking_for_plugin = | 634 bool strict_mixed_content_checking_for_plugin = |
636 mixed_frame->GetSettings() && | 635 mixed_frame->GetSettings() && |
637 mixed_frame->GetSettings()->GetStrictMixedContentCheckingForPlugin(); | 636 mixed_frame->GetSettings()->GetStrictMixedContentCheckingForPlugin(); |
638 return WebMixedContent::ContextTypeFromRequestContext( | 637 return WebMixedContent::ContextTypeFromRequestContext( |
639 request.GetRequestContext(), strict_mixed_content_checking_for_plugin); | 638 request.GetRequestContext(), strict_mixed_content_checking_for_plugin); |
640 } | 639 } |
641 | 640 |
642 } // namespace blink | 641 } // namespace blink |
OLD | NEW |