| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "core/fetch/FontResource.h" | 44 #include "core/fetch/FontResource.h" |
| 45 #include "core/fetch/ImageResource.h" | 45 #include "core/fetch/ImageResource.h" |
| 46 #include "core/fetch/MemoryCache.h" | 46 #include "core/fetch/MemoryCache.h" |
| 47 #include "core/fetch/Resource.h" | 47 #include "core/fetch/Resource.h" |
| 48 #include "core/fetch/ResourceFetcher.h" | 48 #include "core/fetch/ResourceFetcher.h" |
| 49 #include "core/fetch/ScriptResource.h" | 49 #include "core/fetch/ScriptResource.h" |
| 50 #include "core/frame/FrameView.h" | 50 #include "core/frame/FrameView.h" |
| 51 #include "core/frame/LocalFrame.h" | 51 #include "core/frame/LocalFrame.h" |
| 52 #include "core/frame/Settings.h" | 52 #include "core/frame/Settings.h" |
| 53 #include "core/html/HTMLFrameOwnerElement.h" | 53 #include "core/html/HTMLFrameOwnerElement.h" |
| 54 #include "core/html/VoidCallback.h" | |
| 55 #include "core/html/imports/HTMLImport.h" | 54 #include "core/html/imports/HTMLImport.h" |
| 56 #include "core/html/imports/HTMLImportLoader.h" | 55 #include "core/html/imports/HTMLImportLoader.h" |
| 57 #include "core/html/imports/HTMLImportsController.h" | 56 #include "core/html/imports/HTMLImportsController.h" |
| 58 #include "core/html/parser/TextResourceDecoder.h" | 57 #include "core/html/parser/TextResourceDecoder.h" |
| 59 #include "core/inspector/ContentSearchUtils.h" | 58 #include "core/inspector/ContentSearchUtils.h" |
| 60 #include "core/inspector/DOMPatchSupport.h" | 59 #include "core/inspector/DOMPatchSupport.h" |
| 61 #include "core/inspector/IdentifiersFactory.h" | 60 #include "core/inspector/IdentifiersFactory.h" |
| 62 #include "core/inspector/InjectedScriptManager.h" | 61 #include "core/inspector/InjectedScriptManager.h" |
| 63 #include "core/inspector/InspectorClient.h" | 62 #include "core/inspector/InspectorClient.h" |
| 64 #include "core/inspector/InspectorInstrumentation.h" | 63 #include "core/inspector/InspectorInstrumentation.h" |
| 65 #include "core/inspector/InspectorOverlay.h" | 64 #include "core/inspector/InspectorOverlay.h" |
| 66 #include "core/inspector/InspectorResourceContentLoader.h" | |
| 67 #include "core/inspector/InspectorState.h" | 65 #include "core/inspector/InspectorState.h" |
| 68 #include "core/inspector/InstrumentingAgents.h" | 66 #include "core/inspector/InstrumentingAgents.h" |
| 69 #include "core/loader/CookieJar.h" | 67 #include "core/loader/CookieJar.h" |
| 70 #include "core/loader/DocumentLoader.h" | 68 #include "core/loader/DocumentLoader.h" |
| 71 #include "core/loader/FrameLoadRequest.h" | 69 #include "core/loader/FrameLoadRequest.h" |
| 72 #include "core/loader/FrameLoader.h" | 70 #include "core/loader/FrameLoader.h" |
| 73 #include "core/page/Page.h" | 71 #include "core/page/Page.h" |
| 74 #include "platform/Cookie.h" | 72 #include "platform/Cookie.h" |
| 75 #include "platform/JSONValues.h" | 73 #include "platform/JSONValues.h" |
| 76 #include "platform/UserGestureIndicator.h" | 74 #include "platform/UserGestureIndicator.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 108 |
| 111 KURL urlWithoutFragment(const KURL& url) | 109 KURL urlWithoutFragment(const KURL& url) |
| 112 { | 110 { |
| 113 KURL result = url; | 111 KURL result = url; |
| 114 result.removeFragmentIdentifier(); | 112 result.removeFragmentIdentifier(); |
| 115 return result; | 113 return result; |
| 116 } | 114 } |
| 117 | 115 |
| 118 } | 116 } |
| 119 | 117 |
| 120 class InspectorPageAgent::GetResourceContentLoadListener FINAL : public VoidCall
back { | |
| 121 public: | |
| 122 GetResourceContentLoadListener(InspectorPageAgent*, const String& frameId, c
onst String& url, PassRefPtr<GetResourceContentCallback>); | |
| 123 virtual void handleEvent() OVERRIDE; | |
| 124 private: | |
| 125 InspectorPageAgent* m_pageAgent; | |
| 126 String m_frameId; | |
| 127 String m_url; | |
| 128 RefPtr<GetResourceContentCallback> m_callback; | |
| 129 }; | |
| 130 | |
| 131 InspectorPageAgent::GetResourceContentLoadListener::GetResourceContentLoadListen
er(InspectorPageAgent* pageAgent, const String& frameId, const String& url, Pass
RefPtr<GetResourceContentCallback> callback) | |
| 132 : m_pageAgent(pageAgent) | |
| 133 , m_frameId(frameId) | |
| 134 , m_url(url) | |
| 135 , m_callback(callback) | |
| 136 { | |
| 137 } | |
| 138 | |
| 139 void InspectorPageAgent::GetResourceContentLoadListener::handleEvent() | |
| 140 { | |
| 141 if (!m_callback->isActive()) | |
| 142 return; | |
| 143 m_pageAgent->getResourceContentAfterResourcesContentLoaded(m_frameId, m_url,
m_callback); | |
| 144 } | |
| 145 | |
| 146 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEn
codingName, String* result) | 118 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEn
codingName, String* result) |
| 147 { | 119 { |
| 148 if (buffer) { | 120 if (buffer) { |
| 149 WTF::TextEncoding encoding(textEncodingName); | 121 WTF::TextEncoding encoding(textEncodingName); |
| 150 if (!encoding.isValid()) | 122 if (!encoding.isValid()) |
| 151 encoding = WindowsLatin1Encoding(); | 123 encoding = WindowsLatin1Encoding(); |
| 152 *result = encoding.decode(buffer, size); | 124 *result = encoding.decode(buffer, size); |
| 153 return true; | 125 return true; |
| 154 } | 126 } |
| 155 return false; | 127 return false; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 { | 246 { |
| 275 return adoptPtr(new InspectorPageAgent(page, injectedScriptManager, client,
overlay)); | 247 return adoptPtr(new InspectorPageAgent(page, injectedScriptManager, client,
overlay)); |
| 276 } | 248 } |
| 277 | 249 |
| 278 // static | 250 // static |
| 279 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) |
| 280 { | 252 { |
| 281 DocumentLoader* loader = assertDocumentLoader(errorString, frame); | 253 DocumentLoader* loader = assertDocumentLoader(errorString, frame); |
| 282 if (!loader) | 254 if (!loader) |
| 283 return; | 255 return; |
| 284 | |
| 285 if (!cachedResourceContent(cachedResource(frame, url), result, base64Encoded
)) | 256 if (!cachedResourceContent(cachedResource(frame, url), result, base64Encoded
)) |
| 286 *errorString = "No resource with given URL found"; | 257 *errorString = "No resource with given URL found"; |
| 287 } | 258 } |
| 288 | 259 |
| 289 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) | 260 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) |
| 290 { | 261 { |
| 291 Document* document = frame->document(); | 262 Resource* cachedResource = frame->document()->fetcher()->cachedResource(url)
; |
| 292 if (!document) | |
| 293 return 0; | |
| 294 Resource* cachedResource = document->fetcher()->cachedResource(url); | |
| 295 if (!cachedResource) { | |
| 296 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame
); | |
| 297 for (Vector<Document*>::const_iterator it = allImports.begin(); it != al
lImports.end(); ++it) { | |
| 298 Document* import = *it; | |
| 299 cachedResource = import->fetcher()->cachedResource(url); | |
| 300 if (cachedResource) | |
| 301 break; | |
| 302 } | |
| 303 } | |
| 304 if (!cachedResource) | 263 if (!cachedResource) |
| 305 cachedResource = memoryCache()->resourceForURL(url); | 264 cachedResource = memoryCache()->resourceForURL(url); |
| 306 return cachedResource; | 265 return cachedResource; |
| 307 } | 266 } |
| 308 | 267 |
| 309 TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::resourceTypeJson(Inspe
ctorPageAgent::ResourceType resourceType) | 268 TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::resourceTypeJson(Inspe
ctorPageAgent::ResourceType resourceType) |
| 310 { | 269 { |
| 311 switch (resourceType) { | 270 switch (resourceType) { |
| 312 case DocumentResource: | 271 case DocumentResource: |
| 313 return TypeBuilder::Page::ResourceType::Document; | 272 return TypeBuilder::Page::ResourceType::Document; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 updateViewMetricsFromState(); | 396 updateViewMetricsFromState(); |
| 438 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); | 397 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); |
| 439 } | 398 } |
| 440 } | 399 } |
| 441 | 400 |
| 442 void InspectorPageAgent::enable(ErrorString*) | 401 void InspectorPageAgent::enable(ErrorString*) |
| 443 { | 402 { |
| 444 m_enabled = true; | 403 m_enabled = true; |
| 445 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); | 404 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); |
| 446 m_instrumentingAgents->setInspectorPageAgent(this); | 405 m_instrumentingAgents->setInspectorPageAgent(this); |
| 447 m_inspectorResourceContentLoader = adoptPtr(new InspectorResourceContentLoad
er(m_page)); | |
| 448 } | 406 } |
| 449 | 407 |
| 450 void InspectorPageAgent::disable(ErrorString*) | 408 void InspectorPageAgent::disable(ErrorString*) |
| 451 { | 409 { |
| 452 m_enabled = false; | 410 m_enabled = false; |
| 453 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); | 411 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); |
| 454 m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad); | 412 m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad); |
| 455 m_overlay->hide(); | 413 m_overlay->hide(); |
| 456 m_instrumentingAgents->setInspectorPageAgent(0); | 414 m_instrumentingAgents->setInspectorPageAgent(0); |
| 457 m_inspectorResourceContentLoader.clear(); | |
| 458 m_deviceMetricsOverridden = false; | 415 m_deviceMetricsOverridden = false; |
| 459 | 416 |
| 460 setShowPaintRects(0, false); | 417 setShowPaintRects(0, false); |
| 461 setShowDebugBorders(0, false); | 418 setShowDebugBorders(0, false); |
| 462 setShowFPSCounter(0, false); | 419 setShowFPSCounter(0, false); |
| 463 setEmulatedMedia(0, String()); | 420 setEmulatedMedia(0, String()); |
| 464 setContinuousPaintingEnabled(0, false); | 421 setContinuousPaintingEnabled(0, false); |
| 465 setShowScrollBottleneckRects(0, false); | 422 setShowScrollBottleneckRects(0, false); |
| 466 setShowViewportSizeOnResize(0, false, 0); | 423 setShowViewportSizeOnResize(0, false, 0); |
| 467 | 424 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 RefPtr<TypeBuilder::Array<TypeBuilder::Page::Cookie> > cookies = TypeBuilder
::Array<TypeBuilder::Page::Cookie>::create(); | 504 RefPtr<TypeBuilder::Array<TypeBuilder::Page::Cookie> > cookies = TypeBuilder
::Array<TypeBuilder::Page::Cookie>::create(); |
| 548 | 505 |
| 549 ListHashSet<Cookie>::iterator end = cookiesList.end(); | 506 ListHashSet<Cookie>::iterator end = cookiesList.end(); |
| 550 ListHashSet<Cookie>::iterator it = cookiesList.begin(); | 507 ListHashSet<Cookie>::iterator it = cookiesList.begin(); |
| 551 for (int i = 0; it != end; ++it, i++) | 508 for (int i = 0; it != end; ++it, i++) |
| 552 cookies->addItem(buildObjectForCookie(*it)); | 509 cookies->addItem(buildObjectForCookie(*it)); |
| 553 | 510 |
| 554 return cookies; | 511 return cookies; |
| 555 } | 512 } |
| 556 | 513 |
| 557 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult, bool skipXHRs) | 514 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult) |
| 558 { | 515 { |
| 559 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); | 516 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); |
| 560 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); | 517 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); |
| 561 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { | 518 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { |
| 562 Resource* cachedResource = it->value.get(); | 519 Resource* cachedResource = it->value.get(); |
| 563 | 520 |
| 564 switch (cachedResource->type()) { | 521 switch (cachedResource->type()) { |
| 565 case Resource::Image: | 522 case Resource::Image: |
| 566 // Skip images that were not auto loaded (images disabled in the use
r agent). | 523 // Skip images that were not auto loaded (images disabled in the use
r agent). |
| 567 if (toImageResource(cachedResource)->stillNeedsLoad()) | 524 if (toImageResource(cachedResource)->stillNeedsLoad()) |
| 568 continue; | 525 continue; |
| 569 break; | 526 break; |
| 570 case Resource::Font: | 527 case Resource::Font: |
| 571 // Skip fonts that were referenced in CSS but never used/downloaded. | 528 // Skip fonts that were referenced in CSS but never used/downloaded. |
| 572 if (toFontResource(cachedResource)->stillNeedsLoad()) | 529 if (toFontResource(cachedResource)->stillNeedsLoad()) |
| 573 continue; | 530 continue; |
| 574 break; | 531 break; |
| 575 case Resource::Raw: | |
| 576 if (skipXHRs) | |
| 577 continue; | |
| 578 break; | |
| 579 default: | 532 default: |
| 580 // All other Resource types download immediately. | 533 // All other Resource types download immediately. |
| 581 break; | 534 break; |
| 582 } | 535 } |
| 583 | 536 |
| 584 result.append(cachedResource); | 537 result.append(cachedResource); |
| 585 } | 538 } |
| 586 } | 539 } |
| 587 | 540 |
| 588 // static | 541 static Vector<Document*> importsForFrame(LocalFrame* frame) |
| 589 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) | |
| 590 { | 542 { |
| 591 Vector<Document*> result; | 543 Vector<Document*> result; |
| 592 Document* rootDocument = frame->document(); | 544 Document* rootDocument = frame->document(); |
| 593 | 545 |
| 594 if (HTMLImportsController* controller = rootDocument->importsController()) { | 546 if (HTMLImportsController* controller = rootDocument->importsController()) { |
| 595 for (size_t i = 0; i < controller->loaderCount(); ++i) { | 547 for (size_t i = 0; i < controller->loaderCount(); ++i) { |
| 596 if (Document* document = controller->loaderAt(i)->document()) | 548 if (Document* document = controller->loaderAt(i)->document()) |
| 597 result.append(document); | 549 result.append(document); |
| 598 } | 550 } |
| 599 } | 551 } |
| 600 | 552 |
| 601 return result; | 553 return result; |
| 602 } | 554 } |
| 603 | 555 |
| 604 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame, bool skipXHR
s) | 556 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) |
| 605 { | 557 { |
| 606 Vector<Resource*> result; | 558 Vector<Resource*> result; |
| 607 Document* rootDocument = frame->document(); | 559 Document* rootDocument = frame->document(); |
| 608 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); | 560 Vector<Document*> loaders = importsForFrame(frame); |
| 609 | 561 |
| 610 cachedResourcesForDocument(rootDocument, result, skipXHRs); | 562 cachedResourcesForDocument(rootDocument, result); |
| 611 for (size_t i = 0; i < loaders.size(); ++i) | 563 for (size_t i = 0; i < loaders.size(); ++i) |
| 612 cachedResourcesForDocument(loaders[i], result, skipXHRs); | 564 cachedResourcesForDocument(loaders[i], result); |
| 613 | 565 |
| 614 return result; | 566 return result; |
| 615 } | 567 } |
| 616 | 568 |
| 617 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) | 569 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) |
| 618 { | 570 { |
| 619 Vector<KURL> result; | 571 Vector<KURL> result; |
| 620 | 572 |
| 621 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); | 573 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); |
| 622 | 574 |
| 623 Vector<Resource*> allResources = cachedResourcesForFrame(frame, false); | 575 Vector<Resource*> allResources = cachedResourcesForFrame(frame); |
| 624 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) | 576 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) |
| 625 result.append(urlWithoutFragment((*it)->url())); | 577 result.append(urlWithoutFragment((*it)->url())); |
| 626 | 578 |
| 627 return result; | 579 return result; |
| 628 } | 580 } |
| 629 | 581 |
| 630 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) | 582 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) |
| 631 { | 583 { |
| 632 ListHashSet<Cookie> rawCookiesList; | 584 ListHashSet<Cookie> rawCookiesList; |
| 633 | 585 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 657 if (frame->isLocalFrame()) | 609 if (frame->isLocalFrame()) |
| 658 WebCore::deleteCookie(toLocalFrame(frame)->document(), parsedURL, co
okieName); | 610 WebCore::deleteCookie(toLocalFrame(frame)->document(), parsedURL, co
okieName); |
| 659 } | 611 } |
| 660 } | 612 } |
| 661 | 613 |
| 662 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page:
:FrameResourceTree>& object) | 614 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page:
:FrameResourceTree>& object) |
| 663 { | 615 { |
| 664 object = buildObjectForFrameTree(m_page->deprecatedLocalMainFrame()); | 616 object = buildObjectForFrameTree(m_page->deprecatedLocalMainFrame()); |
| 665 } | 617 } |
| 666 | 618 |
| 667 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(const Str
ing& frameId, const String& url, PassRefPtr<GetResourceContentCallback> callback
) | 619 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri
ng& frameId, const String& url, String* content, bool* base64Encoded) |
| 668 { | 620 { |
| 669 ErrorString errorString; | 621 LocalFrame* frame = assertFrame(errorString, frameId); |
| 670 LocalFrame* frame = assertFrame(&errorString, frameId); | 622 if (!frame) |
| 671 if (!frame) { | |
| 672 callback->sendFailure(errorString); | |
| 673 return; | 623 return; |
| 674 } | 624 resourceContent(errorString, frame, KURL(ParsedURLString, url), content, bas
e64Encoded); |
| 675 String content; | |
| 676 bool base64Encoded; | |
| 677 resourceContent(&errorString, frame, KURL(ParsedURLString, url), &content, &
base64Encoded); | |
| 678 if (!errorString.isEmpty()) { | |
| 679 callback->sendFailure(errorString); | |
| 680 return; | |
| 681 } | |
| 682 callback->sendSuccess(content, base64Encoded); | |
| 683 } | |
| 684 | |
| 685 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri
ng& frameId, const String& url, PassRefPtr<GetResourceContentCallback> callback) | |
| 686 { | |
| 687 if (!m_inspectorResourceContentLoader) { | |
| 688 callback->sendFailure("Agent was not enabled before sending content requ
ests."); | |
| 689 return; | |
| 690 } | |
| 691 m_inspectorResourceContentLoader->addListener(adoptPtr(new GetResourceConten
tLoadListener(this, frameId, url, callback))); | |
| 692 } | 625 } |
| 693 | 626 |
| 694 static bool textContentForResource(Resource* cachedResource, String* result) | 627 static bool textContentForResource(Resource* cachedResource, String* result) |
| 695 { | 628 { |
| 696 if (hasTextContent(cachedResource)) { | 629 if (hasTextContent(cachedResource)) { |
| 697 String content; | 630 String content; |
| 698 bool base64Encoded; | 631 bool base64Encoded; |
| 699 if (InspectorPageAgent::cachedResourceContent(cachedResource, result, &b
ase64Encoded)) { | 632 if (InspectorPageAgent::cachedResourceContent(cachedResource, result, &b
ase64Encoded)) { |
| 700 ASSERT(!base64Encoded); | 633 ASSERT(!base64Encoded); |
| 701 return true; | 634 return true; |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 | 850 |
| 918 void InspectorPageAgent::loadEventFired(LocalFrame* frame) | 851 void InspectorPageAgent::loadEventFired(LocalFrame* frame) |
| 919 { | 852 { |
| 920 if (!frame->isMainFrame()) | 853 if (!frame->isMainFrame()) |
| 921 return; | 854 return; |
| 922 m_frontend->loadEventFired(currentTime()); | 855 m_frontend->loadEventFired(currentTime()); |
| 923 } | 856 } |
| 924 | 857 |
| 925 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) | 858 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) |
| 926 { | 859 { |
| 927 // FIXME: If "frame" is always guaranteed to be in the same Page as loader->
frame() | 860 // FIXME: If "frame" is always guarenteed to be in the same Page as loader->
frame() |
| 928 // then all we need to check here is loader->frame()->isMainFrame() | 861 // then all we need to check here is loader->frame()->isMainFrame() |
| 929 // and we don't need "frame" at all. | 862 // and we don't need "frame" at all. |
| 930 if (loader->frame() == m_page->mainFrame()) { | 863 if (loader->frame() == m_page->mainFrame()) { |
| 931 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; | 864 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; |
| 932 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; | 865 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; |
| 933 m_pendingScriptToEvaluateOnLoadOnce = String(); | 866 m_pendingScriptToEvaluateOnLoadOnce = String(); |
| 934 m_pendingScriptPreprocessor = String(); | 867 m_pendingScriptPreprocessor = String(); |
| 935 if (m_inspectorResourceContentLoader) | |
| 936 m_inspectorResourceContentLoader->stop(); | |
| 937 } | 868 } |
| 938 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); | 869 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); |
| 939 } | 870 } |
| 940 | 871 |
| 941 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) | 872 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) |
| 942 { | 873 { |
| 943 Frame* parentFrame = frame->tree().parent(); | 874 Frame* parentFrame = frame->tree().parent(); |
| 944 if (!parentFrame->isLocalFrame()) | 875 if (!parentFrame->isLocalFrame()) |
| 945 parentFrame = 0; | 876 parentFrame = 0; |
| 946 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame))
); | 877 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame))
); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 } | 1095 } |
| 1165 | 1096 |
| 1166 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) | 1097 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) |
| 1167 { | 1098 { |
| 1168 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); | 1099 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); |
| 1169 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); | 1100 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); |
| 1170 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() | 1101 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() |
| 1171 .setFrame(frameObject) | 1102 .setFrame(frameObject) |
| 1172 .setResources(subresources); | 1103 .setResources(subresources); |
| 1173 | 1104 |
| 1174 Vector<Resource*> allResources = cachedResourcesForFrame(frame, true); | 1105 Vector<Resource*> allResources = cachedResourcesForFrame(frame); |
| 1175 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { | 1106 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { |
| 1176 Resource* cachedResource = *it; | 1107 Resource* cachedResource = *it; |
| 1177 | 1108 |
| 1178 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1109 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
| 1179 .setUrl(urlWithoutFragment(cachedResource->url()).string()) | 1110 .setUrl(urlWithoutFragment(cachedResource->url()).string()) |
| 1180 .setType(cachedResourceTypeJson(*cachedResource)) | 1111 .setType(cachedResourceTypeJson(*cachedResource)) |
| 1181 .setMimeType(cachedResource->response().mimeType()); | 1112 .setMimeType(cachedResource->response().mimeType()); |
| 1182 if (cachedResource->wasCanceled()) | 1113 if (cachedResource->wasCanceled()) |
| 1183 resourceObject->setCanceled(true); | 1114 resourceObject->setCanceled(true); |
| 1184 else if (cachedResource->status() == Resource::LoadError) | 1115 else if (cachedResource->status() == Resource::LoadError) |
| 1185 resourceObject->setFailed(true); | 1116 resourceObject->setFailed(true); |
| 1186 subresources->addItem(resourceObject); | 1117 subresources->addItem(resourceObject); |
| 1187 } | 1118 } |
| 1188 | 1119 |
| 1189 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame); | 1120 Vector<Document*> allImports = importsForFrame(frame); |
| 1190 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp
orts.end(); ++it) { | 1121 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp
orts.end(); ++it) { |
| 1191 Document* import = *it; | 1122 Document* import = *it; |
| 1192 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1123 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
| 1193 .setUrl(urlWithoutFragment(import->url()).string()) | 1124 .setUrl(urlWithoutFragment(import->url()).string()) |
| 1194 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) | 1125 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) |
| 1195 .setMimeType(import->suggestedMIMEType()); | 1126 .setMimeType(import->suggestedMIMEType()); |
| 1196 subresources->addItem(resourceObject); | 1127 subresources->addItem(resourceObject); |
| 1197 } | 1128 } |
| 1198 | 1129 |
| 1199 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; | 1130 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 } | 1270 } |
| 1340 | 1271 |
| 1341 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1272 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
| 1342 { | 1273 { |
| 1343 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1274 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
| 1344 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1275 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
| 1345 } | 1276 } |
| 1346 | 1277 |
| 1347 } // namespace WebCore | 1278 } // namespace WebCore |
| 1348 | 1279 |
| OLD | NEW |