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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "core/html/imports/HTMLImportLoader.h" | 55 #include "core/html/imports/HTMLImportLoader.h" |
56 #include "core/html/imports/HTMLImportsController.h" | 56 #include "core/html/imports/HTMLImportsController.h" |
57 #include "core/html/parser/TextResourceDecoder.h" | 57 #include "core/html/parser/TextResourceDecoder.h" |
58 #include "core/inspector/ContentSearchUtils.h" | 58 #include "core/inspector/ContentSearchUtils.h" |
59 #include "core/inspector/DOMPatchSupport.h" | 59 #include "core/inspector/DOMPatchSupport.h" |
60 #include "core/inspector/IdentifiersFactory.h" | 60 #include "core/inspector/IdentifiersFactory.h" |
61 #include "core/inspector/InjectedScriptManager.h" | 61 #include "core/inspector/InjectedScriptManager.h" |
62 #include "core/inspector/InspectorClient.h" | 62 #include "core/inspector/InspectorClient.h" |
63 #include "core/inspector/InspectorInstrumentation.h" | 63 #include "core/inspector/InspectorInstrumentation.h" |
64 #include "core/inspector/InspectorOverlay.h" | 64 #include "core/inspector/InspectorOverlay.h" |
| 65 #include "core/inspector/InspectorResourceContentLoader.h" |
65 #include "core/inspector/InspectorState.h" | 66 #include "core/inspector/InspectorState.h" |
66 #include "core/inspector/InstrumentingAgents.h" | 67 #include "core/inspector/InstrumentingAgents.h" |
67 #include "core/loader/CookieJar.h" | 68 #include "core/loader/CookieJar.h" |
68 #include "core/loader/DocumentLoader.h" | 69 #include "core/loader/DocumentLoader.h" |
69 #include "core/loader/FrameLoadRequest.h" | 70 #include "core/loader/FrameLoadRequest.h" |
70 #include "core/loader/FrameLoader.h" | 71 #include "core/loader/FrameLoader.h" |
71 #include "core/page/Page.h" | 72 #include "core/page/Page.h" |
72 #include "platform/Cookie.h" | 73 #include "platform/Cookie.h" |
73 #include "platform/JSONValues.h" | 74 #include "platform/JSONValues.h" |
74 #include "platform/UserGestureIndicator.h" | 75 #include "platform/UserGestureIndicator.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 updateViewMetricsFromState(); | 397 updateViewMetricsFromState(); |
397 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); | 398 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); |
398 } | 399 } |
399 } | 400 } |
400 | 401 |
401 void InspectorPageAgent::enable(ErrorString*) | 402 void InspectorPageAgent::enable(ErrorString*) |
402 { | 403 { |
403 m_enabled = true; | 404 m_enabled = true; |
404 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); | 405 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); |
405 m_instrumentingAgents->setInspectorPageAgent(this); | 406 m_instrumentingAgents->setInspectorPageAgent(this); |
| 407 m_inspectorResourceContentLoader = adoptPtr(new InspectorResourceContentLoad
er(m_page)); |
406 } | 408 } |
407 | 409 |
408 void InspectorPageAgent::disable(ErrorString*) | 410 void InspectorPageAgent::disable(ErrorString*) |
409 { | 411 { |
410 m_enabled = false; | 412 m_enabled = false; |
411 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); | 413 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); |
412 m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad); | 414 m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad); |
413 m_overlay->hide(); | 415 m_overlay->hide(); |
414 m_instrumentingAgents->setInspectorPageAgent(0); | 416 m_instrumentingAgents->setInspectorPageAgent(0); |
| 417 m_inspectorResourceContentLoader.clear(); |
415 m_deviceMetricsOverridden = false; | 418 m_deviceMetricsOverridden = false; |
416 | 419 |
417 setShowPaintRects(0, false); | 420 setShowPaintRects(0, false); |
418 setShowDebugBorders(0, false); | 421 setShowDebugBorders(0, false); |
419 setShowFPSCounter(0, false); | 422 setShowFPSCounter(0, false); |
420 setEmulatedMedia(0, String()); | 423 setEmulatedMedia(0, String()); |
421 setContinuousPaintingEnabled(0, false); | 424 setContinuousPaintingEnabled(0, false); |
422 setShowScrollBottleneckRects(0, false); | 425 setShowScrollBottleneckRects(0, false); |
423 setShowViewportSizeOnResize(0, false, 0); | 426 setShowViewportSizeOnResize(0, false, 0); |
424 | 427 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 break; | 534 break; |
532 default: | 535 default: |
533 // All other Resource types download immediately. | 536 // All other Resource types download immediately. |
534 break; | 537 break; |
535 } | 538 } |
536 | 539 |
537 result.append(cachedResource); | 540 result.append(cachedResource); |
538 } | 541 } |
539 } | 542 } |
540 | 543 |
541 static Vector<Document*> importsForFrame(LocalFrame* frame) | 544 // static |
| 545 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) |
542 { | 546 { |
543 Vector<Document*> result; | 547 Vector<Document*> result; |
544 Document* rootDocument = frame->document(); | 548 Document* rootDocument = frame->document(); |
545 | 549 |
546 if (HTMLImportsController* controller = rootDocument->importsController()) { | 550 if (HTMLImportsController* controller = rootDocument->importsController()) { |
547 for (size_t i = 0; i < controller->loaderCount(); ++i) { | 551 for (size_t i = 0; i < controller->loaderCount(); ++i) { |
548 if (Document* document = controller->loaderAt(i)->document()) | 552 if (Document* document = controller->loaderAt(i)->document()) |
549 result.append(document); | 553 result.append(document); |
550 } | 554 } |
551 } | 555 } |
552 | 556 |
553 return result; | 557 return result; |
554 } | 558 } |
555 | 559 |
556 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) | 560 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) |
557 { | 561 { |
558 Vector<Resource*> result; | 562 Vector<Resource*> result; |
559 Document* rootDocument = frame->document(); | 563 Document* rootDocument = frame->document(); |
560 Vector<Document*> loaders = importsForFrame(frame); | 564 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); |
561 | 565 |
562 cachedResourcesForDocument(rootDocument, result); | 566 cachedResourcesForDocument(rootDocument, result); |
563 for (size_t i = 0; i < loaders.size(); ++i) | 567 for (size_t i = 0; i < loaders.size(); ++i) |
564 cachedResourcesForDocument(loaders[i], result); | 568 cachedResourcesForDocument(loaders[i], result); |
565 | 569 |
566 return result; | 570 return result; |
567 } | 571 } |
568 | 572 |
569 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) | 573 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) |
570 { | 574 { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 | 854 |
851 void InspectorPageAgent::loadEventFired(LocalFrame* frame) | 855 void InspectorPageAgent::loadEventFired(LocalFrame* frame) |
852 { | 856 { |
853 if (!frame->isMainFrame()) | 857 if (!frame->isMainFrame()) |
854 return; | 858 return; |
855 m_frontend->loadEventFired(currentTime()); | 859 m_frontend->loadEventFired(currentTime()); |
856 } | 860 } |
857 | 861 |
858 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) | 862 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) |
859 { | 863 { |
860 // FIXME: If "frame" is always guarenteed to be in the same Page as loader->
frame() | 864 // FIXME: If "frame" is always guaranteed to be in the same Page as loader->
frame() |
861 // then all we need to check here is loader->frame()->isMainFrame() | 865 // then all we need to check here is loader->frame()->isMainFrame() |
862 // and we don't need "frame" at all. | 866 // and we don't need "frame" at all. |
863 if (loader->frame() == m_page->mainFrame()) { | 867 if (loader->frame() == m_page->mainFrame()) { |
864 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; | 868 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; |
865 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; | 869 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; |
866 m_pendingScriptToEvaluateOnLoadOnce = String(); | 870 m_pendingScriptToEvaluateOnLoadOnce = String(); |
867 m_pendingScriptPreprocessor = String(); | 871 m_pendingScriptPreprocessor = String(); |
| 872 if (m_inspectorResourceContentLoader) |
| 873 m_inspectorResourceContentLoader->stop(); |
868 } | 874 } |
869 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); | 875 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); |
870 } | 876 } |
871 | 877 |
872 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) | 878 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) |
873 { | 879 { |
874 Frame* parentFrame = frame->tree().parent(); | 880 Frame* parentFrame = frame->tree().parent(); |
875 if (!parentFrame->isLocalFrame()) | 881 if (!parentFrame->isLocalFrame()) |
876 parentFrame = 0; | 882 parentFrame = 0; |
877 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame))
); | 883 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame))
); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 .setUrl(urlWithoutFragment(cachedResource->url()).string()) | 1116 .setUrl(urlWithoutFragment(cachedResource->url()).string()) |
1111 .setType(cachedResourceTypeJson(*cachedResource)) | 1117 .setType(cachedResourceTypeJson(*cachedResource)) |
1112 .setMimeType(cachedResource->response().mimeType()); | 1118 .setMimeType(cachedResource->response().mimeType()); |
1113 if (cachedResource->wasCanceled()) | 1119 if (cachedResource->wasCanceled()) |
1114 resourceObject->setCanceled(true); | 1120 resourceObject->setCanceled(true); |
1115 else if (cachedResource->status() == Resource::LoadError) | 1121 else if (cachedResource->status() == Resource::LoadError) |
1116 resourceObject->setFailed(true); | 1122 resourceObject->setFailed(true); |
1117 subresources->addItem(resourceObject); | 1123 subresources->addItem(resourceObject); |
1118 } | 1124 } |
1119 | 1125 |
1120 Vector<Document*> allImports = importsForFrame(frame); | 1126 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame); |
1121 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) { |
1122 Document* import = *it; | 1128 Document* import = *it; |
1123 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1129 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
1124 .setUrl(urlWithoutFragment(import->url()).string()) | 1130 .setUrl(urlWithoutFragment(import->url()).string()) |
1125 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) | 1131 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) |
1126 .setMimeType(import->suggestedMIMEType()); | 1132 .setMimeType(import->suggestedMIMEType()); |
1127 subresources->addItem(resourceObject); | 1133 subresources->addItem(resourceObject); |
1128 } | 1134 } |
1129 | 1135 |
1130 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; | 1136 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr
ray; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 } | 1276 } |
1271 | 1277 |
1272 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1278 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
1273 { | 1279 { |
1274 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1280 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
1275 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1281 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
1276 } | 1282 } |
1277 | 1283 |
1278 } // namespace WebCore | 1284 } // namespace WebCore |
1279 | 1285 |
OLD | NEW |