Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Side by Side Diff: Source/core/inspector/InspectorPageAgent.cpp

Issue 892693006: Revert of DevTools: use per-LocalFrame instrumenting agents instead of per-Page ones. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 495 }
496 } 496 }
497 497
498 void InspectorPageAgent::enable(ErrorString*) 498 void InspectorPageAgent::enable(ErrorString*)
499 { 499 {
500 m_enabled = true; 500 m_enabled = true;
501 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); 501 m_state->setBoolean(PageAgentState::pageAgentEnabled, true);
502 m_instrumentingAgents->setInspectorPageAgent(this); 502 m_instrumentingAgents->setInspectorPageAgent(this);
503 if (m_inspectorResourceContentLoader) 503 if (m_inspectorResourceContentLoader)
504 m_inspectorResourceContentLoader->dispose(); 504 m_inspectorResourceContentLoader->dispose();
505 m_inspectorResourceContentLoader = adoptPtrWillBeNoop(new InspectorResourceC ontentLoader(inspectedFrame())); 505 m_inspectorResourceContentLoader = adoptPtrWillBeNoop(new InspectorResourceC ontentLoader(m_page));
506 } 506 }
507 507
508 void InspectorPageAgent::discardAgent() 508 void InspectorPageAgent::discardAgent()
509 { 509 {
510 if (!m_inspectorResourceContentLoader) 510 if (!m_inspectorResourceContentLoader)
511 return; 511 return;
512 m_inspectorResourceContentLoader->dispose(); 512 m_inspectorResourceContentLoader->dispose();
513 m_inspectorResourceContentLoader.clear(); 513 m_inspectorResourceContentLoader.clear();
514 } 514 }
515 515
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 *error = "Script not found"; 581 *error = "Script not found";
582 return; 582 return;
583 } 583 }
584 scripts->remove(identifier); 584 scripts->remove(identifier);
585 } 585 }
586 586
587 void InspectorPageAgent::reload(ErrorString*, const bool* const optionalIgnoreCa che, const String* optionalScriptToEvaluateOnLoad, const String* optionalScriptP reprocessor) 587 void InspectorPageAgent::reload(ErrorString*, const bool* const optionalIgnoreCa che, const String* optionalScriptToEvaluateOnLoad, const String* optionalScriptP reprocessor)
588 { 588 {
589 m_pendingScriptToEvaluateOnLoadOnce = optionalScriptToEvaluateOnLoad ? *opti onalScriptToEvaluateOnLoad : ""; 589 m_pendingScriptToEvaluateOnLoadOnce = optionalScriptToEvaluateOnLoad ? *opti onalScriptToEvaluateOnLoad : "";
590 m_pendingScriptPreprocessor = optionalScriptPreprocessor ? *optionalScriptPr eprocessor : ""; 590 m_pendingScriptPreprocessor = optionalScriptPreprocessor ? *optionalScriptPr eprocessor : "";
591 inspectedFrame()->reload(asBool(optionalIgnoreCache) ? EndToEndReload : Norm alReload, NotClientRedirect); 591 m_page->mainFrame()->reload(asBool(optionalIgnoreCache) ? EndToEndReload : N ormalReload, NotClientRedirect);
592 } 592 }
593 593
594 void InspectorPageAgent::navigate(ErrorString*, const String& url, String* outFr ameId) 594 void InspectorPageAgent::navigate(ErrorString*, const String& url, String* outFr ameId)
595 { 595 {
596 *outFrameId = frameId(inspectedFrame()); 596 LocalFrame* frame = m_page->deprecatedLocalMainFrame();
597 *outFrameId = frameId(frame);
597 } 598 }
598 599
599 static PassRefPtr<TypeBuilder::Page::Cookie> buildObjectForCookie(const Cookie& cookie) 600 static PassRefPtr<TypeBuilder::Page::Cookie> buildObjectForCookie(const Cookie& cookie)
600 { 601 {
601 return TypeBuilder::Page::Cookie::create() 602 return TypeBuilder::Page::Cookie::create()
602 .setName(cookie.name) 603 .setName(cookie.name)
603 .setValue(cookie.value) 604 .setValue(cookie.value)
604 .setDomain(cookie.domain) 605 .setDomain(cookie.domain)
605 .setPath(cookie.path) 606 .setPath(cookie.path)
606 .setExpires(cookie.expires) 607 .setExpires(cookie.expires)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 for (const auto& resource : allResources) 693 for (const auto& resource : allResources)
693 result.append(urlWithoutFragment(resource->url())); 694 result.append(urlWithoutFragment(resource->url()));
694 695
695 return result; 696 return result;
696 } 697 }
697 698
698 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)
699 { 700 {
700 ListHashSet<Cookie> rawCookiesList; 701 ListHashSet<Cookie> rawCookiesList;
701 702
702 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) { 703 for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(m ainFrame())) {
703 if (!frame->isLocalFrame()) 704 if (!frame->isLocalFrame())
704 continue; 705 continue;
705 Document* document = toLocalFrame(frame)->document(); 706 Document* document = toLocalFrame(frame)->document();
706 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame)); 707 Vector<KURL> allURLs = allResourcesURLsForFrame(toLocalFrame(frame));
707 for (const auto& url : allURLs) { 708 for (const auto& url : allURLs) {
708 Vector<Cookie> docCookiesList; 709 Vector<Cookie> docCookiesList;
709 getRawCookies(document, url, docCookiesList); 710 getRawCookies(document, url, docCookiesList);
710 int cookiesSize = docCookiesList.size(); 711 int cookiesSize = docCookiesList.size();
711 for (int i = 0; i < cookiesSize; i++) { 712 for (int i = 0; i < cookiesSize; i++) {
712 if (!rawCookiesList.contains(docCookiesList[i])) 713 if (!rawCookiesList.contains(docCookiesList[i]))
713 rawCookiesList.add(docCookiesList[i]); 714 rawCookiesList.add(docCookiesList[i]);
714 } 715 }
715 } 716 }
716 } 717 }
717 718
718 cookies = buildArrayForCookies(rawCookiesList); 719 cookies = buildArrayForCookies(rawCookiesList);
719 } 720 }
720 721
721 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& url) 722 void InspectorPageAgent::deleteCookie(ErrorString*, const String& cookieName, co nst String& url)
722 { 723 {
723 KURL parsedURL(ParsedURLString, url); 724 KURL parsedURL(ParsedURLString, url);
724 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) { 725 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext(m_page->mainFrame())) {
725 if (frame->isLocalFrame()) 726 if (frame->isLocalFrame())
726 blink::deleteCookie(toLocalFrame(frame)->document(), parsedURL, cook ieName); 727 blink::deleteCookie(toLocalFrame(frame)->document(), parsedURL, cook ieName);
727 } 728 }
728 } 729 }
729 730
730 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page: :FrameResourceTree>& object) 731 void InspectorPageAgent::getResourceTree(ErrorString*, RefPtr<TypeBuilder::Page: :FrameResourceTree>& object)
731 { 732 {
732 object = buildObjectForFrameTree(inspectedFrame()); 733 object = buildObjectForFrameTree(m_page->deprecatedLocalMainFrame());
733 } 734 }
734 735
735 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(const Str ing& frameId, const String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallba ck> callback) 736 void InspectorPageAgent::getResourceContentAfterResourcesContentLoaded(const Str ing& frameId, const String& url, PassRefPtrWillBeRawPtr<GetResourceContentCallba ck> callback)
736 { 737 {
737 ErrorString errorString; 738 ErrorString errorString;
738 LocalFrame* frame = assertFrame(&errorString, frameId); 739 LocalFrame* frame = assertFrame(&errorString, frameId);
739 if (!frame) { 740 if (!frame) {
740 callback->sendFailure(errorString); 741 callback->sendFailure(errorString);
741 return; 742 return;
742 } 743 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 || scale != currentScale 902 || scale != currentScale
902 || offsetX != currentOffsetX 903 || offsetX != currentOffsetX
903 || offsetY != currentOffsetY; 904 || offsetY != currentOffsetY;
904 } 905 }
905 906
906 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show) 907 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show)
907 { 908 {
908 m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show); 909 m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show);
909 m_client->setShowPaintRects(show); 910 m_client->setShowPaintRects(show);
910 911
911 if (!show && inspectedFrame() && inspectedFrame()->isMainFrame() && inspecte dFrame()->view()) 912 if (!show && mainFrame() && mainFrame()->view())
912 inspectedFrame()->view()->invalidate(); 913 mainFrame()->view()->invalidate();
913 } 914 }
914 915
915 void InspectorPageAgent::setShowDebugBorders(ErrorString* errorString, bool show ) 916 void InspectorPageAgent::setShowDebugBorders(ErrorString* errorString, bool show )
916 { 917 {
917 m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show); 918 m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show);
918 if (show && !compositingEnabled(errorString)) 919 if (show && !compositingEnabled(errorString))
919 return; 920 return;
920 m_client->setShowDebugBorders(show); 921 m_client->setShowDebugBorders(show);
921 } 922 }
922 923
(...skipping 19 matching lines...) Expand all
942 m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show ); 943 m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show );
943 if (show && !compositingEnabled(errorString)) 944 if (show && !compositingEnabled(errorString))
944 return; 945 return;
945 m_client->setShowScrollBottleneckRects(show); 946 m_client->setShowScrollBottleneckRects(show);
946 } 947 }
947 948
948 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl er::Result::Enum* status) 949 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl er::Result::Enum* status)
949 { 950 {
950 bool disabledByScriptController = false; 951 bool disabledByScriptController = false;
951 bool disabledInSettings = false; 952 bool disabledInSettings = false;
952 LocalFrame* frame = inspectedFrame(); 953 LocalFrame* frame = mainFrame();
953 if (frame) { 954 if (frame) {
954 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout ToExecuteScript); 955 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout ToExecuteScript);
955 if (frame->settings()) 956 if (frame->settings())
956 disabledInSettings = !frame->settings()->scriptEnabled(); 957 disabledInSettings = !frame->settings()->scriptEnabled();
957 } 958 }
958 959
959 // Order is important. 960 // Order is important.
960 if (disabledInSettings) 961 if (disabledInSettings)
961 *status = PageCommandHandler::Result::Disabled; 962 *status = PageCommandHandler::Result::Disabled;
962 else if (disabledByScriptController) 963 else if (disabledByScriptController)
963 *status = PageCommandHandler::Result::Forbidden; 964 *status = PageCommandHandler::Result::Forbidden;
964 else 965 else
965 *status = PageCommandHandler::Result::Allowed; 966 *status = PageCommandHandler::Result::Allowed;
966 } 967 }
967 968
968 void InspectorPageAgent::setScriptExecutionDisabled(ErrorString*, bool value) 969 void InspectorPageAgent::setScriptExecutionDisabled(ErrorString*, bool value)
969 { 970 {
970 m_state->setBoolean(PageAgentState::pageAgentScriptExecutionDisabled, value) ; 971 m_state->setBoolean(PageAgentState::pageAgentScriptExecutionDisabled, value) ;
971 if (!inspectedFrame()) 972 if (!mainFrame())
972 return; 973 return;
973 974
974 Settings* settings = inspectedFrame()->settings(); 975 Settings* settings = mainFrame()->settings();
975 if (settings) { 976 if (settings) {
976 m_ignoreScriptsEnabledNotification = true; 977 m_ignoreScriptsEnabledNotification = true;
977 settings->setScriptEnabled(!value); 978 settings->setScriptEnabled(!value);
978 m_ignoreScriptsEnabledNotification = false; 979 m_ignoreScriptsEnabledNotification = false;
979 } 980 }
980 } 981 }
981 982
982 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame) 983 void InspectorPageAgent::didClearDocumentOfWindowObject(LocalFrame* frame)
983 { 984 {
984 if (!m_frontend) 985 if (!m_frontend)
985 return; 986 return;
986 987
987 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr iptsToEvaluateOnLoad); 988 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr iptsToEvaluateOnLoad);
988 if (scripts) { 989 if (scripts) {
989 for (const auto& script : *scripts) { 990 for (const auto& script : *scripts) {
990 String scriptText; 991 String scriptText;
991 if (script.value->asString(&scriptText)) 992 if (script.value->asString(&scriptText))
992 frame->script().executeScriptInMainWorld(scriptText); 993 frame->script().executeScriptInMainWorld(scriptText);
993 } 994 }
994 } 995 }
995 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) 996 if (!m_scriptToEvaluateOnLoadOnce.isEmpty())
996 frame->script().executeScriptInMainWorld(m_scriptToEvaluateOnLoadOnce); 997 frame->script().executeScriptInMainWorld(m_scriptToEvaluateOnLoadOnce);
997 } 998 }
998 999
999 void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame) 1000 void InspectorPageAgent::domContentLoadedEventFired(LocalFrame* frame)
1000 { 1001 {
1001 if (frame != inspectedFrame()) 1002 if (!frame->isMainFrame())
1002 return; 1003 return;
1003 m_frontend->domContentEventFired(currentTime()); 1004 m_frontend->domContentEventFired(currentTime());
1004 } 1005 }
1005 1006
1006 void InspectorPageAgent::loadEventFired(LocalFrame* frame) 1007 void InspectorPageAgent::loadEventFired(LocalFrame* frame)
1007 { 1008 {
1008 if (frame != inspectedFrame()) 1009 if (!frame->isMainFrame())
1009 return; 1010 return;
1010 m_frontend->loadEventFired(currentTime()); 1011 m_frontend->loadEventFired(currentTime());
1011 } 1012 }
1012 1013
1013 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader) 1014 void InspectorPageAgent::didCommitLoad(LocalFrame*, DocumentLoader* loader)
1014 { 1015 {
1015 if (loader->frame() == inspectedFrame()) { 1016 // FIXME: If "frame" is always guaranteed to be in the same Page as loader-> frame()
1017 // then all we need to check here is loader->frame()->isMainFrame()
1018 // and we don't need "frame" at all.
1019 if (loader->frame() == m_page->mainFrame()) {
1016 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce; 1020 m_scriptToEvaluateOnLoadOnce = m_pendingScriptToEvaluateOnLoadOnce;
1017 m_scriptPreprocessorSource = m_pendingScriptPreprocessor; 1021 m_scriptPreprocessorSource = m_pendingScriptPreprocessor;
1018 m_pendingScriptToEvaluateOnLoadOnce = String(); 1022 m_pendingScriptToEvaluateOnLoadOnce = String();
1019 m_pendingScriptPreprocessor = String(); 1023 m_pendingScriptPreprocessor = String();
1020 if (m_inspectorResourceContentLoader) 1024 if (m_inspectorResourceContentLoader)
1021 m_inspectorResourceContentLoader->stop(); 1025 m_inspectorResourceContentLoader->stop();
1022 } 1026 }
1023 m_frontend->frameNavigated(buildObjectForFrame(loader->frame())); 1027 m_frontend->frameNavigated(buildObjectForFrame(loader->frame()));
1024 viewportChanged(); 1028 viewportChanged();
1025 } 1029 }
1026 1030
1027 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame) 1031 void InspectorPageAgent::frameAttachedToParent(LocalFrame* frame)
1028 { 1032 {
1029 Frame* parentFrame = frame->tree().parent(); 1033 Frame* parentFrame = frame->tree().parent();
1030 if (!parentFrame->isLocalFrame()) 1034 if (!parentFrame->isLocalFrame())
1031 parentFrame = 0; 1035 parentFrame = 0;
1032 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame)) ); 1036 m_frontend->frameAttached(frameId(frame), frameId(toLocalFrame(parentFrame)) );
1033 } 1037 }
1034 1038
1035 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame) 1039 void InspectorPageAgent::frameDetachedFromParent(LocalFrame* frame)
1036 { 1040 {
1037 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f rame); 1041 HashMap<LocalFrame*, String>::iterator iterator = m_frameToIdentifier.find(f rame);
1038 if (iterator != m_frameToIdentifier.end()) { 1042 if (iterator != m_frameToIdentifier.end()) {
1039 m_frontend->frameDetached(iterator->value); 1043 m_frontend->frameDetached(iterator->value);
1040 m_identifierToFrame.remove(iterator->value); 1044 m_identifierToFrame.remove(iterator->value);
1041 m_frameToIdentifier.remove(iterator); 1045 m_frameToIdentifier.remove(iterator);
1042 } 1046 }
1043 } 1047 }
1044 1048
1045 FrameHost* InspectorPageAgent::frameHost() 1049 LocalFrame* InspectorPageAgent::mainFrame()
1046 {
1047 return &m_page->frameHost();
1048 }
1049
1050 LocalFrame* InspectorPageAgent::inspectedFrame()
1051 { 1050 {
1052 return m_page->deprecatedLocalMainFrame(); 1051 return m_page->deprecatedLocalMainFrame();
1053 } 1052 }
1054 1053
1055 LocalFrame* InspectorPageAgent::frameForId(const String& frameId) 1054 LocalFrame* InspectorPageAgent::frameForId(const String& frameId)
1056 { 1055 {
1057 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId); 1056 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId);
1058 } 1057 }
1059 1058
1060 String InspectorPageAgent::frameId(LocalFrame* frame) 1059 String InspectorPageAgent::frameId(LocalFrame* frame)
(...skipping 21 matching lines...) Expand all
1082 String identifier = m_loaderToIdentifier.get(loader); 1081 String identifier = m_loaderToIdentifier.get(loader);
1083 if (identifier.isNull()) { 1082 if (identifier.isNull()) {
1084 identifier = IdentifiersFactory::createIdentifier(); 1083 identifier = IdentifiersFactory::createIdentifier();
1085 m_loaderToIdentifier.set(loader, identifier); 1084 m_loaderToIdentifier.set(loader, identifier);
1086 } 1085 }
1087 return identifier; 1086 return identifier;
1088 } 1087 }
1089 1088
1090 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin RawString) 1089 LocalFrame* InspectorPageAgent::findFrameWithSecurityOrigin(const String& origin RawString)
1091 { 1090 {
1092 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) { 1091 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
1092 // FIXME: RemoteFrame security origins are not yet available.
1093 if (!frame->isLocalFrame()) 1093 if (!frame->isLocalFrame())
1094 continue; 1094 continue;
1095 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin(); 1095 RefPtr<SecurityOrigin> documentOrigin = toLocalFrame(frame)->document()- >securityOrigin();
1096 if (documentOrigin->toRawString() == originRawString) 1096 if (documentOrigin->toRawString() == originRawString)
1097 return toLocalFrame(frame); 1097 return toLocalFrame(frame);
1098 } 1098 }
1099 return nullptr; 1099 return nullptr;
1100 } 1100 }
1101 1101
1102 LocalFrame* InspectorPageAgent::assertFrame(ErrorString* errorString, const Stri ng& frameId) 1102 LocalFrame* InspectorPageAgent::assertFrame(ErrorString* errorString, const Stri ng& frameId)
1103 { 1103 {
1104 LocalFrame* frame = frameForId(frameId); 1104 LocalFrame* frame = frameForId(frameId);
1105 if (!frame) 1105 if (!frame)
1106 *errorString = "No frame for given id found"; 1106 *errorString = "No frame for given id found";
1107 return frame; 1107 return frame;
1108 } 1108 }
1109 1109
1110 const AtomicString& InspectorPageAgent::resourceSourceMapURL(const String& url) 1110 const AtomicString& InspectorPageAgent::resourceSourceMapURL(const String& url)
1111 { 1111 {
1112 DEFINE_STATIC_LOCAL(const AtomicString, sourceMapHttpHeader, ("SourceMap", A tomicString::ConstructFromLiteral)); 1112 DEFINE_STATIC_LOCAL(const AtomicString, sourceMapHttpHeader, ("SourceMap", A tomicString::ConstructFromLiteral));
1113 DEFINE_STATIC_LOCAL(const AtomicString, deprecatedSourceMapHttpHeader, ("X-S ourceMap", AtomicString::ConstructFromLiteral)); 1113 DEFINE_STATIC_LOCAL(const AtomicString, deprecatedSourceMapHttpHeader, ("X-S ourceMap", AtomicString::ConstructFromLiteral));
1114 if (url.isEmpty()) 1114 if (url.isEmpty())
1115 return nullAtom; 1115 return nullAtom;
1116 LocalFrame* frame = inspectedFrame(); 1116 LocalFrame* frame = mainFrame();
1117 if (!frame) 1117 if (!frame)
1118 return nullAtom; 1118 return nullAtom;
1119 Resource* resource = cachedResource(frame, KURL(ParsedURLString, url)); 1119 Resource* resource = cachedResource(frame, KURL(ParsedURLString, url));
1120 if (!resource) 1120 if (!resource)
1121 return nullAtom; 1121 return nullAtom;
1122 const AtomicString& deprecatedHeaderSourceMapURL = resource->response().http HeaderField(deprecatedSourceMapHttpHeader); 1122 const AtomicString& deprecatedHeaderSourceMapURL = resource->response().http HeaderField(deprecatedSourceMapHttpHeader);
1123 if (!deprecatedHeaderSourceMapURL.isEmpty()) { 1123 if (!deprecatedHeaderSourceMapURL.isEmpty()) {
1124 // FIXME: add deprecated console message here. 1124 // FIXME: add deprecated console message here.
1125 return deprecatedHeaderSourceMapURL; 1125 return deprecatedHeaderSourceMapURL;
1126 } 1126 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 1210
1211 void InspectorPageAgent::didScroll() 1211 void InspectorPageAgent::didScroll()
1212 { 1212 {
1213 if (m_enabled) 1213 if (m_enabled)
1214 m_overlay->update(); 1214 m_overlay->update();
1215 viewportChanged(); 1215 viewportChanged();
1216 } 1216 }
1217 1217
1218 void InspectorPageAgent::viewportChanged() 1218 void InspectorPageAgent::viewportChanged()
1219 { 1219 {
1220 if (!m_enabled || !m_deviceMetricsOverridden || !inspectedFrame()->isMainFra me()) 1220 if (!m_enabled || !m_deviceMetricsOverridden)
1221 return; 1221 return;
1222 IntSize contentsSize = inspectedFrame()->view()->contentsSize(); 1222 IntSize contentsSize = m_page->deprecatedLocalMainFrame()->view()->contentsS ize();
1223 IntRect viewRect = inspectedFrame()->view()->visibleContentRect(); 1223 IntRect viewRect = m_page->deprecatedLocalMainFrame()->view()->visibleConten tRect();
1224 RefPtr<TypeBuilder::Page::Viewport> viewport = TypeBuilder::Page::Viewport:: create() 1224 RefPtr<TypeBuilder::Page::Viewport> viewport = TypeBuilder::Page::Viewport:: create()
1225 .setScrollX(viewRect.x()) 1225 .setScrollX(viewRect.x())
1226 .setScrollY(viewRect.y()) 1226 .setScrollY(viewRect.y())
1227 .setContentsWidth(contentsSize.width()) 1227 .setContentsWidth(contentsSize.width())
1228 .setContentsHeight(contentsSize.height()) 1228 .setContentsHeight(contentsSize.height())
1229 .setPageScaleFactor(m_page->pageScaleFactor()) 1229 .setPageScaleFactor(m_page->pageScaleFactor())
1230 .setMinimumPageScaleFactor(m_client->minimumPageScaleFactor()) 1230 .setMinimumPageScaleFactor(m_client->minimumPageScaleFactor())
1231 .setMaximumPageScaleFactor(m_client->maximumPageScaleFactor()); 1231 .setMaximumPageScaleFactor(m_client->maximumPageScaleFactor());
1232 m_frontend->viewportChanged(viewport); 1232 m_frontend->viewportChanged(viewport);
1233 } 1233 }
1234 1234
1235 void InspectorPageAgent::didResizeMainFrame() 1235 void InspectorPageAgent::didResizeMainFrame()
1236 { 1236 {
1237 if (!inspectedFrame()->isMainFrame())
1238 return;
1239 #if !OS(ANDROID) 1237 #if !OS(ANDROID)
1240 if (m_enabled && m_state->getBoolean(PageAgentState::showSizeOnResize)) 1238 if (m_enabled && m_state->getBoolean(PageAgentState::showSizeOnResize))
1241 m_overlay->showAndHideViewSize(m_state->getBoolean(PageAgentState::showG ridOnResize)); 1239 m_overlay->showAndHideViewSize(m_state->getBoolean(PageAgentState::showG ridOnResize));
1242 #endif 1240 #endif
1243 m_frontend->frameResized(); 1241 m_frontend->frameResized();
1244 viewportChanged(); 1242 viewportChanged();
1245 } 1243 }
1246 1244
1247 void InspectorPageAgent::didRecalculateStyle(int) 1245 void InspectorPageAgent::didRecalculateStyle(int)
1248 { 1246 {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 double scale = m_state->getDouble(PageAgentState::deviceScale, 1); 1339 double scale = m_state->getDouble(PageAgentState::deviceScale, 1);
1342 double offsetX = m_state->getDouble(PageAgentState::deviceOffsetX, 0); 1340 double offsetX = m_state->getDouble(PageAgentState::deviceOffsetX, 0);
1343 double offsetY = m_state->getDouble(PageAgentState::deviceOffsetY, 0); 1341 double offsetY = m_state->getDouble(PageAgentState::deviceOffsetY, 0);
1344 updateViewMetrics(enabled, width, height, deviceScaleFactor, mobile, fitWind ow, scale, offsetX, offsetY); 1342 updateViewMetrics(enabled, width, height, deviceScaleFactor, mobile, fitWind ow, scale, offsetX, offsetY);
1345 } 1343 }
1346 1344
1347 void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height, double deviceScaleFactor, bool mobile, bool fitWindow, double scale, double offs etX, double offsetY) 1345 void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height, double deviceScaleFactor, bool mobile, bool fitWindow, double scale, double offs etX, double offsetY)
1348 { 1346 {
1349 if (enabled && !m_page->settings().acceleratedCompositingEnabled()) 1347 if (enabled && !m_page->settings().acceleratedCompositingEnabled())
1350 return; 1348 return;
1351 if (!inspectedFrame()->isMainFrame())
1352 return;
1353 1349
1354 m_deviceMetricsOverridden = enabled; 1350 m_deviceMetricsOverridden = enabled;
1355 m_emulateMobileEnabled = mobile; 1351 m_emulateMobileEnabled = mobile;
1356 if (enabled) 1352 if (enabled)
1357 m_client->setDeviceMetricsOverride(width, height, static_cast<float>(dev iceScaleFactor), mobile, fitWindow, static_cast<float>(scale), static_cast<float >(offsetX), static_cast<float>(offsetY)); 1353 m_client->setDeviceMetricsOverride(width, height, static_cast<float>(dev iceScaleFactor), mobile, fitWindow, static_cast<float>(scale), static_cast<float >(offsetX), static_cast<float>(offsetY));
1358 else 1354 else
1359 m_client->clearDeviceMetricsOverride(); 1355 m_client->clearDeviceMetricsOverride();
1360 1356
1361 Document* document = inspectedFrame()->document(); 1357 Document* document = mainFrame()->document();
1362 if (document) { 1358 if (document) {
1363 document->styleResolverChanged(); 1359 document->styleResolverChanged();
1364 document->mediaQueryAffectingValueChanged(); 1360 document->mediaQueryAffectingValueChanged();
1365 } 1361 }
1366 1362
1367 if (m_deviceMetricsOverridden) { 1363 if (m_deviceMetricsOverridden) {
1368 m_page->settings().setTextAutosizingEnabled(mobile); 1364 m_page->settings().setTextAutosizingEnabled(mobile);
1369 m_page->settings().setPreferCompositingToLCDTextEnabled(mobile); 1365 m_page->settings().setPreferCompositingToLCDTextEnabled(mobile);
1370 m_page->settings().setDeviceScaleAdjustment(calculateFontScaleFactor(wid th, height, static_cast<float>(deviceScaleFactor))); 1366 m_page->settings().setDeviceScaleAdjustment(calculateFontScaleFactor(wid th, height, static_cast<float>(deviceScaleFactor)));
1371 } else { 1367 } else {
1372 m_page->settings().setTextAutosizingEnabled(m_embedderTextAutosizingEnab led); 1368 m_page->settings().setTextAutosizingEnabled(m_embedderTextAutosizingEnab led);
1373 m_page->settings().setPreferCompositingToLCDTextEnabled(m_embedderPrefer CompositingToLCDTextEnabled); 1369 m_page->settings().setPreferCompositingToLCDTextEnabled(m_embedderPrefer CompositingToLCDTextEnabled);
1374 m_page->settings().setDeviceScaleAdjustment(m_embedderFontScaleFactor); 1370 m_page->settings().setDeviceScaleAdjustment(m_embedderFontScaleFactor);
1375 } 1371 }
1376 1372
1377 // FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837. 1373 // FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837.
1378 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho wFPSCounter) && !m_deviceMetricsOverridden); 1374 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho wFPSCounter) && !m_deviceMetricsOverridden);
1379 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p ageAgentContinuousPaintingEnabled) && !m_deviceMetricsOverridden); 1375 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p ageAgentContinuousPaintingEnabled) && !m_deviceMetricsOverridden);
1380 } 1376 }
1381 1377
1382 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) 1378 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled)
1383 { 1379 {
1384 if (!inspectedFrame()->isMainFrame())
1385 return;
1386 if (!m_touchEmulationEnabled) { 1380 if (!m_touchEmulationEnabled) {
1387 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled(); 1381 m_originalTouchEnabled = RuntimeEnabledFeatures::touchEnabled();
1388 m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse() ; 1382 m_originalDeviceSupportsMouse = m_page->settings().deviceSupportsMouse() ;
1389 m_originalDeviceSupportsTouch = m_page->settings().deviceSupportsTouch() ; 1383 m_originalDeviceSupportsTouch = m_page->settings().deviceSupportsTouch() ;
1390 m_originalMaxTouchPoints = m_page->settings().maxTouchPoints(); 1384 m_originalMaxTouchPoints = m_page->settings().maxTouchPoints();
1391 } 1385 }
1392 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led); 1386 RuntimeEnabledFeatures::setTouchEnabled(enabled ? true : m_originalTouchEnab led);
1393 if (!m_originalDeviceSupportsTouch) { 1387 if (!m_originalDeviceSupportsTouch) {
1394 m_page->settings().setDeviceSupportsMouse(enabled ? false : m_originalDe viceSupportsMouse); 1388 m_page->settings().setDeviceSupportsMouse(enabled ? false : m_originalDe viceSupportsMouse);
1395 m_page->settings().setDeviceSupportsTouch(enabled ? true : m_originalDev iceSupportsTouch); 1389 m_page->settings().setDeviceSupportsTouch(enabled ? true : m_originalDev iceSupportsTouch);
1396 // Currently emulation does not provide multiple touch points. 1390 // Currently emulation does not provide multiple touch points.
1397 m_page->settings().setMaxTouchPoints(enabled ? 1 : m_originalMaxTouchPoi nts); 1391 m_page->settings().setMaxTouchPoints(enabled ? 1 : m_originalMaxTouchPoi nts);
1398 } 1392 }
1399 m_touchEmulationEnabled = enabled; 1393 m_touchEmulationEnabled = enabled;
1400 m_client->setTouchEventEmulationEnabled(enabled); 1394 m_client->setTouchEventEmulationEnabled(enabled);
1401 inspectedFrame()->view()->layout(); 1395 m_page->deprecatedLocalMainFrame()->view()->layout();
1402 } 1396 }
1403 1397
1404 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, co nst String* configuration) 1398 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, co nst String* configuration)
1405 { 1399 {
1406 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed) 1400 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed)
1407 return; 1401 return;
1408 1402
1409 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); 1403 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled);
1410 updateTouchEventEmulationInPage(enabled); 1404 updateTouchEventEmulationInPage(enabled);
1411 } 1405 }
1412 1406
1413 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media) 1407 void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media)
1414 { 1408 {
1415 if (!inspectedFrame()->isMainFrame())
1416 return;
1417 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe dia); 1409 String currentMedia = m_state->getString(PageAgentState::pageAgentEmulatedMe dia);
1418 if (media == currentMedia) 1410 if (media == currentMedia)
1419 return; 1411 return;
1420 1412
1421 m_state->setString(PageAgentState::pageAgentEmulatedMedia, media); 1413 m_state->setString(PageAgentState::pageAgentEmulatedMedia, media);
1422 Document* document = inspectedFrame()->document(); 1414 Document* document = 0;
1415 if (m_page->mainFrame())
1416 document = m_page->deprecatedLocalMainFrame()->document();
1423 if (document) { 1417 if (document) {
1424 document->mediaQueryAffectingValueChanged(); 1418 document->mediaQueryAffectingValueChanged();
1425 document->styleResolverChanged(); 1419 document->styleResolverChanged();
1426 document->updateLayout(); 1420 document->updateLayout();
1427 } 1421 }
1428 } 1422 }
1429 1423
1430 bool InspectorPageAgent::applyViewportStyleOverride(StyleResolver* resolver) 1424 bool InspectorPageAgent::applyViewportStyleOverride(StyleResolver* resolver)
1431 { 1425 {
1432 if (!m_deviceMetricsOverridden || !m_emulateMobileEnabled) 1426 if (!m_deviceMetricsOverridden || !m_emulateMobileEnabled)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 m_state->setBoolean(PageAgentState::showGridOnResize, asBool(showGrid)); 1467 m_state->setBoolean(PageAgentState::showGridOnResize, asBool(showGrid));
1474 } 1468 }
1475 1469
1476 void InspectorPageAgent::setOverlayMessage(ErrorString*, const String* message) 1470 void InspectorPageAgent::setOverlayMessage(ErrorString*, const String* message)
1477 { 1471 {
1478 m_overlay->setPausedInDebuggerMessage(message); 1472 m_overlay->setPausedInDebuggerMessage(message);
1479 } 1473 }
1480 1474
1481 void InspectorPageAgent::animationsPlaybackRate(ErrorString*, double* playbackRa te) 1475 void InspectorPageAgent::animationsPlaybackRate(ErrorString*, double* playbackRa te)
1482 { 1476 {
1483 *playbackRate = inspectedFrame()->document()->timeline().playbackRate(); 1477 *playbackRate = toLocalFrame(m_page->mainFrame())->document()->timeline().pl aybackRate();
1484 } 1478 }
1485 1479
1486 void InspectorPageAgent::setAnimationsPlaybackRate(ErrorString*, double playback Rate) 1480 void InspectorPageAgent::setAnimationsPlaybackRate(ErrorString*, double playback Rate)
1487 { 1481 {
1488 for (Frame* frame = inspectedFrame(); frame; frame = frame->tree().traverseN ext(inspectedFrame())) { 1482 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
1489 if (frame->isLocalFrame()) 1483 if (frame->isLocalFrame())
1490 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback Rate); 1484 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback Rate);
1491 } 1485 }
1492 } 1486 }
1493 1487
1494 void InspectorPageAgent::clearEditedResourcesContent() 1488 void InspectorPageAgent::clearEditedResourcesContent()
1495 { 1489 {
1496 m_editedResourceContent.clear(); 1490 m_editedResourceContent.clear();
1497 } 1491 }
1498 1492
(...skipping 13 matching lines...) Expand all
1512 void InspectorPageAgent::trace(Visitor* visitor) 1506 void InspectorPageAgent::trace(Visitor* visitor)
1513 { 1507 {
1514 visitor->trace(m_page); 1508 visitor->trace(m_page);
1515 visitor->trace(m_injectedScriptManager); 1509 visitor->trace(m_injectedScriptManager);
1516 visitor->trace(m_inspectorResourceContentLoader); 1510 visitor->trace(m_inspectorResourceContentLoader);
1517 InspectorBaseAgent::trace(visitor); 1511 InspectorBaseAgent::trace(visitor);
1518 } 1512 }
1519 1513
1520 } // namespace blink 1514 } // namespace blink
1521 1515
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/core/inspector/InspectorResourceAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698