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

Side by Side Diff: Source/core/loader/MixedContentChecker.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: 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 break; 285 break;
286 286
287 default: 287 default:
288 ASSERT_NOT_REACHED(); 288 ASSERT_NOT_REACHED();
289 return; 289 return;
290 } 290 }
291 UseCounter::count(frame, feature); 291 UseCounter::count(frame, feature);
292 } 292 }
293 293
294 // static 294 // static
295 bool MixedContentChecker::shouldBlockFetch(LocalFrame* frame, WebURLRequest::Req uestContext requestContext, WebURLRequest::FrameType frameType, const KURL& url, MixedContentChecker::ReportingStatus reportingStatus) 295 bool MixedContentChecker::shouldBlockFetch(LocalFrame* frame, ResourceRequest* r equest, WebURLRequest::RequestContext requestContext, WebURLRequest::FrameType f rameType, const KURL& url, MixedContentChecker::ReportingStatus reportingStatus)
296 { 296 {
297 LocalFrame* mixedFrame = inWhichFrameIsContentMixed(frame, frameType, url); 297 LocalFrame* mixedFrame = inWhichFrameIsContentMixed(frame, frameType, url);
298 if (!mixedFrame) 298 if (!mixedFrame)
299 return false; 299 return false;
300 300
301 MixedContentChecker::count(mixedFrame, requestContext); 301 MixedContentChecker::count(mixedFrame, requestContext);
302 302
303 Settings* settings = mixedFrame->settings(); 303 Settings* settings = mixedFrame->settings();
304 FrameLoaderClient* client = mixedFrame->loader().client(); 304 FrameLoaderClient* client = mixedFrame->loader().client();
305 SecurityOrigin* securityOrigin = mixedFrame->document()->securityOrigin(); 305 SecurityOrigin* securityOrigin = mixedFrame->document()->securityOrigin();
(...skipping 10 matching lines...) Expand all
316 // treat frames as passive content. 316 // treat frames as passive content.
317 // 317 //
318 // FIXME: Remove this temporary hack once we have a reasonable API for launc hing external applications 318 // FIXME: Remove this temporary hack once we have a reasonable API for launc hing external applications
319 // via URLs. http://crbug.com/318788 and https://crbug.com/393481 319 // via URLs. http://crbug.com/318788 and https://crbug.com/393481
320 if (frameType == WebURLRequest::FrameTypeNested && !SchemeRegistry::shouldTr eatURLSchemeAsCORSEnabled(url.protocol())) 320 if (frameType == WebURLRequest::FrameTypeNested && !SchemeRegistry::shouldTr eatURLSchemeAsCORSEnabled(url.protocol()))
321 contextType = ContextTypeOptionallyBlockable; 321 contextType = ContextTypeOptionallyBlockable;
322 322
323 switch (contextType) { 323 switch (contextType) {
324 case ContextTypeOptionallyBlockable: 324 case ContextTypeOptionallyBlockable:
325 allowed = !strictMode && client->allowDisplayingInsecureContent(settings && settings->allowDisplayOfInsecureContent(), securityOrigin, url); 325 allowed = !strictMode && client->allowDisplayingInsecureContent(settings && settings->allowDisplayOfInsecureContent(), securityOrigin, url);
326 if (allowed) 326 if (allowed) {
327 client->didDisplayInsecureContent(); 327 client->didDisplayInsecureContent();
328 request->setMixedContentStatus(ResourceRequest::PassiveMixedContent) ;
329 }
328 break; 330 break;
329 331
330 case ContextTypeBlockable: { 332 case ContextTypeBlockable: {
331 bool shouldAskEmbedder = !strictMode && settings && (!settings->strictly BlockBlockableMixedContent() || settings->allowRunningOfInsecureContent()); 333 bool shouldAskEmbedder = !strictMode && settings && (!settings->strictly BlockBlockableMixedContent() || settings->allowRunningOfInsecureContent());
332 allowed = shouldAskEmbedder && client->allowRunningInsecureContent(setti ngs && settings->allowRunningOfInsecureContent(), securityOrigin, url); 334 allowed = shouldAskEmbedder && client->allowRunningInsecureContent(setti ngs && settings->allowRunningOfInsecureContent(), securityOrigin, url);
333 if (allowed) { 335 if (allowed) {
334 client->didRunInsecureContent(securityOrigin, url); 336 client->didRunInsecureContent(securityOrigin, url);
335 UseCounter::count(mixedFrame, UseCounter::MixedContentBlockableAllow ed); 337 UseCounter::count(mixedFrame, UseCounter::MixedContentBlockableAllow ed);
338 request->setMixedContentStatus(ResourceRequest::ActiveMixedContent);
336 } 339 }
337 break; 340 break;
338 } 341 }
339 342
340 case ContextTypeShouldBeBlockable: 343 case ContextTypeShouldBeBlockable:
341 allowed = !strictMode; 344 allowed = !strictMode;
342 if (allowed) 345 if (allowed) {
343 client->didDisplayInsecureContent(); 346 client->didDisplayInsecureContent();
347 request->setMixedContentStatus(ResourceRequest::PassiveMixedContent) ;
348 }
344 break; 349 break;
345 }; 350 };
346 351
347 if (reportingStatus == SendReport) 352 if (reportingStatus == SendReport)
348 logToConsoleAboutFetch(frame, url, requestContext, allowed); 353 logToConsoleAboutFetch(frame, url, requestContext, allowed);
349 return !allowed; 354 return !allowed;
350 } 355 }
351 356
352 // static 357 // static
353 void MixedContentChecker::logToConsoleAboutWebSocket(LocalFrame* frame, const KU RL& url, bool allowed) 358 void MixedContentChecker::logToConsoleAboutWebSocket(LocalFrame* frame, const KU RL& url, bool allowed)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 { 426 {
422 if (!frame || !frame->document() || !frame->document()->loader()) 427 if (!frame || !frame->document() || !frame->document()->loader())
423 return; 428 return;
424 429
425 // Just count these for the moment, don't block them. 430 // Just count these for the moment, don't block them.
426 if (Platform::current()->isReservedIPAddress(resourceIPAddress) && !frame->d ocument()->isHostedInReservedIPRange()) 431 if (Platform::current()->isReservedIPAddress(resourceIPAddress) && !frame->d ocument()->isHostedInReservedIPRange())
427 UseCounter::count(frame->document(), UseCounter::MixedContentPrivateHost nameInPublicHostname); 432 UseCounter::count(frame->document(), UseCounter::MixedContentPrivateHost nameInPublicHostname);
428 } 433 }
429 434
430 } // namespace blink 435 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698