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

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

Issue 1299493003: Attach mixed content status to resource requests when sent to devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: change to MixedContentChecker::contextTypeForInspector() Created 5 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "core/inspector/IdentifiersFactory.h" 51 #include "core/inspector/IdentifiersFactory.h"
52 #include "core/inspector/InspectorOverlay.h" 52 #include "core/inspector/InspectorOverlay.h"
53 #include "core/inspector/InspectorPageAgent.h" 53 #include "core/inspector/InspectorPageAgent.h"
54 #include "core/inspector/InspectorState.h" 54 #include "core/inspector/InspectorState.h"
55 #include "core/inspector/InstrumentingAgents.h" 55 #include "core/inspector/InstrumentingAgents.h"
56 #include "core/inspector/NetworkResourcesData.h" 56 #include "core/inspector/NetworkResourcesData.h"
57 #include "core/inspector/ScriptAsyncCallStack.h" 57 #include "core/inspector/ScriptAsyncCallStack.h"
58 #include "core/inspector/ScriptCallStack.h" 58 #include "core/inspector/ScriptCallStack.h"
59 #include "core/loader/DocumentLoader.h" 59 #include "core/loader/DocumentLoader.h"
60 #include "core/loader/FrameLoader.h" 60 #include "core/loader/FrameLoader.h"
61 #include "core/loader/MixedContentChecker.h"
61 #include "core/loader/ThreadableLoaderClient.h" 62 #include "core/loader/ThreadableLoaderClient.h"
62 #include "core/page/Page.h" 63 #include "core/page/Page.h"
63 #include "core/xmlhttprequest/XMLHttpRequest.h" 64 #include "core/xmlhttprequest/XMLHttpRequest.h"
64 #include "platform/JSONValues.h" 65 #include "platform/JSONValues.h"
65 #include "platform/blob/BlobData.h" 66 #include "platform/blob/BlobData.h"
66 #include "platform/network/HTTPHeaderMap.h" 67 #include "platform/network/HTTPHeaderMap.h"
67 #include "platform/network/ResourceError.h" 68 #include "platform/network/ResourceError.h"
68 #include "platform/network/ResourceRequest.h" 69 #include "platform/network/ResourceRequest.h"
69 #include "platform/network/ResourceResponse.h" 70 #include "platform/network/ResourceResponse.h"
70 #include "platform/network/WebSocketHandshakeRequest.h" 71 #include "platform/network/WebSocketHandshakeRequest.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 OwnPtr<ArrayBufferBuilder> m_rawData; 170 OwnPtr<ArrayBufferBuilder> m_rawData;
170 }; 171 };
171 172
172 KURL urlWithoutFragment(const KURL& url) 173 KURL urlWithoutFragment(const KURL& url)
173 { 174 {
174 KURL result = url; 175 KURL result = url;
175 result.removeFragmentIdentifier(); 176 result.removeFragmentIdentifier();
176 return result; 177 return result;
177 } 178 }
178 179
180 TypeBuilder::Network::Request::MixedContentType::Enum mixedContentTypeForContext Type(MixedContentChecker::ContextType contextType)
181 {
182 switch (contextType) {
183 case MixedContentChecker::ContextTypeNotMixedContent:
184 return TypeBuilder::Network::Request::MixedContentType::None;
185 case MixedContentChecker::ContextTypeBlockable:
186 return TypeBuilder::Network::Request::MixedContentType::Blockable;
187 case MixedContentChecker::ContextTypeOptionallyBlockable:
188 case MixedContentChecker::ContextTypeShouldBeBlockable:
189 return TypeBuilder::Network::Request::MixedContentType::Optionally_block able;
190 }
191
192 return TypeBuilder::Network::Request::MixedContentType::None;
193 }
194
179 } // namespace 195 } // namespace
180 196
181 void InspectorResourceAgent::restore() 197 void InspectorResourceAgent::restore()
182 { 198 {
183 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled)) 199 if (m_state->getBoolean(ResourceAgentState::resourceAgentEnabled))
184 enable(); 200 enable();
185 } 201 }
186 202
187 static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(con st ResourceLoadTiming& timing) 203 static PassRefPtr<TypeBuilder::Network::ResourceTiming> buildObjectForTiming(con st ResourceLoadTiming& timing)
188 { 204 {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 358
343 DEFINE_TRACE(InspectorResourceAgent) 359 DEFINE_TRACE(InspectorResourceAgent)
344 { 360 {
345 visitor->trace(m_pageAgent); 361 visitor->trace(m_pageAgent);
346 visitor->trace(m_replayXHRs); 362 visitor->trace(m_replayXHRs);
347 visitor->trace(m_replayXHRsToBeDeleted); 363 visitor->trace(m_replayXHRsToBeDeleted);
348 visitor->trace(m_pendingXHRReplayData); 364 visitor->trace(m_pendingXHRReplayData);
349 InspectorBaseAgent::trace(visitor); 365 InspectorBaseAgent::trace(visitor);
350 } 366 }
351 367
352 void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL oader* loader, ResourceRequest& request, const ResourceResponse& redirectRespons e, const FetchInitiatorInfo& initiatorInfo) 368 void InspectorResourceAgent::willSendRequest(LocalFrame* frame, unsigned long id entifier, DocumentLoader* loader, ResourceRequest& request, const ResourceRespon se& redirectResponse, const FetchInitiatorInfo& initiatorInfo)
353 { 369 {
354 // Ignore the request initiated internally. 370 // Ignore the request initiated internally.
355 if (initiatorInfo.name == FetchInitiatorTypeNames::internal) 371 if (initiatorInfo.name == FetchInitiatorTypeNames::internal)
356 return; 372 return;
357 373
358 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->subst ituteData().isValid()) 374 if (initiatorInfo.name == FetchInitiatorTypeNames::document && loader->subst ituteData().isValid())
359 return; 375 return;
360 376
361 String requestId = IdentifiersFactory::requestId(identifier); 377 String requestId = IdentifiersFactory::requestId(identifier);
362 String loaderId = IdentifiersFactory::loaderId(loader); 378 String loaderId = IdentifiersFactory::loaderId(loader);
(...skipping 28 matching lines...) Expand all
391 String frameId = loader->frame() ? IdentifiersFactory::frameId(loader->frame ()) : ""; 407 String frameId = loader->frame() ? IdentifiersFactory::frameId(loader->frame ()) : "";
392 RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObje ct(loader->frame() ? loader->frame()->document() : 0, initiatorInfo); 408 RefPtr<TypeBuilder::Network::Initiator> initiatorObject = buildInitiatorObje ct(loader->frame() ? loader->frame()->document() : 0, initiatorInfo);
393 if (initiatorInfo.name == FetchInitiatorTypeNames::document) { 409 if (initiatorInfo.name == FetchInitiatorTypeNames::document) {
394 FrameNavigationInitiatorMap::iterator it = m_frameNavigationInitiatorMap .find(frameId); 410 FrameNavigationInitiatorMap::iterator it = m_frameNavigationInitiatorMap .find(frameId);
395 if (it != m_frameNavigationInitiatorMap.end()) 411 if (it != m_frameNavigationInitiatorMap.end())
396 initiatorObject = it->value; 412 initiatorObject = it->value;
397 } 413 }
398 414
399 RefPtr<TypeBuilder::Network::Request> requestInfo(buildObjectForResourceRequ est(request)); 415 RefPtr<TypeBuilder::Network::Request> requestInfo(buildObjectForResourceRequ est(request));
400 416
417 requestInfo->setMixedContentType(mixedContentTypeForContextType(MixedContent Checker::contextTypeForInspector(frame, request)));
418
401 if (!m_hostId.isEmpty()) 419 if (!m_hostId.isEmpty())
402 request.addHTTPHeaderField(kDevToolsEmulateNetworkConditionsClientId, At omicString(m_hostId)); 420 request.addHTTPHeaderField(kDevToolsEmulateNetworkConditionsClientId, At omicString(m_hostId));
403 421
404 TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::res ourceTypeJson(type); 422 TypeBuilder::Page::ResourceType::Enum resourceType = InspectorPageAgent::res ourceTypeJson(type);
405 frontend()->requestWillBeSent(requestId, frameId, loaderId, urlWithoutFragme nt(loader->url()).string(), requestInfo.release(), monotonicallyIncreasingTime() , currentTime(), initiatorObject, buildObjectForResourceResponse(redirectRespons e), &resourceType); 423 frontend()->requestWillBeSent(requestId, frameId, loaderId, urlWithoutFragme nt(loader->url()).string(), requestInfo.release(), monotonicallyIncreasingTime() , currentTime(), initiatorObject, buildObjectForResourceResponse(redirectRespons e), &resourceType);
406 if (m_pendingXHRReplayData && !m_pendingXHRReplayData->async()) 424 if (m_pendingXHRReplayData && !m_pendingXHRReplayData->async())
407 frontend()->flush(); 425 frontend()->flush();
408 } 426 }
409 427
410 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) 428 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier)
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired) 1006 , m_removeFinishedReplayXHRTimer(this, &InspectorResourceAgent::removeFinish edReplayXHRFired)
989 { 1007 {
990 } 1008 }
991 1009
992 bool InspectorResourceAgent::shouldForceCORSPreflight() 1010 bool InspectorResourceAgent::shouldForceCORSPreflight()
993 { 1011 {
994 return m_state->getBoolean(ResourceAgentState::cacheDisabled); 1012 return m_state->getBoolean(ResourceAgentState::cacheDisabled);
995 } 1013 }
996 1014
997 } // namespace blink 1015 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698