| 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef MixedContentChecker_h | 31 #ifndef MixedContentChecker_h |
| 32 #define MixedContentChecker_h | 32 #define MixedContentChecker_h |
| 33 | 33 |
| 34 #include "base/gtest_prod_util.h" | 34 #include "base/gtest_prod_util.h" |
| 35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
| 36 #include "platform/heap/Handle.h" | 36 #include "platform/heap/Handle.h" |
| 37 #include "platform/network/ResourceRequest.h" | 37 #include "platform/network/ResourceRequest.h" |
| 38 #include "public/platform/WebMixedContent.h" |
| 38 #include "public/platform/WebURLRequest.h" | 39 #include "public/platform/WebURLRequest.h" |
| 39 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 class Frame; | 44 class Frame; |
| 44 class FrameLoaderClient; | 45 class FrameLoaderClient; |
| 45 class LocalFrame; | 46 class LocalFrame; |
| 46 class KURL; | 47 class KURL; |
| 47 class ResourceResponse; | 48 class ResourceResponse; |
| 48 class SecurityOrigin; | 49 class SecurityOrigin; |
| 49 | 50 |
| 50 class CORE_EXPORT MixedContentChecker final { | 51 class CORE_EXPORT MixedContentChecker final { |
| 51 WTF_MAKE_NONCOPYABLE(MixedContentChecker); | 52 WTF_MAKE_NONCOPYABLE(MixedContentChecker); |
| 52 DISALLOW_NEW(); | 53 DISALLOW_NEW(); |
| 53 public: | 54 public: |
| 54 enum ContextType { | |
| 55 ContextTypeNotMixedContent, | |
| 56 ContextTypeBlockable, | |
| 57 ContextTypeOptionallyBlockable, | |
| 58 ContextTypeShouldBeBlockable, | |
| 59 }; | |
| 60 | |
| 61 enum ReportingStatus { SendReport, SuppressReport }; | 55 enum ReportingStatus { SendReport, SuppressReport }; |
| 62 static bool shouldBlockFetch(LocalFrame*, WebURLRequest::RequestContext, Web
URLRequest::FrameType, ResourceRequest::RedirectStatus, const KURL&, ReportingSt
atus = SendReport); | 56 static bool shouldBlockFetch(LocalFrame*, WebURLRequest::RequestContext, Web
URLRequest::FrameType, ResourceRequest::RedirectStatus, const KURL&, ReportingSt
atus = SendReport); |
| 63 static bool shouldBlockFetch(LocalFrame* frame, const ResourceRequest& reque
st, const KURL& url, ReportingStatus status = SendReport) | 57 static bool shouldBlockFetch(LocalFrame* frame, const ResourceRequest& reque
st, const KURL& url, ReportingStatus status = SendReport) |
| 64 { | 58 { |
| 65 return shouldBlockFetch(frame, request.requestContext(), request.frameTy
pe(), request.redirectStatus(), url, status); | 59 return shouldBlockFetch(frame, request.requestContext(), request.frameTy
pe(), request.redirectStatus(), url, status); |
| 66 } | 60 } |
| 67 | 61 |
| 68 static bool shouldBlockWebSocket(LocalFrame*, const KURL&, ReportingStatus =
SendReport); | 62 static bool shouldBlockWebSocket(LocalFrame*, const KURL&, ReportingStatus =
SendReport); |
| 69 | 63 |
| 70 static bool isMixedContent(SecurityOrigin*, const KURL&); | 64 static bool isMixedContent(SecurityOrigin*, const KURL&); |
| 71 static bool isMixedFormAction(LocalFrame*, const KURL&, ReportingStatus = Se
ndReport); | 65 static bool isMixedFormAction(LocalFrame*, const KURL&, ReportingStatus = Se
ndReport); |
| 72 | 66 |
| 73 static void checkMixedPrivatePublic(LocalFrame*, const AtomicString& resourc
eIPAddress); | 67 static void checkMixedPrivatePublic(LocalFrame*, const AtomicString& resourc
eIPAddress); |
| 74 | 68 |
| 75 static ContextType contextTypeForInspector(LocalFrame*, const ResourceReques
t&); | 69 static WebMixedContent::ContextType contextTypeForInspector(LocalFrame*, con
st ResourceRequest&); |
| 76 | 70 |
| 77 // Returns the frame that should be considered the effective frame | 71 // Returns the frame that should be considered the effective frame |
| 78 // for a mixed content check for the given frame type. | 72 // for a mixed content check for the given frame type. |
| 79 static Frame* effectiveFrameForFrameType(LocalFrame*, WebURLRequest::FrameTy
pe); | 73 static Frame* effectiveFrameForFrameType(LocalFrame*, WebURLRequest::FrameTy
pe); |
| 80 | 74 |
| 81 static void handleCertificateError(LocalFrame*, const ResourceResponse&, Web
URLRequest::FrameType, WebURLRequest::RequestContext); | 75 static void handleCertificateError(LocalFrame*, const ResourceResponse&, Web
URLRequest::FrameType, WebURLRequest::RequestContext); |
| 82 | 76 |
| 83 private: | 77 private: |
| 84 FRIEND_TEST_ALL_PREFIXES(MixedContentCheckerTest, HandleCertificateError); | 78 FRIEND_TEST_ALL_PREFIXES(MixedContentCheckerTest, HandleCertificateError); |
| 85 enum MixedContentType { | |
| 86 Display, | |
| 87 Execution, | |
| 88 WebSocket, | |
| 89 Submission | |
| 90 }; | |
| 91 | 79 |
| 92 static Frame* inWhichFrameIsContentMixed(Frame*, WebURLRequest::FrameType, c
onst KURL&); | 80 static Frame* inWhichFrameIsContentMixed(Frame*, WebURLRequest::FrameType, c
onst KURL&); |
| 93 | 81 |
| 94 static ContextType contextTypeFromContext(WebURLRequest::RequestContext, Fra
me*); | |
| 95 static const char* typeNameFromContext(WebURLRequest::RequestContext); | |
| 96 static void logToConsoleAboutFetch(LocalFrame*, const KURL&, const KURL&, We
bURLRequest::RequestContext, bool allowed); | 82 static void logToConsoleAboutFetch(LocalFrame*, const KURL&, const KURL&, We
bURLRequest::RequestContext, bool allowed); |
| 97 static void logToConsoleAboutWebSocket(LocalFrame*, const KURL&, const KURL&
, bool allowed); | 83 static void logToConsoleAboutWebSocket(LocalFrame*, const KURL&, const KURL&
, bool allowed); |
| 98 static void count(Frame*, WebURLRequest::RequestContext); | 84 static void count(Frame*, WebURLRequest::RequestContext); |
| 99 }; | 85 }; |
| 100 | 86 |
| 101 } // namespace blink | 87 } // namespace blink |
| 102 | 88 |
| 103 #endif // MixedContentChecker_h | 89 #endif // MixedContentChecker_h |
| OLD | NEW |