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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 334 } |
335 | 335 |
336 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) | 336 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) |
337 { | 337 { |
338 Document* document = frame->document(); | 338 Document* document = frame->document(); |
339 if (!document) | 339 if (!document) |
340 return 0; | 340 return 0; |
341 Resource* cachedResource = document->fetcher()->cachedResource(url); | 341 Resource* cachedResource = document->fetcher()->cachedResource(url); |
342 if (!cachedResource) { | 342 if (!cachedResource) { |
343 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame
); | 343 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame
); |
344 for (Vector<Document*>::const_iterator it = allImports.begin(); it != al
lImports.end(); ++it) { | 344 for (Document* import : allImports) { |
345 Document* import = *it; | |
346 cachedResource = import->fetcher()->cachedResource(url); | 345 cachedResource = import->fetcher()->cachedResource(url); |
347 if (cachedResource) | 346 if (cachedResource) |
348 break; | 347 break; |
349 } | 348 } |
350 } | 349 } |
351 if (!cachedResource) | 350 if (!cachedResource) |
352 cachedResource = memoryCache()->resourceForURL(url, document->fetcher()-
>getCacheIdentifier()); | 351 cachedResource = memoryCache()->resourceForURL(url, document->fetcher()-
>getCacheIdentifier()); |
353 return cachedResource; | 352 return cachedResource; |
354 } | 353 } |
355 | 354 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 ListHashSet<Cookie>::iterator it = cookiesList.begin(); | 620 ListHashSet<Cookie>::iterator it = cookiesList.begin(); |
622 for (int i = 0; it != end; ++it, i++) | 621 for (int i = 0; it != end; ++it, i++) |
623 cookies->addItem(buildObjectForCookie(*it)); | 622 cookies->addItem(buildObjectForCookie(*it)); |
624 | 623 |
625 return cookies; | 624 return cookies; |
626 } | 625 } |
627 | 626 |
628 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult, bool skipXHRs) | 627 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult, bool skipXHRs) |
629 { | 628 { |
630 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); | 629 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); |
631 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); | 630 for (const auto& resource : allResources) { |
632 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { | 631 Resource* cachedResource = resource.value.get(); |
633 Resource* cachedResource = it->value.get(); | |
634 | 632 |
635 switch (cachedResource->type()) { | 633 switch (cachedResource->type()) { |
636 case Resource::Image: | 634 case Resource::Image: |
637 // Skip images that were not auto loaded (images disabled in the use
r agent). | 635 // Skip images that were not auto loaded (images disabled in the use
r agent). |
638 if (toImageResource(cachedResource)->stillNeedsLoad()) | 636 if (toImageResource(cachedResource)->stillNeedsLoad()) |
639 continue; | 637 continue; |
640 break; | 638 break; |
641 case Resource::Font: | 639 case Resource::Font: |
642 // Skip fonts that were referenced in CSS but never used/downloaded. | 640 // Skip fonts that were referenced in CSS but never used/downloaded. |
643 if (toFontResource(cachedResource)->stillNeedsLoad()) | 641 if (toFontResource(cachedResource)->stillNeedsLoad()) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 return result; | 683 return result; |
686 } | 684 } |
687 | 685 |
688 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) | 686 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) |
689 { | 687 { |
690 Vector<KURL> result; | 688 Vector<KURL> result; |
691 | 689 |
692 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); | 690 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); |
693 | 691 |
694 Vector<Resource*> allResources = cachedResourcesForFrame(frame, false); | 692 Vector<Resource*> allResources = cachedResourcesForFrame(frame, false); |
695 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) | 693 for (const auto& resource : allResources) |
696 result.append(urlWithoutFragment((*it)->url())); | 694 result.append(urlWithoutFragment(resource->url())); |
697 | 695 |
698 return result; | 696 return result; |
699 } | 697 } |
700 | 698 |
701 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) | 699 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) |
702 { | 700 { |
703 ListHashSet<Cookie> rawCookiesList; | 701 ListHashSet<Cookie> rawCookiesList; |
704 | 702 |
705 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(m
ainFrame())) { | 703 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(m
ainFrame())) { |
706 if (!frame->isLocalFrame()) | 704 if (!frame->isLocalFrame()) |
707 continue; | 705 continue; |
708 Document* document = toLocalFrame(frame)->document(); | 706 Document* document = toLocalFrame(frame)->document(); |
709 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame)); | 707 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame)); |
710 for (Vector<KURL>::const_iterator it = allURLs.begin(); it != allURLs.en
d(); ++it) { | 708 for (const auto& url : allURLs) { |
711 Vector<Cookie> docCookiesList; | 709 Vector<Cookie> docCookiesList; |
712 getRawCookies(document, *it, docCookiesList); | 710 getRawCookies(document, url, docCookiesList); |
713 int cookiesSize = docCookiesList.size(); | 711 int cookiesSize = docCookiesList.size(); |
714 for (int i = 0; i < cookiesSize; i++) { | 712 for (int i = 0; i < cookiesSize; i++) { |
715 if (!rawCookiesList.contains(docCookiesList[i])) | 713 if (!rawCookiesList.contains(docCookiesList[i])) |
716 rawCookiesList.add(docCookiesList[i]); | 714 rawCookiesList.add(docCookiesList[i]); |
717 } | 715 } |
718 } | 716 } |
719 } | 717 } |
720 | 718 |
721 cookies = buildArrayForCookies(rawCookiesList); | 719 cookies = buildArrayForCookies(rawCookiesList); |
722 } | 720 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 } | 980 } |
983 } | 981 } |
984 | 982 |
985 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) | 983 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) |
986 { | 984 { |
987 if (!m_frontend) | 985 if (!m_frontend) |
988 return; | 986 return; |
989 | 987 |
990 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr
iptsToEvaluateOnLoad); | 988 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr
iptsToEvaluateOnLoad); |
991 if (scripts) { | 989 if (scripts) { |
992 JSONObject::const_iterator end = scripts->end(); | 990 for (const auto& script : *scripts) { |
993 for (JSONObject::const_iterator it = scripts->begin(); it != end; ++it)
{ | |
994 String scriptText; | 991 String scriptText; |
995 if (it->value->asString(&scriptText)) | 992 if (script.value->asString(&scriptText)) |
996 frame->script().executeScriptInMainWorld(scriptText); | 993 frame->script().executeScriptInMainWorld(scriptText); |
997 } | 994 } |
998 } | 995 } |
999 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) | 996 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) |
1000 frame->script().executeScriptInMainWorld(m_scriptToEvaluateOnLoadOnce); | 997 frame->script().executeScriptInMainWorld(m_scriptToEvaluateOnLoadOnce); |
1001 } | 998 } |
1002 | 999 |
1003 void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame) | 1000 void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame) |
1004 { | 1001 { |
1005 if (!frame->isMainFrame()) | 1002 if (!frame->isMainFrame()) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 | 1287 |
1291 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) | 1288 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) |
1292 { | 1289 { |
1293 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); | 1290 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); |
1294 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); | 1291 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); |
1295 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() | 1292 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() |
1296 .setFrame(frameObject) | 1293 .setFrame(frameObject) |
1297 .setResources(subresources); | 1294 .setResources(subresources); |
1298 | 1295 |
1299 Vector<Resource*> allResources = cachedResourcesForFrame(frame, true); | 1296 Vector<Resource*> allResources = cachedResourcesForFrame(frame, true); |
1300 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { | 1297 for (Resource* cachedResource : allResources) { |
1301 Resource* cachedResource = *it; | |
1302 | |
1303 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1298 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
1304 .setUrl(urlWithoutFragment(cachedResource->url()).string()) | 1299 .setUrl(urlWithoutFragment(cachedResource->url()).string()) |
1305 .setType(cachedResourceTypeJson(*cachedResource)) | 1300 .setType(cachedResourceTypeJson(*cachedResource)) |
1306 .setMimeType(cachedResource->response().mimeType()); | 1301 .setMimeType(cachedResource->response().mimeType()); |
1307 if (cachedResource->wasCanceled()) | 1302 if (cachedResource->wasCanceled()) |
1308 resourceObject->setCanceled(true); | 1303 resourceObject->setCanceled(true); |
1309 else if (cachedResource->status() == Resource::LoadError) | 1304 else if (cachedResource->status() == Resource::LoadError) |
1310 resourceObject->setFailed(true); | 1305 resourceObject->setFailed(true); |
1311 subresources->addItem(resourceObject); | 1306 subresources->addItem(resourceObject); |
1312 } | 1307 } |
1313 | 1308 |
1314 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame); | 1309 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame); |
1315 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp
orts.end(); ++it) { | 1310 for (Document* import : allImports) { |
1316 Document* import = *it; | |
1317 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1311 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
1318 .setUrl(urlWithoutFragment(import->url()).string()) | 1312 .setUrl(urlWithoutFragment(import->url()).string()) |
1319 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) | 1313 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) |
1320 .setMimeType(import->suggestedMIMEType()); | 1314 .setMimeType(import->suggestedMIMEType()); |
1321 subresources->addItem(resourceObject); | 1315 subresources->addItem(resourceObject); |
1322 } | 1316 } |
1323 | 1317 |
1324 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; | 1318 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; |
1325 for (Frame* child = frame->tree().firstChild(); child; child = child->tree()
.nextSibling()) { | 1319 for (Frame* child = frame->tree().firstChild(); child; child = child->tree()
.nextSibling()) { |
1326 if (!child->isLocalFrame()) | 1320 if (!child->isLocalFrame()) |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 void InspectorPageAgent::trace(Visitor* visitor) | 1497 void InspectorPageAgent::trace(Visitor* visitor) |
1504 { | 1498 { |
1505 visitor->trace(m_page); | 1499 visitor->trace(m_page); |
1506 visitor->trace(m_injectedScriptManager); | 1500 visitor->trace(m_injectedScriptManager); |
1507 visitor->trace(m_inspectorResourceContentLoader); | 1501 visitor->trace(m_inspectorResourceContentLoader); |
1508 InspectorBaseAgent::trace(visitor); | 1502 InspectorBaseAgent::trace(visitor); |
1509 } | 1503 } |
1510 | 1504 |
1511 } // namespace blink | 1505 } // namespace blink |
1512 | 1506 |
OLD | NEW |