Chromium Code Reviews| 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 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 582 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR esources.end(); ++it) | 582 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR esources.end(); ++it) |
| 583 result.append(urlWithoutFragment((*it)->url())); | 583 result.append(urlWithoutFragment((*it)->url())); |
| 584 | 584 |
| 585 return result; | 585 return result; |
| 586 } | 586 } |
| 587 | 587 |
| 588 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type Builder::Page::Cookie> >& cookies) | 588 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type Builder::Page::Cookie> >& cookies) |
| 589 { | 589 { |
| 590 ListHashSet<Cookie> rawCookiesList; | 590 ListHashSet<Cookie> rawCookiesList; |
| 591 | 591 |
| 592 for (LocalFrame* frame = mainFrame(); frame; frame = frame->tree().traverseN ext(mainFrame())) { | 592 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(m ainFrame())) { |
| 593 Document* document = frame->document(); | 593 if (!frame->isLocalFrame()) |
| 594 Vector<KURL> allURLs = allResourcesURLsForFrame(frame); | 594 continue; |
| 595 Document* document = toLocalFrame(frame)->document(); | |
| 596 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame)); | |
| 595 for (Vector<KURL>::const_iterator it = allURLs.begin(); it != allURLs.en d(); ++it) { | 597 for (Vector<KURL>::const_iterator it = allURLs.begin(); it != allURLs.en d(); ++it) { |
| 596 Vector<Cookie> docCookiesList; | 598 Vector<Cookie> docCookiesList; |
| 597 getRawCookies(document, *it, docCookiesList); | 599 getRawCookies(document, *it, docCookiesList); |
| 598 int cookiesSize = docCookiesList.size(); | 600 int cookiesSize = docCookiesList.size(); |
| 599 for (int i = 0; i < cookiesSize; i++) { | 601 for (int i = 0; i < cookiesSize; i++) { |
| 600 if (!rawCookiesList.contains(docCookiesList[i])) | 602 if (!rawCookiesList.contains(docCookiesList[i])) |
| 601 rawCookiesList.add(docCookiesList[i]); | 603 rawCookiesList.add(docCookiesList[i]); |
| 602 } | 604 } |
| 603 } | 605 } |
| 604 } | 606 } |
| 605 | 607 |
| 606 cookies = buildArrayForCookies(rawCookiesList); | 608 cookies = buildArrayForCookies(rawCookiesList); |
| 607 } | 609 } |
| 608 | 610 |
| 609 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& url) | 611 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& url) |
| 610 { | 612 { |
| 611 KURL parsedURL(ParsedURLString, url); | 613 KURL parsedURL(ParsedURLString, url); |
| 612 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t raverseNext(m_page->mainFrame())) | 614 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext(m_page->mainFrame())) { |
| 613 WebCore::deleteCookie(frame->document(), parsedURL, cookieName); | 615 if (frame->isLocalFrame()) |
| 616 WebCore::deleteCookie(toLocalFrame(frame)->document(), parsedURL, co okieName); | |
| 617 } | |
| 614 } | 618 } |
| 615 | 619 |
| 616 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page: :FrameResourceTree>& object) | 620 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page: :FrameResourceTree>& object) |
| 617 { | 621 { |
| 618 object = buildObjectForFrameTree(m_page->mainFrame()); | 622 object = buildObjectForFrameTree(m_page->mainFrame()); |
| 619 } | 623 } |
| 620 | 624 |
| 621 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri ng& frameId, const String& url, String* content, bool* base64Encoded) | 625 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri ng& frameId, const String& url, String* content, bool* base64Encoded) |
| 622 { | 626 { |
| 623 LocalFrame* frame = assertFrame(errorString, frameId); | 627 LocalFrame* frame = assertFrame(errorString, frameId); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 866 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; | 870 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; |
| 867 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; | 871 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; |
| 868 m_pendingScriptToEvaluateOnLoadOnce = String(); | 872 m_pendingScriptToEvaluateOnLoadOnce = String(); |
| 869 m_pendingScriptPreprocessor = String(); | 873 m_pendingScriptPreprocessor = String(); |
| 870 } | 874 } |
| 871 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); | 875 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); |
| 872 } | 876 } |
| 873 | 877 |
| 874 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) | 878 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) |
| 875 { | 879 { |
| 876 m_frontend->frameAttached(frameId(frame), frameId(frame->tree().parent())); | 880 LocalFrame* parentFrame = 0; |
| 881 if (frame->tree().parent() && frame->tree().parent()->isLocalFrame()) | |
|
yurys
2014/06/02 07:56:27
Please extract frame->tree().parent() into a varia
kenrb
2014/06/02 15:20:48
Done.
| |
| 882 parentFrame = frame->tree().parent(); | |
| 883 m_frontend->frameAttached(frameId(frame), frameId(parentFrame)); | |
| 877 } | 884 } |
| 878 | 885 |
| 879 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame) | 886 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame) |
| 880 { | 887 { |
| 881 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f rame); | 888 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f rame); |
| 882 if (iterator != m_frameToIdentifier.end()) { | 889 if (iterator != m_frameToIdentifier.end()) { |
| 883 m_frontend->frameDetached(iterator->value); | 890 m_frontend->frameDetached(iterator->value); |
| 884 m_identifierToFrame.remove(iterator->value); | 891 m_identifierToFrame.remove(iterator->value); |
| 885 m_frameToIdentifier.remove(iterator); | 892 m_frameToIdentifier.remove(iterator); |
| 886 } | 893 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 921 String identifier = m_loaderToIdentifier.get(loader); | 928 String identifier = m_loaderToIdentifier.get(loader); |
| 922 if (identifier.isNull()) { | 929 if (identifier.isNull()) { |
| 923 identifier = IdentifiersFactory::createIdentifier(); | 930 identifier = IdentifiersFactory::createIdentifier(); |
| 924 m_loaderToIdentifier.set(loader, identifier); | 931 m_loaderToIdentifier.set(loader, identifier); |
| 925 } | 932 } |
| 926 return identifier; | 933 return identifier; |
| 927 } | 934 } |
| 928 | 935 |
| 929 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin RawString) | 936 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin RawString) |
| 930 { | 937 { |
| 931 for (LocalFrame* frame = m_page->mainFrame(); frame; frame = frame->tree().t raverseNext()) { | 938 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { |
| 932 RefPtr<SecurityOrigin> documentOrigin = frame->document()->securityOrigi n(); | 939 // FIXME: RemoteFrame security origins are not yet available. |
| 940 if (!frame->isLocalFrame()) | |
| 941 continue; | |
| 942 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin(); | |
| 933 if (documentOrigin->toRawString() == originRawString) | 943 if (documentOrigin->toRawString() == originRawString) |
| 934 return frame; | 944 return toLocalFrame(frame); |
| 935 } | 945 } |
| 936 return 0; | 946 return 0; |
| 937 } | 947 } |
| 938 | 948 |
| 939 LocalFrame* InspectorPageAgent::assertFrame(ErrorString* errorString, const Stri ng& frameId) | 949 LocalFrame* InspectorPageAgent::assertFrame(ErrorString* errorString, const Stri ng& frameId) |
| 940 { | 950 { |
| 941 LocalFrame* frame = frameForId(frameId); | 951 LocalFrame* frame = frameForId(frameId); |
| 942 if (!frame) | 952 if (!frame) |
| 943 *errorString = "No frame for given id found"; | 953 *errorString = "No frame for given id found"; |
| 944 return frame; | 954 return frame; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1069 } | 1079 } |
| 1070 | 1080 |
| 1071 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Loc alFrame* frame) | 1081 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Loc alFrame* frame) |
| 1072 { | 1082 { |
| 1073 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre ate() | 1083 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre ate() |
| 1074 .setId(frameId(frame)) | 1084 .setId(frameId(frame)) |
| 1075 .setLoaderId(loaderId(frame->loader().documentLoader())) | 1085 .setLoaderId(loaderId(frame->loader().documentLoader())) |
| 1076 .setUrl(urlWithoutFragment(frame->document()->url()).string()) | 1086 .setUrl(urlWithoutFragment(frame->document()->url()).string()) |
| 1077 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) | 1087 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) |
| 1078 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); | 1088 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); |
| 1079 if (frame->tree().parent()) | 1089 if (frame->tree().parent() && frame->tree().parent()->isLocalFrame()) |
|
yurys
2014/06/02 07:56:27
Ditto.
kenrb
2014/06/02 15:20:48
Done.
| |
| 1080 frameObject->setParentId(frameId(frame->tree().parent())); | 1090 frameObject->setParentId(frameId(frame->tree().parent())); |
| 1081 if (frame->ownerElement()) { | 1091 if (frame->ownerElement()) { |
| 1082 AtomicString name = frame->ownerElement()->getNameAttribute(); | 1092 AtomicString name = frame->ownerElement()->getNameAttribute(); |
| 1083 if (name.isEmpty()) | 1093 if (name.isEmpty()) |
| 1084 name = frame->ownerElement()->getAttribute(HTMLNames::idAttr); | 1094 name = frame->ownerElement()->getAttribute(HTMLNames::idAttr); |
| 1085 frameObject->setName(name); | 1095 frameObject->setName(name); |
| 1086 } | 1096 } |
| 1087 | 1097 |
| 1088 return frameObject; | 1098 return frameObject; |
| 1089 } | 1099 } |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1115 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp orts.end(); ++it) { | 1125 for (Vector<Document*>::const_iterator it = allImports.begin(); it != allImp orts.end(); ++it) { |
| 1116 Document* import = *it; | 1126 Document* import = *it; |
| 1117 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject = TypeBuilder::Page::FrameResourceTree::Resources::create() | 1127 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject = TypeBuilder::Page::FrameResourceTree::Resources::create() |
| 1118 .setUrl(urlWithoutFragment(import->url()).string()) | 1128 .setUrl(urlWithoutFragment(import->url()).string()) |
| 1119 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) | 1129 .setType(resourceTypeJson(InspectorPageAgent::DocumentResource)) |
| 1120 .setMimeType(import->suggestedMIMEType()); | 1130 .setMimeType(import->suggestedMIMEType()); |
| 1121 subresources->addItem(resourceObject); | 1131 subresources->addItem(resourceObject); |
| 1122 } | 1132 } |
| 1123 | 1133 |
| 1124 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr ray; | 1134 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree> > childrenAr ray; |
| 1125 for (LocalFrame* child = frame->tree().firstChild(); child; child = child->t ree().nextSibling()) { | 1135 for (Frame* child = frame->tree().firstChild(); child; child = child->tree() .nextSibling()) { |
| 1136 if (!child->isLocalFrame()) | |
| 1137 continue; | |
| 1126 if (!childrenArray) { | 1138 if (!childrenArray) { |
| 1127 childrenArray = TypeBuilder::Array<TypeBuilder::Page::FrameResourceT ree>::create(); | 1139 childrenArray = TypeBuilder::Array<TypeBuilder::Page::FrameResourceT ree>::create(); |
| 1128 result->setChildFrames(childrenArray); | 1140 result->setChildFrames(childrenArray); |
| 1129 } | 1141 } |
| 1130 childrenArray->addItem(buildObjectForFrameTree(child)); | 1142 childrenArray->addItem(buildObjectForFrameTree(toLocalFrame(child))); |
| 1131 } | 1143 } |
| 1132 return result; | 1144 return result; |
| 1133 } | 1145 } |
| 1134 | 1146 |
| 1135 void InspectorPageAgent::updateViewMetricsFromState() | 1147 void InspectorPageAgent::updateViewMetricsFromState() |
| 1136 { | 1148 { |
| 1137 bool enabled = m_state->getBoolean(PageAgentState::deviceMetricsOverrideEnab led); | 1149 bool enabled = m_state->getBoolean(PageAgentState::deviceMetricsOverrideEnab led); |
| 1138 int width = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScree nWidthOverride)); | 1150 int width = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScree nWidthOverride)); |
| 1139 int height = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScre enHeightOverride)); | 1151 int height = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScre enHeightOverride)); |
| 1140 bool emulateViewport = m_state->getBoolean(PageAgentState::pageAgentEmulateV iewport); | 1152 bool emulateViewport = m_state->getBoolean(PageAgentState::pageAgentEmulateV iewport); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 } | 1281 } |
| 1270 | 1282 |
| 1271 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) | 1283 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) |
| 1272 { | 1284 { |
| 1273 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1285 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
| 1274 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; | 1286 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; |
| 1275 } | 1287 } |
| 1276 | 1288 |
| 1277 } // namespace WebCore | 1289 } // namespace WebCore |
| 1278 | 1290 |
| OLD | NEW |