| 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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 RefPtr<TypeBuilder::Array<TypeBuilder::Page::Cookie> > cookies = TypeBuilder
::Array<TypeBuilder::Page::Cookie>::create(); | 548 RefPtr<TypeBuilder::Array<TypeBuilder::Page::Cookie> > cookies = TypeBuilder
::Array<TypeBuilder::Page::Cookie>::create(); |
| 549 | 549 |
| 550 ListHashSet<Cookie>::iterator end = cookiesList.end(); | 550 ListHashSet<Cookie>::iterator end = cookiesList.end(); |
| 551 ListHashSet<Cookie>::iterator it = cookiesList.begin(); | 551 ListHashSet<Cookie>::iterator it = cookiesList.begin(); |
| 552 for (int i = 0; it != end; ++it, i++) | 552 for (int i = 0; it != end; ++it, i++) |
| 553 cookies->addItem(buildObjectForCookie(*it)); | 553 cookies->addItem(buildObjectForCookie(*it)); |
| 554 | 554 |
| 555 return cookies; | 555 return cookies; |
| 556 } | 556 } |
| 557 | 557 |
| 558 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult) | 558 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult, bool skipXHRs) |
| 559 { | 559 { |
| 560 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); | 560 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); |
| 561 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); | 561 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); |
| 562 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { | 562 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { |
| 563 Resource* cachedResource = it->value.get(); | 563 Resource* cachedResource = it->value.get(); |
| 564 | 564 |
| 565 switch (cachedResource->type()) { | 565 switch (cachedResource->type()) { |
| 566 case Resource::Image: | 566 case Resource::Image: |
| 567 // Skip images that were not auto loaded (images disabled in the use
r agent). | 567 // Skip images that were not auto loaded (images disabled in the use
r agent). |
| 568 if (toImageResource(cachedResource)->stillNeedsLoad()) | 568 if (toImageResource(cachedResource)->stillNeedsLoad()) |
| 569 continue; | 569 continue; |
| 570 break; | 570 break; |
| 571 case Resource::Font: | 571 case Resource::Font: |
| 572 // Skip fonts that were referenced in CSS but never used/downloaded. | 572 // Skip fonts that were referenced in CSS but never used/downloaded. |
| 573 if (toFontResource(cachedResource)->stillNeedsLoad()) | 573 if (toFontResource(cachedResource)->stillNeedsLoad()) |
| 574 continue; | 574 continue; |
| 575 break; | 575 break; |
| 576 case Resource::Raw: |
| 577 if (skipXHRs) |
| 578 continue; |
| 579 break; |
| 576 default: | 580 default: |
| 577 // All other Resource types download immediately. | 581 // All other Resource types download immediately. |
| 578 break; | 582 break; |
| 579 } | 583 } |
| 580 | 584 |
| 581 result.append(cachedResource); | 585 result.append(cachedResource); |
| 582 } | 586 } |
| 583 } | 587 } |
| 584 | 588 |
| 585 // static | 589 // static |
| 586 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) | 590 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) |
| 587 { | 591 { |
| 588 Vector<Document*> result; | 592 Vector<Document*> result; |
| 589 Document* rootDocument = frame->document(); | 593 Document* rootDocument = frame->document(); |
| 590 | 594 |
| 591 if (HTMLImportsController* controller = rootDocument->importsController()) { | 595 if (HTMLImportsController* controller = rootDocument->importsController()) { |
| 592 for (size_t i = 0; i < controller->loaderCount(); ++i) { | 596 for (size_t i = 0; i < controller->loaderCount(); ++i) { |
| 593 if (Document* document = controller->loaderAt(i)->document()) | 597 if (Document* document = controller->loaderAt(i)->document()) |
| 594 result.append(document); | 598 result.append(document); |
| 595 } | 599 } |
| 596 } | 600 } |
| 597 | 601 |
| 598 return result; | 602 return result; |
| 599 } | 603 } |
| 600 | 604 |
| 601 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) | 605 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame, bool skipXHR
s) |
| 602 { | 606 { |
| 603 Vector<Resource*> result; | 607 Vector<Resource*> result; |
| 604 Document* rootDocument = frame->document(); | 608 Document* rootDocument = frame->document(); |
| 605 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); | 609 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); |
| 606 | 610 |
| 607 cachedResourcesForDocument(rootDocument, result); | 611 cachedResourcesForDocument(rootDocument, result, skipXHRs); |
| 608 for (size_t i = 0; i < loaders.size(); ++i) | 612 for (size_t i = 0; i < loaders.size(); ++i) |
| 609 cachedResourcesForDocument(loaders[i], result); | 613 cachedResourcesForDocument(loaders[i], result, skipXHRs); |
| 610 | 614 |
| 611 return result; | 615 return result; |
| 612 } | 616 } |
| 613 | 617 |
| 614 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) | 618 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) |
| 615 { | 619 { |
| 616 Vector<KURL> result; | 620 Vector<KURL> result; |
| 617 | 621 |
| 618 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); | 622 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); |
| 619 | 623 |
| 620 Vector<Resource*> allResources = cachedResourcesForFrame(frame); | 624 Vector<Resource*> allResources = cachedResourcesForFrame(frame, false); |
| 621 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) | 625 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) |
| 622 result.append(urlWithoutFragment((*it)->url())); | 626 result.append(urlWithoutFragment((*it)->url())); |
| 623 | 627 |
| 624 return result; | 628 return result; |
| 625 } | 629 } |
| 626 | 630 |
| 627 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) | 631 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) |
| 628 { | 632 { |
| 629 ListHashSet<Cookie> rawCookiesList; | 633 ListHashSet<Cookie> rawCookiesList; |
| 630 | 634 |
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 } | 1172 } |
| 1169 | 1173 |
| 1170 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) | 1174 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) |
| 1171 { | 1175 { |
| 1172 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); | 1176 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); |
| 1173 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); | 1177 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); |
| 1174 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() | 1178 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() |
| 1175 .setFrame(frameObject) | 1179 .setFrame(frameObject) |
| 1176 .setResources(subresources); | 1180 .setResources(subresources); |
| 1177 | 1181 |
| 1178 Vector<Resource*> allResources = cachedResourcesForFrame(frame); | 1182 Vector<Resource*> allResources = cachedResourcesForFrame(frame, true); |
| 1179 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { | 1183 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { |
| 1180 Resource* cachedResource = *it; | 1184 Resource* cachedResource = *it; |
| 1181 | 1185 |
| 1182 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1186 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
| 1183 .setUrl(urlWithoutFragment(cachedResource->url()).string()) | 1187 .setUrl(urlWithoutFragment(cachedResource->url()).string()) |
| 1184 .setType(cachedResourceTypeJson(*cachedResource)) | 1188 .setType(cachedResourceTypeJson(*cachedResource)) |
| 1185 .setMimeType(cachedResource->response().mimeType()); | 1189 .setMimeType(cachedResource->response().mimeType()); |
| 1186 if (cachedResource->wasCanceled()) | 1190 if (cachedResource->wasCanceled()) |
| 1187 resourceObject->setCanceled(true); | 1191 resourceObject->setCanceled(true); |
| 1188 else if (cachedResource->status() == Resource::LoadError) | 1192 else if (cachedResource->status() == Resource::LoadError) |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 } | 1347 } |
| 1344 | 1348 |
| 1345 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1349 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
| 1346 { | 1350 { |
| 1347 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1351 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
| 1348 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1352 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
| 1349 } | 1353 } |
| 1350 | 1354 |
| 1351 } // namespace WebCore | 1355 } // namespace WebCore |
| 1352 | 1356 |
| OLD | NEW |