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

Side by Side Diff: Source/platform/exported/WebURLRequest.cpp

Issue 417483002: Drop the 'WebURLRequest::TargetType' enum. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | public/platform/WebURLRequest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 { 349 {
350 // Subclasses may call this directly so a self-assignment check is needed 350 // Subclasses may call this directly so a self-assignment check is needed
351 // here as well as in the public assign method. 351 // here as well as in the public assign method.
352 if (m_private == p) 352 if (m_private == p)
353 return; 353 return;
354 if (m_private) 354 if (m_private)
355 m_private->dispose(); 355 m_private->dispose();
356 m_private = p; 356 m_private = p;
357 } 357 }
358 358
359 WebURLRequest::RequestContext WebURLRequest::requestContextFromTargetType(WebURL Request::TargetType targetType)
360 {
361 switch (targetType) {
362 case TargetIsMainFrame:
363 return RequestContextHyperlink; // FIXME: Fetch defines the target separ ately from the cause. Need to work that out here.
364 case TargetIsSubframe:
365 return RequestContextIframe;
366 case TargetIsSubresource:
367 return RequestContextSubresource;
368 case TargetIsStyleSheet:
369 return RequestContextStyle;
370 case TargetIsScript:
371 return RequestContextScript;
372 case TargetIsFontResource:
373 return RequestContextFont;
374 case TargetIsImage:
375 return RequestContextImage;
376 case TargetIsObject:
377 return RequestContextObject;
378 case TargetIsMedia:
379 // FIXME: Split this out.
380 return RequestContextVideo;
381 case TargetIsWorker:
382 return RequestContextWorker;
383 case TargetIsSharedWorker:
384 return RequestContextSharedWorker;
385 case TargetIsPrefetch:
386 return RequestContextPrefetch;
387 case TargetIsFavicon:
388 return RequestContextFavicon;
389 case TargetIsXHR:
390 return RequestContextXMLHttpRequest;
391 case TargetIsTextTrack:
392 return RequestContextTrack;
393 case TargetIsPing:
394 return RequestContextPing;
395 case TargetIsServiceWorker:
396 return RequestContextServiceWorker;
397 case TargetIsUnspecified:
398 return RequestContextUnspecified;
399 }
400 ASSERT_NOT_REACHED();
401 return RequestContextUnspecified;
402 }
403
404 WebURLRequest::TargetType WebURLRequest::targetTypeFromRequestContextAndFrameTyp e(WebURLRequest::RequestContext requestContext, WebURLRequest::FrameType frameTy pe)
405 {
406 if (frameType != FrameTypeNone) {
407 ASSERT(requestContext == RequestContextForm || requestContext == Request ContextFrame || requestContext == RequestContextHyperlink || requestContext == R equestContextIframe || requestContext == RequestContextInternal || requestContex t == RequestContextLocation);
408 if (frameType == FrameTypeTopLevel || frameType == FrameTypeAuxiliary)
409 return TargetIsMainFrame;
410 if (frameType == FrameTypeNested)
411 return TargetIsSubframe;
412 ASSERT_NOT_REACHED();
413 return TargetIsUnspecified;
414 }
415
416 switch (requestContext) {
417 // Favicon
418 case RequestContextFavicon:
419 return TargetIsFavicon;
420
421 // Font
422 case RequestContextFont:
423 return TargetIsFontResource;
424
425 // Image
426 case RequestContextImage:
427 return TargetIsImage;
428
429 // Media
430 case RequestContextAudio:
431 case RequestContextVideo:
432 return TargetIsMedia;
433
434 // Object
435 case RequestContextEmbed:
436 case RequestContextObject:
437 return TargetIsObject;
438
439 // Ping
440 case RequestContextBeacon:
441 case RequestContextCSPReport:
442 case RequestContextPing:
443 return TargetIsPing;
444
445 // Prefetch
446 case RequestContextPrefetch:
447 return TargetIsPrefetch;
448
449 // Script
450 case RequestContextScript:
451 return TargetIsScript;
452
453 // Style
454 case RequestContextXSLT:
455 case RequestContextStyle:
456 return TargetIsStyleSheet;
457
458
459 // Subresource
460 case RequestContextDownload:
461 case RequestContextManifest:
462 case RequestContextSubresource:
463 case RequestContextPlugin:
464 return TargetIsSubresource;
465
466 // TextTrack
467 case RequestContextTrack:
468 return TargetIsTextTrack;
469
470 // Workers
471 case RequestContextServiceWorker:
472 return TargetIsServiceWorker;
473 case RequestContextSharedWorker:
474 return TargetIsSharedWorker;
475 case RequestContextWorker:
476 return TargetIsWorker;
477
478 // Unspecified
479 case RequestContextInternal:
480 case RequestContextUnspecified:
481 return TargetIsUnspecified;
482
483 // XHR
484 case RequestContextEventSource:
485 case RequestContextFetch:
486 case RequestContextXMLHttpRequest:
487 return TargetIsXHR;
488
489 // These should be handled by the FrameType checks at the top of the functio n.
490 // Main Frame
491 case RequestContextForm:
492 case RequestContextHyperlink:
493 case RequestContextLocation:
494 case RequestContextFrame:
495 case RequestContextIframe:
496 ASSERT_NOT_REACHED();
497 return TargetIsUnspecified;
498 }
499 ASSERT_NOT_REACHED();
500 return TargetIsUnspecified;
501 }
502
503 // FIXME: Drop these two methods once embedders are updated to use RequestContex ts.
504 WebURLRequest::TargetType WebURLRequest::targetType() const
505 {
506 // FIXME: Temporary special case until downstream chromium.org knows of the new TargetTypes.
507 TargetType targetType = WebURLRequest::targetTypeFromRequestContextAndFrameT ype(requestContext(), frameType());
508 if (targetType == TargetIsTextTrack || targetType == TargetIsUnspecified)
509 return TargetIsSubresource;
510 return targetType;
511 }
512
513 void WebURLRequest::setTargetType(TargetType targetType)
514 {
515 setRequestContext(WebURLRequest::requestContextFromTargetType(targetType));
516 if (targetType == TargetIsMainFrame)
517 setFrameType(FrameTypeTopLevel);
518 if (targetType == TargetIsSubframe)
519 setFrameType(FrameTypeNested);
520 }
521
522
523 } // namespace blink 359 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | public/platform/WebURLRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698