Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

documentreferrer.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. *
  3. * Copyright (C) 2002-2011 Opera Software AS. All rights reserved.
  4. *
  5. * This file is part of the Opera web browser.
  6. * It may not be distributed under any circumstances.
  7. */
  8. #ifndef _DOCUMENTREFERER_H_
  9. #define _DOCUMENTREFERER_H_
  10. #include "modules/url/url2.h"
  11. class DocumentOrigin;
  12. class FramesDocument;
  13. /**
  14. * This class represents the cause of a document load. It's used both
  15. * to deduce HTTP Referrer and to deduce the best security context for
  16. * the new document in case the new document doesn't have an inherent
  17. * security context. If a document load has its origin in another
  18. * document, then the DocumentReferrer should preferably be generated
  19. * through that document's DocumentOrigin object.
  20. */
  21. class DocumentReferrer
  22. {
  23. public:
  24. /**
  25. * The referrer url. Will be set even if the non-URL version of the
  26. * constructor is used.
  27. */
  28. URL url;
  29. /**
  30. * The DocumentOrigin of the document requesting the new document load.
  31. */
  32. DocumentOrigin* origin; ///< Owns a reference to the origin if it's not NULL.
  33. /**
  34. * Creates an empty referrer. Explicit since this is an opportunity
  35. * to lose security information and should only be used to user
  36. * started top level document loads.
  37. */
  38. explicit DocumentReferrer() : origin(NULL) {}
  39. /**
  40. * Creates a DocumentReferrer from an url. This is not the preferred
  41. * constructor. If possible, use one based on a document since if
  42. * the url sent in here is a data: url it doesn't have the security
  43. * information we need.
  44. */
  45. explicit DocumentReferrer(URL url) : url(url), origin(NULL) {}
  46. /**
  47. * Creates a DocumentReferrer based on the DocumentOrigin of a
  48. * document.
  49. */
  50. DocumentReferrer(FramesDocument* doc);
  51. /**
  52. * Creates a DocumentReferrer based on the DocumentOrigin of a
  53. * document. The DocumentReferrer will add a reference to the
  54. * DocumentOrigin.
  55. */
  56. DocumentReferrer(DocumentOrigin* origin);
  57. /**
  58. * Destructor. Will release the reference to the origin.
  59. */
  60. ~DocumentReferrer();
  61. /**
  62. * Copy constructor.
  63. */
  64. DocumentReferrer(const DocumentReferrer& other);
  65. /**
  66. * Assignment operator.
  67. */
  68. DocumentReferrer& operator=(const DocumentReferrer& other);
  69. /**
  70. * Check if the referrer is empty (i.e. there is no information
  71. * to base HTTP headers or future security contexts on.
  72. */
  73. BOOL IsEmpty() { return url.IsEmpty(); }
  74. };
  75. #endif /* _DOCUMENTREFERER_H_ */