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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 : m_frame(frame) | 45 : m_frame(frame) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 FrameLoaderClient* MixedContentChecker::client() const | 49 FrameLoaderClient* MixedContentChecker::client() const |
50 { | 50 { |
51 return m_frame->loader().client(); | 51 return m_frame->loader().client(); |
52 } | 52 } |
53 | 53 |
54 // static | 54 // static |
55 bool MixedContentChecker::isMixedRealm(SecurityOrigin* securityOrigin, const KUR L& url) | |
56 { | |
57 if (RuntimeEnabledFeatures::laxMixedContentCheckingEnabled()) | |
58 return false; | |
59 | |
60 if (securityOrigin->isReservedIPAddress()) | |
61 return false; // We only care about public origins. | |
62 | |
63 return SecurityOrigin::create(url)->isReservedIPAddress(); | |
abarth-chromium
2014/08/01 18:09:45
Why do we need to create a SecurityOrigin just to
Mike West
2014/08/02 15:21:46
I can skip SecurityOrigin entirely and just call t
| |
64 } | |
65 | |
66 // static | |
55 bool MixedContentChecker::isMixedContent(SecurityOrigin* securityOrigin, const K URL& url) | 67 bool MixedContentChecker::isMixedContent(SecurityOrigin* securityOrigin, const K URL& url) |
56 { | 68 { |
57 if (securityOrigin->protocol() != "https") | 69 if (securityOrigin->protocol() != "https") |
58 return false; // We only care about HTTPS security origins. | 70 return false; // We only care about HTTPS security origins. |
59 | 71 |
60 // We're in a secure context, so |url| is mixed content if it's insecure. | 72 // We're in a secure context, so |url| is mixed content if it's insecure. |
61 return !SecurityOrigin::isSecure(url); | 73 return !SecurityOrigin::isSecure(url); |
62 } | 74 } |
63 | 75 |
64 bool MixedContentChecker::canDisplayInsecureContentInternal(SecurityOrigin* secu rityOrigin, const KURL& url, const MixedContentType type) const | 76 bool MixedContentChecker::canDisplayInsecureContentInternal(SecurityOrigin* secu rityOrigin, const KURL& url, const MixedContentType type) const |
65 { | 77 { |
66 // Check the top frame if it differs from MixedContentChecker's m_frame. | 78 // Check the top frame if it differs from MixedContentChecker's m_frame. |
67 if (!m_frame->tree().top()->isLocalFrame()) { | 79 if (!m_frame->tree().top()->isLocalFrame()) { |
68 // FIXME: We need a way to access the top-level frame's MixedContentChec ker when that frame | 80 // FIXME: We need a way to access the top-level frame's MixedContentChec ker when that frame |
69 // is in a different process from the current frame. Until that is done, we always allow | 81 // is in a different process from the current frame. Until that is done, we always allow |
70 // loads in remote frames. | 82 // loads in remote frames. |
71 return false; | 83 return false; |
72 } | 84 } |
73 Frame* top = m_frame->tree().top(); | 85 Frame* top = m_frame->tree().top(); |
74 if (top != m_frame && !toLocalFrame(top)->loader().mixedContentChecker()->ca nDisplayInsecureContent(toLocalFrame(top)->document()->securityOrigin(), url)) | 86 if (top != m_frame && !toLocalFrame(top)->loader().mixedContentChecker()->ca nDisplayInsecureContent(toLocalFrame(top)->document()->securityOrigin(), url)) |
75 return false; | 87 return false; |
76 | 88 |
77 // Then check the current frame: | 89 // Then check the current frame: |
78 if (!isMixedContent(securityOrigin, url)) | 90 if (!isMixedRealm(securityOrigin, url) && !isMixedContent(securityOrigin, ur l)) |
79 return true; | 91 return true; |
80 | 92 |
81 Settings* settings = m_frame->settings(); | 93 Settings* settings = m_frame->settings(); |
82 bool allowed = client()->allowDisplayingInsecureContent(settings && settings ->allowDisplayOfInsecureContent(), securityOrigin, url); | 94 bool allowed = client()->allowDisplayingInsecureContent(settings && settings ->allowDisplayOfInsecureContent(), securityOrigin, url); |
83 logWarning(allowed, url, type); | 95 logWarning(allowed, url, type); |
84 | 96 |
85 if (allowed) | 97 if (allowed) |
86 client()->didDisplayInsecureContent(); | 98 client()->didDisplayInsecureContent(); |
87 | 99 |
88 return allowed; | 100 return allowed; |
89 } | 101 } |
90 | 102 |
91 bool MixedContentChecker::canRunInsecureContentInternal(SecurityOrigin* security Origin, const KURL& url, const MixedContentType type) const | 103 bool MixedContentChecker::canRunInsecureContentInternal(SecurityOrigin* security Origin, const KURL& url, const MixedContentType type) const |
92 { | 104 { |
93 // Check the top frame if it differs from MixedContentChecker's m_frame. | 105 // Check the top frame if it differs from MixedContentChecker's m_frame. |
94 if (!m_frame->tree().top()->isLocalFrame()) { | 106 if (!m_frame->tree().top()->isLocalFrame()) { |
95 // FIXME: We need a way to access the top-level frame's MixedContentChec ker when that frame | 107 // FIXME: We need a way to access the top-level frame's MixedContentChec ker when that frame |
96 // is in a different process from the current frame. Until that is done, we always allow | 108 // is in a different process from the current frame. Until that is done, we always allow |
97 // loads in remote frames. | 109 // loads in remote frames. |
98 return false; | 110 return false; |
99 } | 111 } |
100 Frame* top = m_frame->tree().top(); | 112 Frame* top = m_frame->tree().top(); |
101 if (top != m_frame && !toLocalFrame(top)->loader().mixedContentChecker()->ca nRunInsecureContent(toLocalFrame(top)->document()->securityOrigin(), url)) | 113 if (top != m_frame && !toLocalFrame(top)->loader().mixedContentChecker()->ca nRunInsecureContent(toLocalFrame(top)->document()->securityOrigin(), url)) |
102 return false; | 114 return false; |
103 | 115 |
104 // Then check the current frame: | 116 // Then check the current frame: |
105 if (!isMixedContent(securityOrigin, url)) | 117 if (!isMixedRealm(securityOrigin, url) && !isMixedContent(securityOrigin, ur l)) |
106 return true; | 118 return true; |
107 | 119 |
108 Settings* settings = m_frame->settings(); | 120 Settings* settings = m_frame->settings(); |
109 bool allowedPerSettings = settings && (settings->allowRunningOfInsecureConte nt() || ((type == WebSocket) && settings->allowConnectingInsecureWebSocket())); | 121 bool allowedPerSettings = settings && (settings->allowRunningOfInsecureConte nt() || ((type == WebSocket) && settings->allowConnectingInsecureWebSocket())); |
110 bool allowed = client()->allowRunningInsecureContent(allowedPerSettings, sec urityOrigin, url); | 122 bool allowed = client()->allowRunningInsecureContent(allowedPerSettings, sec urityOrigin, url); |
111 logWarning(allowed, url, type); | 123 logWarning(allowed, url, type); |
112 | 124 |
113 if (allowed) | 125 if (allowed) |
114 client()->didRunInsecureContent(securityOrigin, url); | 126 client()->didRunInsecureContent(securityOrigin, url); |
115 | 127 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 break; | 176 break; |
165 case Submission: | 177 case Submission: |
166 message.append("is submitting data to an insecure location at '" + targe t.elidedString() + "': this content should also be submitted over HTTPS.\n"); | 178 message.append("is submitting data to an insecure location at '" + targe t.elidedString() + "': this content should also be submitted over HTTPS.\n"); |
167 break; | 179 break; |
168 } | 180 } |
169 MessageLevel messageLevel = allowed ? WarningMessageLevel : ErrorMessageLeve l; | 181 MessageLevel messageLevel = allowed ? WarningMessageLevel : ErrorMessageLeve l; |
170 m_frame->document()->addConsoleMessage(SecurityMessageSource, messageLevel, message.toString()); | 182 m_frame->document()->addConsoleMessage(SecurityMessageSource, messageLevel, message.toString()); |
171 } | 183 } |
172 | 184 |
173 } // namespace blink | 185 } // namespace blink |
OLD | NEW |