1 | /* |
2 | * Copyright (C) 2019 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #pragma once |
27 | |
28 | #include "CachedFontClient.h" |
29 | #include "CachedImageClient.h" |
30 | #include "CachedRawResourceClient.h" |
31 | #include "CachedResourceClient.h" |
32 | #include "CachedSVGDocumentClient.h" |
33 | #include "CachedStyleSheetClient.h" |
34 | #include "ExceptionOr.h" |
35 | #include <JavaScriptCore/InspectorAuditAgent.h> |
36 | #include <wtf/Forward.h> |
37 | #include <wtf/Ref.h> |
38 | #include <wtf/RefCounted.h> |
39 | |
40 | namespace WebCore { |
41 | |
42 | class CachedResource; |
43 | class Document; |
44 | |
45 | class InspectorAuditResourcesObject : public RefCounted<InspectorAuditResourcesObject> { |
46 | public: |
47 | static Ref<InspectorAuditResourcesObject> create(Inspector::InspectorAuditAgent& auditAgent) |
48 | { |
49 | return adoptRef(*new InspectorAuditResourcesObject(auditAgent)); |
50 | } |
51 | |
52 | ~InspectorAuditResourcesObject(); |
53 | |
54 | struct Resource { |
55 | String id; |
56 | String url; |
57 | String mimeType; |
58 | }; |
59 | |
60 | struct ResourceContent { |
61 | String data; |
62 | bool base64Encoded; |
63 | }; |
64 | |
65 | ExceptionOr<Vector<Resource>> getResources(Document&); |
66 | ExceptionOr<ResourceContent> getResourceContent(Document&, const String& id); |
67 | |
68 | private: |
69 | explicit InspectorAuditResourcesObject(Inspector::InspectorAuditAgent&); |
70 | |
71 | CachedResourceClient& clientForResource(const CachedResource&); |
72 | |
73 | Inspector::InspectorAuditAgent& m_auditAgent; |
74 | |
75 | class InspectorAuditCachedResourceClient : public CachedResourceClient { }; |
76 | InspectorAuditCachedResourceClient m_cachedResourceClient; |
77 | |
78 | class InspectorAuditCachedFontClient : public CachedFontClient { }; |
79 | InspectorAuditCachedFontClient m_cachedFontClient; |
80 | |
81 | class InspectorAuditCachedImageClient : public CachedImageClient { }; |
82 | InspectorAuditCachedImageClient m_cachedImageClient; |
83 | |
84 | class InspectorAuditCachedRawResourceClient : public CachedRawResourceClient { }; |
85 | InspectorAuditCachedRawResourceClient m_cachedRawResourceClient; |
86 | |
87 | class InspectorAuditCachedSVGDocumentClient : public CachedSVGDocumentClient { }; |
88 | InspectorAuditCachedSVGDocumentClient m_cachedSVGDocumentClient; |
89 | |
90 | class InspectorAuditCachedStyleSheetClient : public CachedStyleSheetClient { }; |
91 | InspectorAuditCachedStyleSheetClient m_cachedStyleSheetClient; |
92 | |
93 | HashMap<String, CachedResource*> m_resources; |
94 | }; |
95 | |
96 | } // namespace WebCore |
97 | |