| 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/Resource.h" | 44 #include "core/fetch/Resource.h" |
| 45 #include "core/fetch/ResourceFetcher.h" | 45 #include "core/fetch/ResourceFetcher.h" |
| 46 #include "core/frame/LocalFrame.h" | 46 #include "core/frame/LocalFrame.h" |
| 47 #include "core/html/HTMLFrameOwnerElement.h" | 47 #include "core/html/HTMLFrameOwnerElement.h" |
| 48 #include "core/html/VoidCallback.h" | 48 #include "core/html/VoidCallback.h" |
| 49 #include "core/html/imports/HTMLImportLoader.h" | 49 #include "core/html/imports/HTMLImportLoader.h" |
| 50 #include "core/html/imports/HTMLImportsController.h" | 50 #include "core/html/imports/HTMLImportsController.h" |
| 51 #include "core/html/parser/TextResourceDecoder.h" | 51 #include "core/html/parser/TextResourceDecoder.h" |
| 52 #include "core/inspector/ContentSearchUtils.h" | 52 #include "core/inspector/ContentSearchUtils.h" |
| 53 #include "core/inspector/DOMPatchSupport.h" | 53 #include "core/inspector/DOMPatchSupport.h" |
| 54 #include "core/inspector/IdentifiersFactory.h" | |
| 55 #include "core/inspector/InspectorCSSAgent.h" | 54 #include "core/inspector/InspectorCSSAgent.h" |
| 56 #include "core/inspector/InspectorDebuggerAgent.h" | 55 #include "core/inspector/InspectorDebuggerAgent.h" |
| 56 #include "core/inspector/InspectorIdentifiers.h" |
| 57 #include "core/inspector/InspectorInstrumentation.h" | 57 #include "core/inspector/InspectorInstrumentation.h" |
| 58 #include "core/inspector/InspectorOverlay.h" | 58 #include "core/inspector/InspectorOverlay.h" |
| 59 #include "core/inspector/InspectorResourceContentLoader.h" | 59 #include "core/inspector/InspectorResourceContentLoader.h" |
| 60 #include "core/inspector/InspectorState.h" | 60 #include "core/inspector/InspectorState.h" |
| 61 #include "core/inspector/InstrumentingAgents.h" | 61 #include "core/inspector/InstrumentingAgents.h" |
| 62 #include "core/loader/DocumentLoader.h" | 62 #include "core/loader/DocumentLoader.h" |
| 63 #include "core/loader/FrameLoader.h" | 63 #include "core/loader/FrameLoader.h" |
| 64 #include "platform/JSONValues.h" | 64 #include "platform/JSONValues.h" |
| 65 #include "platform/MIMETypeRegistry.h" | 65 #include "platform/MIMETypeRegistry.h" |
| 66 #include "platform/PlatformResourceLoader.h" | 66 #include "platform/PlatformResourceLoader.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 namespace { | 85 namespace { |
| 86 | 86 |
| 87 KURL urlWithoutFragment(const KURL& url) | 87 KURL urlWithoutFragment(const KURL& url) |
| 88 { | 88 { |
| 89 KURL result = url; | 89 KURL result = url; |
| 90 result.removeFragmentIdentifier(); | 90 result.removeFragmentIdentifier(); |
| 91 return result; | 91 return result; |
| 92 } | 92 } |
| 93 | 93 |
| 94 String frameId(LocalFrame* frame) |
| 95 { |
| 96 return frame ? InspectorIdentifiers<LocalFrame>::identifier(frame) : ""; |
| 97 } |
| 98 |
| 94 } | 99 } |
| 95 | 100 |
| 96 class InspectorPageAgent::GetResourceContentLoadListener final : public VoidCall
back { | 101 class InspectorPageAgent::GetResourceContentLoadListener final : public VoidCall
back { |
| 97 public: | 102 public: |
| 98 GetResourceContentLoadListener(InspectorPageAgent*, const String& frameId, c
onst String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallback>); | 103 GetResourceContentLoadListener(InspectorPageAgent*, const String& frameId, c
onst String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallback>); |
| 99 DECLARE_VIRTUAL_TRACE(); | 104 DECLARE_VIRTUAL_TRACE(); |
| 100 virtual void handleEvent() override; | 105 virtual void handleEvent() override; |
| 101 private: | 106 private: |
| 102 RawPtrWillBeMember<InspectorPageAgent> m_pageAgent; | 107 RawPtrWillBeMember<InspectorPageAgent> m_pageAgent; |
| 103 String m_frameId; | 108 String m_frameId; |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) | 668 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) |
| 664 { | 669 { |
| 665 Frame* parentFrame = frame->tree().parent(); | 670 Frame* parentFrame = frame->tree().parent(); |
| 666 if (!parentFrame->isLocalFrame()) | 671 if (!parentFrame->isLocalFrame()) |
| 667 parentFrame = 0; | 672 parentFrame = 0; |
| 668 frontend()->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame))
); | 673 frontend()->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame))
); |
| 669 } | 674 } |
| 670 | 675 |
| 671 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame) | 676 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame) |
| 672 { | 677 { |
| 673 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f
rame); | 678 frontend()->frameDetached(frameId(frame)); |
| 674 if (iterator != m_frameToIdentifier.end()) { | |
| 675 frontend()->frameDetached(iterator->value); | |
| 676 m_identifierToFrame.remove(iterator->value); | |
| 677 m_frameToIdentifier.remove(iterator); | |
| 678 } | |
| 679 } | 679 } |
| 680 | 680 |
| 681 FrameHost* InspectorPageAgent::frameHost() | 681 FrameHost* InspectorPageAgent::frameHost() |
| 682 { | 682 { |
| 683 return m_inspectedFrame->host(); | 683 return m_inspectedFrame->host(); |
| 684 } | 684 } |
| 685 | 685 |
| 686 LocalFrame* InspectorPageAgent::frameForId(const String& frameId) | 686 LocalFrame* InspectorPageAgent::frameForId(const String& frameId) |
| 687 { | 687 { |
| 688 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId); | 688 LocalFrame* frame = InspectorIdentifiers<LocalFrame>::lookup(frameId); |
| 689 } | 689 return frame && frame->instrumentingAgents() == m_inspectedFrame->instrument
ingAgents() ? frame : nullptr; |
| 690 | |
| 691 String InspectorPageAgent::frameId(LocalFrame* frame) | |
| 692 { | |
| 693 if (!frame) | |
| 694 return ""; | |
| 695 String identifier = m_frameToIdentifier.get(frame); | |
| 696 if (identifier.isNull()) { | |
| 697 identifier = IdentifiersFactory::createIdentifier(); | |
| 698 m_frameToIdentifier.set(frame, identifier); | |
| 699 m_identifierToFrame.set(identifier, frame); | |
| 700 } | |
| 701 return identifier; | |
| 702 } | |
| 703 | |
| 704 bool InspectorPageAgent::hasIdForFrame(LocalFrame* frame) const | |
| 705 { | |
| 706 return frame && m_frameToIdentifier.contains(frame); | |
| 707 } | |
| 708 | |
| 709 String InspectorPageAgent::loaderId(DocumentLoader* loader) | |
| 710 { | |
| 711 if (!loader) | |
| 712 return ""; | |
| 713 String identifier = m_loaderToIdentifier.get(loader); | |
| 714 if (identifier.isNull()) { | |
| 715 identifier = IdentifiersFactory::createIdentifier(); | |
| 716 m_loaderToIdentifier.set(loader, identifier); | |
| 717 } | |
| 718 return identifier; | |
| 719 } | 690 } |
| 720 | 691 |
| 721 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin
RawString) | 692 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin
RawString) |
| 722 { | 693 { |
| 723 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN
ext(inspectedFrame())) { | 694 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN
ext(inspectedFrame())) { |
| 724 if (!frame->isLocalFrame()) | 695 if (!frame->isLocalFrame()) |
| 725 continue; | 696 continue; |
| 726 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()-
>securityOrigin(); | 697 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()-
>securityOrigin(); |
| 727 if (documentOrigin->toRawString() == originRawString) | 698 if (documentOrigin->toRawString() == originRawString) |
| 728 return toLocalFrame(frame); | 699 return toLocalFrame(frame); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 745 | 716 |
| 746 // static | 717 // static |
| 747 DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString* errorStrin
g, LocalFrame* frame) | 718 DocumentLoader* InspectorPageAgent::assertDocumentLoader(ErrorString* errorStrin
g, LocalFrame* frame) |
| 748 { | 719 { |
| 749 DocumentLoader* documentLoader = frame->loader().documentLoader(); | 720 DocumentLoader* documentLoader = frame->loader().documentLoader(); |
| 750 if (!documentLoader) | 721 if (!documentLoader) |
| 751 *errorString = "No documentLoader for given frame found"; | 722 *errorString = "No documentLoader for given frame found"; |
| 752 return documentLoader; | 723 return documentLoader; |
| 753 } | 724 } |
| 754 | 725 |
| 755 void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader* loader) | |
| 756 { | |
| 757 HashMap<DocumentLoader*, String>::iterator iterator = m_loaderToIdentifier.f
ind(loader); | |
| 758 if (iterator != m_loaderToIdentifier.end()) | |
| 759 m_loaderToIdentifier.remove(iterator); | |
| 760 } | |
| 761 | |
| 762 void InspectorPageAgent::frameStartedLoading(LocalFrame* frame) | 726 void InspectorPageAgent::frameStartedLoading(LocalFrame* frame) |
| 763 { | 727 { |
| 764 frontend()->frameStartedLoading(frameId(frame)); | 728 frontend()->frameStartedLoading(frameId(frame)); |
| 765 } | 729 } |
| 766 | 730 |
| 767 void InspectorPageAgent::frameStoppedLoading(LocalFrame* frame) | 731 void InspectorPageAgent::frameStoppedLoading(LocalFrame* frame) |
| 768 { | 732 { |
| 769 frontend()->frameStoppedLoading(frameId(frame)); | 733 frontend()->frameStoppedLoading(frameId(frame)); |
| 770 } | 734 } |
| 771 | 735 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 void InspectorPageAgent::didRecalculateStyle(int) | 780 void InspectorPageAgent::didRecalculateStyle(int) |
| 817 { | 781 { |
| 818 if (m_enabled) | 782 if (m_enabled) |
| 819 m_overlay->update(); | 783 m_overlay->update(); |
| 820 } | 784 } |
| 821 | 785 |
| 822 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Loc
alFrame* frame) | 786 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Loc
alFrame* frame) |
| 823 { | 787 { |
| 824 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre
ate() | 788 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre
ate() |
| 825 .setId(frameId(frame)) | 789 .setId(frameId(frame)) |
| 826 .setLoaderId(loaderId(frame->loader().documentLoader())) | 790 .setLoaderId(InspectorIdentifiers<DocumentLoader>::identifier(frame->loa
der().documentLoader())) |
| 827 .setUrl(urlWithoutFragment(frame->document()->url()).string()) | 791 .setUrl(urlWithoutFragment(frame->document()->url()).string()) |
| 828 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) | 792 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) |
| 829 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); | 793 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); |
| 830 // FIXME: This doesn't work for OOPI. | 794 // FIXME: This doesn't work for OOPI. |
| 831 Frame* parentFrame = frame->tree().parent(); | 795 Frame* parentFrame = frame->tree().parent(); |
| 832 if (parentFrame && parentFrame->isLocalFrame()) | 796 if (parentFrame && parentFrame->isLocalFrame()) |
| 833 frameObject->setParentId(frameId(toLocalFrame(parentFrame))); | 797 frameObject->setParentId(frameId(toLocalFrame(parentFrame))); |
| 834 if (frame->deprecatedLocalOwner()) { | 798 if (frame->deprecatedLocalOwner()) { |
| 835 AtomicString name = frame->deprecatedLocalOwner()->getNameAttribute(); | 799 AtomicString name = frame->deprecatedLocalOwner()->getNameAttribute(); |
| 836 if (name.isEmpty()) | 800 if (name.isEmpty()) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 { | 873 { |
| 910 visitor->trace(m_inspectedFrame); | 874 visitor->trace(m_inspectedFrame); |
| 911 visitor->trace(m_debuggerAgent); | 875 visitor->trace(m_debuggerAgent); |
| 912 visitor->trace(m_cssAgent); | 876 visitor->trace(m_cssAgent); |
| 913 visitor->trace(m_overlay); | 877 visitor->trace(m_overlay); |
| 914 visitor->trace(m_inspectorResourceContentLoader); | 878 visitor->trace(m_inspectorResourceContentLoader); |
| 915 InspectorBaseAgent::trace(visitor); | 879 InspectorBaseAgent::trace(visitor); |
| 916 } | 880 } |
| 917 | 881 |
| 918 } // namespace blink | 882 } // namespace blink |
| OLD | NEW |