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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 { | 246 { |
247 return adoptPtr(new InspectorPageAgent(page, injectedScriptManager, client,
overlay)); | 247 return adoptPtr(new InspectorPageAgent(page, injectedScriptManager, client,
overlay)); |
248 } | 248 } |
249 | 249 |
250 // static | 250 // static |
251 void InspectorPageAgent::resourceContent(ErrorString* errorString, LocalFrame* f
rame, const KURL& url, String* result, bool* base64Encoded) | 251 void InspectorPageAgent::resourceContent(ErrorString* errorString, LocalFrame* f
rame, const KURL& url, String* result, bool* base64Encoded) |
252 { | 252 { |
253 DocumentLoader* loader = assertDocumentLoader(errorString, frame); | 253 DocumentLoader* loader = assertDocumentLoader(errorString, frame); |
254 if (!loader) | 254 if (!loader) |
255 return; | 255 return; |
| 256 |
256 if (!cachedResourceContent(cachedResource(frame, url), result, base64Encoded
)) | 257 if (!cachedResourceContent(cachedResource(frame, url), result, base64Encoded
)) |
257 *errorString = "No resource with given URL found"; | 258 *errorString = "No resource with given URL found"; |
258 } | 259 } |
259 | 260 |
260 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) | 261 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) |
261 { | 262 { |
262 Resource* cachedResource = frame->document()->fetcher()->cachedResource(url)
; | 263 Document* document = frame->document(); |
| 264 if (!document) |
| 265 return 0; |
| 266 Resource* cachedResource = document->fetcher()->cachedResource(url); |
| 267 if (!cachedResource) { |
| 268 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame
); |
| 269 for (Vector<Document*>::const_iterator it = allImports.begin(); it != al
lImports.end(); ++it) { |
| 270 Document* import = *it; |
| 271 cachedResource = import->fetcher()->cachedResource(url); |
| 272 if (cachedResource) |
| 273 break; |
| 274 } |
| 275 } |
263 if (!cachedResource) | 276 if (!cachedResource) |
264 cachedResource = memoryCache()->resourceForURL(url); | 277 cachedResource = memoryCache()->resourceForURL(url); |
265 return cachedResource; | 278 return cachedResource; |
266 } | 279 } |
267 | 280 |
268 TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::resourceTypeJson(Inspe
ctorPageAgent::ResourceType resourceType) | 281 TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::resourceTypeJson(Inspe
ctorPageAgent::ResourceType resourceType) |
269 { | 282 { |
270 switch (resourceType) { | 283 switch (resourceType) { |
271 case DocumentResource: | 284 case DocumentResource: |
272 return TypeBuilder::Page::ResourceType::Document; | 285 return TypeBuilder::Page::ResourceType::Document; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 break; | 550 break; |
538 default: | 551 default: |
539 // All other Resource types download immediately. | 552 // All other Resource types download immediately. |
540 break; | 553 break; |
541 } | 554 } |
542 | 555 |
543 result.append(cachedResource); | 556 result.append(cachedResource); |
544 } | 557 } |
545 } | 558 } |
546 | 559 |
547 static Vector<Document*> importsForFrame(LocalFrame* frame) | 560 // static |
| 561 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) |
548 { | 562 { |
549 Vector<Document*> result; | 563 Vector<Document*> result; |
550 Document* rootDocument = frame->document(); | 564 Document* rootDocument = frame->document(); |
551 | 565 |
552 if (HTMLImportsController* controller = rootDocument->importsController()) { | 566 if (HTMLImportsController* controller = rootDocument->importsController()) { |
553 for (size_t i = 0; i < controller->loaderCount(); ++i) { | 567 for (size_t i = 0; i < controller->loaderCount(); ++i) { |
554 if (Document* document = controller->loaderAt(i)->document()) | 568 if (Document* document = controller->loaderAt(i)->document()) |
555 result.append(document); | 569 result.append(document); |
556 } | 570 } |
557 } | 571 } |
558 | 572 |
559 return result; | 573 return result; |
560 } | 574 } |
561 | 575 |
562 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) | 576 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) |
563 { | 577 { |
564 Vector<Resource*> result; | 578 Vector<Resource*> result; |
565 Document* rootDocument = frame->document(); | 579 Document* rootDocument = frame->document(); |
566 Vector<Document*> loaders = importsForFrame(frame); | 580 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); |
567 | 581 |
568 cachedResourcesForDocument(rootDocument, result); | 582 cachedResourcesForDocument(rootDocument, result); |
569 for (size_t i = 0; i < loaders.size(); ++i) | 583 for (size_t i = 0; i < loaders.size(); ++i) |
570 cachedResourcesForDocument(loaders[i], result); | 584 cachedResourcesForDocument(loaders[i], result); |
571 | 585 |
572 return result; | 586 return result; |
573 } | 587 } |
574 | 588 |
575 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) | 589 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) |
576 { | 590 { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 .setUrl(urlWithoutFragment(cachedResource->url()).string()) | 1116 .setUrl(urlWithoutFragment(cachedResource->url()).string()) |
1103 .setType(cachedResourceTypeJson(*cachedResource)) | 1117 .setType(cachedResourceTypeJson(*cachedResource)) |
1104 .setMimeType(cachedResource->response().mimeType()); | 1118 .setMimeType(cachedResource->response().mimeType()); |
1105 if (cachedResource->wasCanceled()) | 1119 if (cachedResource->wasCanceled()) |
1106 resourceObject->setCanceled(true); | 1120 resourceObject->setCanceled(true); |
1107 else if (cachedResource->status() == Resource::LoadError) | 1121 else if (cachedResource->status() == Resource::LoadError) |
1108 resourceObject->setFailed(true); | 1122 resourceObject->setFailed(true); |
1109 subresources->addItem(resourceObject); | 1123 subresources->addItem(resourceObject); |
1110 } | 1124 } |
1111 | 1125 |
1112 Vector<Document*> allImports = importsForFrame(frame); | 1126 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame); |
1113 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp
orts.end(); ++it) { | 1127 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp
orts.end(); ++it) { |
1114 Document* import = *it; | 1128 Document* import = *it; |
1115 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1129 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
1116 .setUrl(urlWithoutFragment(import->url()).string()) | 1130 .setUrl(urlWithoutFragment(import->url()).string()) |
1117 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) | 1131 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) |
1118 .setMimeType(import->suggestedMIMEType()); | 1132 .setMimeType(import->suggestedMIMEType()); |
1119 subresources->addItem(resourceObject); | 1133 subresources->addItem(resourceObject); |
1120 } | 1134 } |
1121 | 1135 |
1122 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; | 1136 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 } | 1281 } |
1268 | 1282 |
1269 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1283 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
1270 { | 1284 { |
1271 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1285 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
1272 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1286 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
1273 } | 1287 } |
1274 | 1288 |
1275 } // namespace WebCore | 1289 } // namespace WebCore |
1276 | 1290 |
OLD | NEW |