OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 InspectorPageAgent_h | 31 #ifndef InspectorPageAgent_h |
32 #define InspectorPageAgent_h | 32 #define InspectorPageAgent_h |
33 | 33 |
34 | 34 |
35 #include "InspectorFrontend.h" | 35 #include "InspectorFrontend.h" |
36 #include "core/inspector/InspectorBaseAgent.h" | 36 #include "core/inspector/InspectorBaseAgent.h" |
| 37 #include "core/inspector/InspectorResourceContentLoader.h" |
37 #include "wtf/HashMap.h" | 38 #include "wtf/HashMap.h" |
38 #include "wtf/text/WTFString.h" | 39 #include "wtf/text/WTFString.h" |
39 | 40 |
40 namespace WebCore { | 41 namespace WebCore { |
41 | 42 |
42 class Resource; | 43 class Resource; |
43 class DOMWrapperWorld; | 44 class DOMWrapperWorld; |
44 class Document; | 45 class Document; |
45 class DocumentLoader; | 46 class DocumentLoader; |
46 class LocalFrame; | 47 class LocalFrame; |
47 class GraphicsContext; | 48 class GraphicsContext; |
48 class GraphicsLayer; | 49 class GraphicsLayer; |
49 class InjectedScriptManager; | 50 class InjectedScriptManager; |
50 class InspectorClient; | 51 class InspectorClient; |
51 class InspectorOverlay; | 52 class InspectorOverlay; |
| 53 class InspectorResourceContentLoader; |
52 class InstrumentingAgents; | 54 class InstrumentingAgents; |
53 class IntSize; | 55 class IntSize; |
54 class KURL; | 56 class KURL; |
55 class LayoutRect; | 57 class LayoutRect; |
56 class Page; | 58 class Page; |
57 class RenderObject; | 59 class RenderObject; |
58 class SharedBuffer; | 60 class SharedBuffer; |
59 class StyleResolver; | 61 class StyleResolver; |
60 | 62 |
61 typedef String ErrorString; | 63 typedef String ErrorString; |
(...skipping 13 matching lines...) Expand all Loading... |
75 WebSocketResource, | 77 WebSocketResource, |
76 OtherResource | 78 OtherResource |
77 }; | 79 }; |
78 | 80 |
79 static PassOwnPtr<InspectorPageAgent> create(Page*, InjectedScriptManager*,
InspectorClient*, InspectorOverlay*); | 81 static PassOwnPtr<InspectorPageAgent> create(Page*, InjectedScriptManager*,
InspectorClient*, InspectorOverlay*); |
80 | 82 |
81 // Settings overrides. | 83 // Settings overrides. |
82 void setTextAutosizingEnabled(bool); | 84 void setTextAutosizingEnabled(bool); |
83 void setDeviceScaleAdjustment(float); | 85 void setDeviceScaleAdjustment(float); |
84 | 86 |
| 87 static Vector<Document*> importsForFrame(LocalFrame*); |
85 static bool cachedResourceContent(Resource*, String* result, bool* base64Enc
oded); | 88 static bool cachedResourceContent(Resource*, String* result, bool* base64Enc
oded); |
86 static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& text
EncodingName, bool withBase64Encode, String* result); | 89 static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& text
EncodingName, bool withBase64Encode, String* result); |
| 90 static void resourceContent(ErrorString*, LocalFrame*, const KURL&, String*
result, bool* base64Encoded); |
87 | 91 |
88 static PassRefPtr<SharedBuffer> resourceData(LocalFrame*, const KURL&, Strin
g* textEncodingName); | 92 static PassRefPtr<SharedBuffer> resourceData(LocalFrame*, const KURL&, Strin
g* textEncodingName); |
89 static Resource* cachedResource(LocalFrame*, const KURL&); | 93 static Resource* cachedResource(LocalFrame*, const KURL&); |
90 static TypeBuilder::Page::ResourceType::Enum resourceTypeJson(ResourceType); | 94 static TypeBuilder::Page::ResourceType::Enum resourceTypeJson(ResourceType); |
91 static ResourceType cachedResourceType(const Resource&); | 95 static ResourceType cachedResourceType(const Resource&); |
92 static TypeBuilder::Page::ResourceType::Enum cachedResourceTypeJson(const Re
source&); | 96 static TypeBuilder::Page::ResourceType::Enum cachedResourceTypeJson(const Re
source&); |
93 | 97 |
94 // Page API for InspectorFrontend | 98 // Page API for InspectorFrontend |
95 virtual void enable(ErrorString*) OVERRIDE; | 99 virtual void enable(ErrorString*) OVERRIDE; |
96 virtual void disable(ErrorString*) OVERRIDE; | 100 virtual void disable(ErrorString*) OVERRIDE; |
97 virtual void addScriptToEvaluateOnLoad(ErrorString*, const String& source, S
tring* result) OVERRIDE; | 101 virtual void addScriptToEvaluateOnLoad(ErrorString*, const String& source, S
tring* result) OVERRIDE; |
98 virtual void removeScriptToEvaluateOnLoad(ErrorString*, const String& identi
fier) OVERRIDE; | 102 virtual void removeScriptToEvaluateOnLoad(ErrorString*, const String& identi
fier) OVERRIDE; |
99 virtual void reload(ErrorString*, const bool* optionalIgnoreCache, const Str
ing* optionalScriptToEvaluateOnLoad, const String* optionalScriptPreprocessor) O
VERRIDE; | 103 virtual void reload(ErrorString*, const bool* optionalIgnoreCache, const Str
ing* optionalScriptToEvaluateOnLoad, const String* optionalScriptPreprocessor) O
VERRIDE; |
100 virtual void navigate(ErrorString*, const String& url) OVERRIDE; | 104 virtual void navigate(ErrorString*, const String& url) OVERRIDE; |
101 virtual void getCookies(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder:
:Page::Cookie> >& cookies) OVERRIDE; | 105 virtual void getCookies(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder:
:Page::Cookie> >& cookies) OVERRIDE; |
102 virtual void deleteCookie(ErrorString*, const String& cookieName, const Stri
ng& url) OVERRIDE; | 106 virtual void deleteCookie(ErrorString*, const String& cookieName, const Stri
ng& url) OVERRIDE; |
103 virtual void getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page::FrameRe
sourceTree>&) OVERRIDE; | 107 virtual void getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page::FrameRe
sourceTree>&) OVERRIDE; |
104 virtual void getResourceContent(ErrorString*, const String& frameId, const S
tring& url, String* content, bool* base64Encoded) OVERRIDE; | 108 virtual void getResourceContent(ErrorString*, const String& frameId, const S
tring& url, PassRefPtr<GetResourceContentCallback>) OVERRIDE; |
105 virtual void hasTouchInputs(ErrorString*, bool* result) OVERRIDE; | 109 virtual void hasTouchInputs(ErrorString*, bool* result) OVERRIDE; |
106 virtual void searchInResource(ErrorString*, const String& frameId, const Str
ing& url, const String& query, const bool* optionalCaseSensitive, const bool* op
tionalIsRegex, RefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> >&) OVE
RRIDE; | 110 virtual void searchInResource(ErrorString*, const String& frameId, const Str
ing& url, const String& query, const bool* optionalCaseSensitive, const bool* op
tionalIsRegex, RefPtr<TypeBuilder::Array<TypeBuilder::Page::SearchMatch> >&) OVE
RRIDE; |
107 virtual void setDocumentContent(ErrorString*, const String& frameId, const S
tring& html) OVERRIDE; | 111 virtual void setDocumentContent(ErrorString*, const String& frameId, const S
tring& html) OVERRIDE; |
108 virtual void setDeviceMetricsOverride(ErrorString*, int width, int height, d
ouble deviceScaleFactor, bool emulateViewport, bool fitWindow, const bool* optio
nalTextAutosizing, const double* optionalFontScaleFactor) OVERRIDE; | 112 virtual void setDeviceMetricsOverride(ErrorString*, int width, int height, d
ouble deviceScaleFactor, bool emulateViewport, bool fitWindow, const bool* optio
nalTextAutosizing, const double* optionalFontScaleFactor) OVERRIDE; |
109 virtual void clearDeviceMetricsOverride(ErrorString*) OVERRIDE; | 113 virtual void clearDeviceMetricsOverride(ErrorString*) OVERRIDE; |
110 virtual void setShowPaintRects(ErrorString*, bool show) OVERRIDE; | 114 virtual void setShowPaintRects(ErrorString*, bool show) OVERRIDE; |
111 virtual void setShowDebugBorders(ErrorString*, bool show) OVERRIDE; | 115 virtual void setShowDebugBorders(ErrorString*, bool show) OVERRIDE; |
112 virtual void setShowFPSCounter(ErrorString*, bool show) OVERRIDE; | 116 virtual void setShowFPSCounter(ErrorString*, bool show) OVERRIDE; |
113 virtual void setContinuousPaintingEnabled(ErrorString*, bool enabled) OVERRI
DE; | 117 virtual void setContinuousPaintingEnabled(ErrorString*, bool enabled) OVERRI
DE; |
114 virtual void setShowScrollBottleneckRects(ErrorString*, bool show) OVERRIDE; | 118 virtual void setShowScrollBottleneckRects(ErrorString*, bool show) OVERRIDE; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 LocalFrame* frameForId(const String& frameId); | 157 LocalFrame* frameForId(const String& frameId); |
154 String frameId(LocalFrame*); | 158 String frameId(LocalFrame*); |
155 bool hasIdForFrame(LocalFrame*) const; | 159 bool hasIdForFrame(LocalFrame*) const; |
156 String loaderId(DocumentLoader*); | 160 String loaderId(DocumentLoader*); |
157 LocalFrame* findFrameWithSecurityOrigin(const String& originRawString); | 161 LocalFrame* findFrameWithSecurityOrigin(const String& originRawString); |
158 LocalFrame* assertFrame(ErrorString*, const String& frameId); | 162 LocalFrame* assertFrame(ErrorString*, const String& frameId); |
159 String scriptPreprocessorSource() { return m_scriptPreprocessorSource; } | 163 String scriptPreprocessorSource() { return m_scriptPreprocessorSource; } |
160 const AtomicString& resourceSourceMapURL(const String& url); | 164 const AtomicString& resourceSourceMapURL(const String& url); |
161 bool deviceMetricsOverrideEnabled(); | 165 bool deviceMetricsOverrideEnabled(); |
162 static DocumentLoader* assertDocumentLoader(ErrorString*, LocalFrame*); | 166 static DocumentLoader* assertDocumentLoader(ErrorString*, LocalFrame*); |
| 167 InspectorResourceContentLoader* resourceContentLoader() { return m_inspector
ResourceContentLoader.get(); } |
163 | 168 |
164 private: | 169 private: |
165 static void resourceContent(ErrorString*, LocalFrame*, const KURL&, String*
result, bool* base64Encoded); | 170 class GetResourceContentLoadListener; |
166 | 171 |
167 InspectorPageAgent(Page*, InjectedScriptManager*, InspectorClient*, Inspecto
rOverlay*); | 172 InspectorPageAgent(Page*, InjectedScriptManager*, InspectorClient*, Inspecto
rOverlay*); |
168 bool deviceMetricsChanged(bool enabled, int width, int height, double device
ScaleFactor, bool emulateViewport, bool fitWindow, double fontScaleFactor, bool
textAutosizing); | 173 bool deviceMetricsChanged(bool enabled, int width, int height, double device
ScaleFactor, bool emulateViewport, bool fitWindow, double fontScaleFactor, bool
textAutosizing); |
169 void updateViewMetricsFromState(); | 174 void updateViewMetricsFromState(); |
170 void updateViewMetrics(bool enabled, int width, int height, double deviceSca
leFactor, bool emulateViewport, bool fitWindow, double fontScaleFactor, bool tex
tAutosizingEnabled); | 175 void updateViewMetrics(bool enabled, int width, int height, double deviceSca
leFactor, bool emulateViewport, bool fitWindow, double fontScaleFactor, bool tex
tAutosizingEnabled); |
171 void updateTouchEventEmulationInPage(bool); | 176 void updateTouchEventEmulationInPage(bool); |
172 bool compositingEnabled(ErrorString*); | 177 bool compositingEnabled(ErrorString*); |
173 | 178 |
| 179 void getResourceContentAfterResourcesContentLoaded(const String& frameId, co
nst String& url, PassRefPtr<GetResourceContentCallback>); |
| 180 |
174 static bool dataContent(const char* data, unsigned size, const String& textE
ncodingName, bool withBase64Encode, String* result); | 181 static bool dataContent(const char* data, unsigned size, const String& textE
ncodingName, bool withBase64Encode, String* result); |
175 | 182 |
176 PassRefPtr<TypeBuilder::Page::Frame> buildObjectForFrame(LocalFrame*); | 183 PassRefPtr<TypeBuilder::Page::Frame> buildObjectForFrame(LocalFrame*); |
177 PassRefPtr<TypeBuilder::Page::FrameResourceTree> buildObjectForFrameTree(Loc
alFrame*); | 184 PassRefPtr<TypeBuilder::Page::FrameResourceTree> buildObjectForFrameTree(Loc
alFrame*); |
178 Page* m_page; | 185 Page* m_page; |
179 InjectedScriptManager* m_injectedScriptManager; | 186 InjectedScriptManager* m_injectedScriptManager; |
180 InspectorClient* m_client; | 187 InspectorClient* m_client; |
181 InspectorFrontend::Page* m_frontend; | 188 InspectorFrontend::Page* m_frontend; |
182 InspectorOverlay* m_overlay; | 189 InspectorOverlay* m_overlay; |
183 long m_lastScriptIdentifier; | 190 long m_lastScriptIdentifier; |
184 String m_pendingScriptToEvaluateOnLoadOnce; | 191 String m_pendingScriptToEvaluateOnLoadOnce; |
185 String m_scriptToEvaluateOnLoadOnce; | 192 String m_scriptToEvaluateOnLoadOnce; |
186 String m_pendingScriptPreprocessor; | 193 String m_pendingScriptPreprocessor; |
187 String m_scriptPreprocessorSource; | 194 String m_scriptPreprocessorSource; |
188 HashMap<LocalFrame*, String> m_frameToIdentifier; | 195 HashMap<LocalFrame*, String> m_frameToIdentifier; |
189 HashMap<String, LocalFrame*> m_identifierToFrame; | 196 HashMap<String, LocalFrame*> m_identifierToFrame; |
190 HashMap<DocumentLoader*, String> m_loaderToIdentifier; | 197 HashMap<DocumentLoader*, String> m_loaderToIdentifier; |
191 bool m_enabled; | 198 bool m_enabled; |
192 bool m_ignoreScriptsEnabledNotification; | 199 bool m_ignoreScriptsEnabledNotification; |
193 bool m_deviceMetricsOverridden; | 200 bool m_deviceMetricsOverridden; |
194 bool m_emulateViewportEnabled; | 201 bool m_emulateViewportEnabled; |
195 | 202 |
196 bool m_touchEmulationEnabled; | 203 bool m_touchEmulationEnabled; |
197 bool m_originalTouchEnabled; | 204 bool m_originalTouchEnabled; |
198 bool m_originalDeviceSupportsMouse; | 205 bool m_originalDeviceSupportsMouse; |
199 bool m_originalDeviceSupportsTouch; | 206 bool m_originalDeviceSupportsTouch; |
200 | 207 |
201 bool m_embedderTextAutosizingEnabled; | 208 bool m_embedderTextAutosizingEnabled; |
202 double m_embedderFontScaleFactor; | 209 double m_embedderFontScaleFactor; |
| 210 |
| 211 OwnPtr<InspectorResourceContentLoader> m_inspectorResourceContentLoader; |
203 }; | 212 }; |
204 | 213 |
205 | 214 |
206 } // namespace WebCore | 215 } // namespace WebCore |
207 | 216 |
208 | 217 |
209 #endif // !defined(InspectorPagerAgent_h) | 218 #endif // !defined(InspectorPagerAgent_h) |
OLD | NEW |