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

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

Issue 445023005: DevTools: reduce ResourceAgent dependency on PageAgent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "core/frame/LocalFrame.h" 52 #include "core/frame/LocalFrame.h"
53 #include "core/frame/Settings.h" 53 #include "core/frame/Settings.h"
54 #include "core/html/HTMLFrameOwnerElement.h" 54 #include "core/html/HTMLFrameOwnerElement.h"
55 #include "core/html/VoidCallback.h" 55 #include "core/html/VoidCallback.h"
56 #include "core/html/imports/HTMLImport.h" 56 #include "core/html/imports/HTMLImport.h"
57 #include "core/html/imports/HTMLImportLoader.h" 57 #include "core/html/imports/HTMLImportLoader.h"
58 #include "core/html/imports/HTMLImportsController.h" 58 #include "core/html/imports/HTMLImportsController.h"
59 #include "core/html/parser/TextResourceDecoder.h" 59 #include "core/html/parser/TextResourceDecoder.h"
60 #include "core/inspector/ContentSearchUtils.h" 60 #include "core/inspector/ContentSearchUtils.h"
61 #include "core/inspector/DOMPatchSupport.h" 61 #include "core/inspector/DOMPatchSupport.h"
62 #include "core/inspector/EditedResourcesContentManager.h"
62 #include "core/inspector/IdentifiersFactory.h" 63 #include "core/inspector/IdentifiersFactory.h"
63 #include "core/inspector/InjectedScriptManager.h" 64 #include "core/inspector/InjectedScriptManager.h"
64 #include "core/inspector/InspectorClient.h" 65 #include "core/inspector/InspectorClient.h"
65 #include "core/inspector/InspectorInstrumentation.h" 66 #include "core/inspector/InspectorInstrumentation.h"
66 #include "core/inspector/InspectorOverlay.h" 67 #include "core/inspector/InspectorOverlay.h"
67 #include "core/inspector/InspectorResourceContentLoader.h" 68 #include "core/inspector/InspectorResourceContentLoader.h"
68 #include "core/inspector/InspectorState.h" 69 #include "core/inspector/InspectorState.h"
69 #include "core/inspector/InstrumentingAgents.h" 70 #include "core/inspector/InstrumentingAgents.h"
70 #include "core/loader/CookieJar.h" 71 #include "core/loader/CookieJar.h"
71 #include "core/loader/DocumentLoader.h" 72 #include "core/loader/DocumentLoader.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 bool InspectorPageAgent::dataContent(const char* data, unsigned size, const Stri ng& textEncodingName, bool withBase64Encode, String* result) 299 bool InspectorPageAgent::dataContent(const char* data, unsigned size, const Stri ng& textEncodingName, bool withBase64Encode, String* result)
299 { 300 {
300 if (withBase64Encode) { 301 if (withBase64Encode) {
301 *result = base64Encode(data, size); 302 *result = base64Encode(data, size);
302 return true; 303 return true;
303 } 304 }
304 305
305 return decodeBuffer(data, size, textEncodingName, result); 306 return decodeBuffer(data, size, textEncodingName, result);
306 } 307 }
307 308
308 PassOwnPtrWillBeRawPtr<InspectorPageAgent> InspectorPageAgent::create(Page* page , InjectedScriptManager* injectedScriptManager, InspectorClient* client, Inspect orOverlay* overlay) 309 PassOwnPtrWillBeRawPtr<InspectorPageAgent> InspectorPageAgent::create(Page* page , InjectedScriptManager* injectedScriptManager, EditedResourcesContentManager* e ditedResourcesContentManager, InspectorClient* client, InspectorOverlay* overlay )
309 { 310 {
310 return adoptPtrWillBeNoop(new InspectorPageAgent(page, injectedScriptManager , client, overlay)); 311 return adoptPtrWillBeNoop(new InspectorPageAgent(page, injectedScriptManager , editedResourcesContentManager, client, overlay));
311 } 312 }
312 313
313 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url) 314 Resource* InspectorPageAgent::cachedResource(LocalFrame* frame, const KURL& url)
314 { 315 {
315 Document* document = frame->document(); 316 Document* document = frame->document();
316 if (!document) 317 if (!document)
317 return 0; 318 return 0;
318 Resource* cachedResource = document->fetcher()->cachedResource(url); 319 Resource* cachedResource = document->fetcher()->cachedResource(url);
319 if (!cachedResource) { 320 if (!cachedResource) {
320 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame ); 321 Vector<Document*> allImports = InspectorPageAgent::importsForFrame(frame );
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 break; 385 break;
385 } 386 }
386 return InspectorPageAgent::OtherResource; 387 return InspectorPageAgent::OtherResource;
387 } 388 }
388 389
389 TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::cachedResourceTypeJson (const Resource& cachedResource) 390 TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::cachedResourceTypeJson (const Resource& cachedResource)
390 { 391 {
391 return resourceTypeJson(cachedResourceType(cachedResource)); 392 return resourceTypeJson(cachedResourceType(cachedResource));
392 } 393 }
393 394
394 InspectorPageAgent::InspectorPageAgent(Page* page, InjectedScriptManager* inject edScriptManager, InspectorClient* client, InspectorOverlay* overlay) 395 InspectorPageAgent::InspectorPageAgent(Page* page, InjectedScriptManager* inject edScriptManager, EditedResourcesContentManager* editedResourcesContentManager, I nspectorClient* client, InspectorOverlay* overlay)
395 : InspectorBaseAgent<InspectorPageAgent>("Page") 396 : InspectorBaseAgent<InspectorPageAgent>("Page")
396 , m_page(page) 397 , m_page(page)
397 , m_injectedScriptManager(injectedScriptManager) 398 , m_injectedScriptManager(injectedScriptManager)
399 , m_editedResourcesContentManager(editedResourcesContentManager)
398 , m_client(client) 400 , m_client(client)
399 , m_frontend(0) 401 , m_frontend(0)
400 , m_overlay(overlay) 402 , m_overlay(overlay)
401 , m_lastScriptIdentifier(0) 403 , m_lastScriptIdentifier(0)
402 , m_enabled(false) 404 , m_enabled(false)
403 , m_ignoreScriptsEnabledNotification(false) 405 , m_ignoreScriptsEnabledNotification(false)
404 , m_deviceMetricsOverridden(false) 406 , m_deviceMetricsOverridden(false)
405 , m_emulateMobileEnabled(false) 407 , m_emulateMobileEnabled(false)
406 , m_touchEmulationEnabled(false) 408 , m_touchEmulationEnabled(false)
407 , m_originalTouchEnabled(false) 409 , m_originalTouchEnabled(false)
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 if (!errorString.isEmpty()) { 706 if (!errorString.isEmpty()) {
705 callback->sendFailure(errorString); 707 callback->sendFailure(errorString);
706 return; 708 return;
707 } 709 }
708 callback->sendSuccess(content, base64Encoded); 710 callback->sendSuccess(content, base64Encoded);
709 } 711 }
710 712
711 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri ng& frameId, const String& url, PassRefPtr<GetResourceContentCallback> callback) 713 void InspectorPageAgent::getResourceContent(ErrorString* errorString, const Stri ng& frameId, const String& url, PassRefPtr<GetResourceContentCallback> callback)
712 { 714 {
713 String content; 715 String content;
714 if (getEditedResourceContent(url, &content)) { 716 if (m_editedResourcesContentManager->get(url, &content)) {
715 callback->sendSuccess(content, false); 717 callback->sendSuccess(content, false);
716 return; 718 return;
717 } 719 }
718 if (!m_inspectorResourceContentLoader) { 720 if (!m_inspectorResourceContentLoader) {
719 callback->sendFailure("Agent is not enabled."); 721 callback->sendFailure("Agent is not enabled.");
720 return; 722 return;
721 } 723 }
722 m_inspectorResourceContentLoader->ensureResourcesContentLoaded(adoptPtr(new GetResourceContentLoadListener(this, frameId, url, callback))); 724 m_inspectorResourceContentLoader->ensureResourcesContentLoaded(adoptPtr(new GetResourceContentLoadListener(this, frameId, url, callback)));
723 } 725 }
724 726
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } 1400 }
1399 return true; 1401 return true;
1400 } 1402 }
1401 1403
1402 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) 1404 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid)
1403 { 1405 {
1404 m_state->setBoolean(PageAgentState::showSizeOnResize, show); 1406 m_state->setBoolean(PageAgentState::showSizeOnResize, show);
1405 m_state->setBoolean(PageAgentState::showGridOnResize, asBool(showGrid)); 1407 m_state->setBoolean(PageAgentState::showGridOnResize, asBool(showGrid));
1406 } 1408 }
1407 1409
1408 void InspectorPageAgent::clearEditedResourcesContent()
1409 {
1410 m_editedResourceContent.clear();
1411 }
1412
1413 void InspectorPageAgent::addEditedResourceContent(const String& url, const Strin g& content)
1414 {
1415 m_editedResourceContent.set(url, content);
1416 }
1417
1418 bool InspectorPageAgent::getEditedResourceContent(const String& url, String* con tent)
1419 {
1420 if (!m_editedResourceContent.contains(url))
1421 return false;
1422 *content = m_editedResourceContent.get(url);
1423 return true;
1424 }
1425
1426 void InspectorPageAgent::trace(Visitor* visitor) 1410 void InspectorPageAgent::trace(Visitor* visitor)
1427 { 1411 {
1428 visitor->trace(m_page); 1412 visitor->trace(m_page);
1429 visitor->trace(m_injectedScriptManager); 1413 visitor->trace(m_injectedScriptManager);
1430 InspectorBaseAgent::trace(visitor); 1414 InspectorBaseAgent::trace(visitor);
1431 } 1415 }
1432 1416
1433 } // namespace blink 1417 } // namespace blink
1434 1418
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698