Chromium Code Reviews| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 return (frame && frame != frame->tree().top() && frameType != WebURLRequest: :FrameTypeNested); | 82 return (frame && frame != frame->tree().top() && frameType != WebURLRequest: :FrameTypeNested); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // static | 85 // static |
| 86 bool MixedContentChecker::isMixedContent(SecurityOrigin* securityOrigin, const K URL& url) | 86 bool MixedContentChecker::isMixedContent(SecurityOrigin* securityOrigin, const K URL& url) |
| 87 { | 87 { |
| 88 if (!SchemeRegistry::shouldTreatURLSchemeAsRestrictingMixedContent(securityO rigin->protocol())) | 88 if (!SchemeRegistry::shouldTreatURLSchemeAsRestrictingMixedContent(securityO rigin->protocol())) |
| 89 return false; | 89 return false; |
| 90 | 90 |
| 91 // |url| is mixed content if its origin is not potentially trustworthy, and | 91 // |url| is mixed content if its origin is not potentially trustworthy, and |
| 92 // its protocol is not 'data'. | 92 // its protocol is not 'data'. We do a quick check against `SecurityOrigin:: isSecure` |
| 93 bool isAllowed = url.protocolIsData() || SecurityOrigin::create(url)->isPote ntiallyTrustworthy(); | 93 // to catch things like `about:blank`, which cannot be sanely passed into |
| 94 // `SecurityOrigin::create` (as their origin depends on their context). | |
| 95 bool isAllowed = url.protocolIsData() || SecurityOrigin::isSecure(url) || Se curityOrigin::create(url)->isPotentiallyTrustworthy(); | |
| 94 // TODO(mkwst): Remove this once 'localhost' is no longer considered potenti ally trustworthy: | 96 // TODO(mkwst): Remove this once 'localhost' is no longer considered potenti ally trustworthy: |
| 95 if (isAllowed && url.protocolIs("http") && url.host() == "localhost") | 97 if (isAllowed && url.protocolIs("http") && url.host() == "localhost") |
|
Yoav Weiss
2016/07/04 09:02:36
unrelated to current change, but IIUC "127.0.0.1"
| |
| 96 isAllowed = false; | 98 isAllowed = false; |
| 97 return !isAllowed; | 99 return !isAllowed; |
| 98 } | 100 } |
| 99 | 101 |
| 100 // static | 102 // static |
| 101 Frame* MixedContentChecker::inWhichFrameIsContentMixed(Frame* frame, WebURLReque st::FrameType frameType, const KURL& url) | 103 Frame* MixedContentChecker::inWhichFrameIsContentMixed(Frame* frame, WebURLReque st::FrameType frameType, const KURL& url) |
| 102 { | 104 { |
| 103 // We only care about subresource loads; top-level navigations cannot be mix ed content. Neither can frameless requests. | 105 // We only care about subresource loads; top-level navigations cannot be mix ed content. Neither can frameless requests. |
| 104 if (frameType == WebURLRequest::FrameTypeTopLevel || !frame) | 106 if (frameType == WebURLRequest::FrameTypeTopLevel || !frame) |
| 105 return nullptr; | 107 return nullptr; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 // See comment in shouldBlockFetch() about loading the main resource of a su bframe. | 392 // See comment in shouldBlockFetch() about loading the main resource of a su bframe. |
| 391 if (request.frameType() == WebURLRequest::FrameTypeNested && !SchemeRegistry ::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())) { | 393 if (request.frameType() == WebURLRequest::FrameTypeNested && !SchemeRegistry ::shouldTreatURLSchemeAsCORSEnabled(request.url().protocol())) { |
| 392 return WebMixedContent::ContextType::OptionallyBlockable; | 394 return WebMixedContent::ContextType::OptionallyBlockable; |
| 393 } | 395 } |
| 394 | 396 |
| 395 bool strictMixedContentCheckingForPlugin = mixedFrame->settings() && mixedFr ame->settings()->strictMixedContentCheckingForPlugin(); | 397 bool strictMixedContentCheckingForPlugin = mixedFrame->settings() && mixedFr ame->settings()->strictMixedContentCheckingForPlugin(); |
| 396 return WebMixedContent::contextTypeFromRequestContext(request.requestContext (), strictMixedContentCheckingForPlugin); | 398 return WebMixedContent::contextTypeFromRequestContext(request.requestContext (), strictMixedContentCheckingForPlugin); |
| 397 } | 399 } |
| 398 | 400 |
| 399 } // namespace blink | 401 } // namespace blink |
| OLD | NEW |