Index: include/AdblockPlus/ReferrerMapping.h
diff --git a/include/AdblockPlus/ReferrerMapping.h b/include/AdblockPlus/ReferrerMapping.h
index 76d7cbfdfed15ca0b1e022709e15e48dbe481e53..98fd0b5c092d2bec35f1021c1c742b32fe69032e 100644
--- a/include/AdblockPlus/ReferrerMapping.h
+++ b/include/AdblockPlus/ReferrerMapping.h
@@ -22,18 +22,29 @@
 #include <map>
 #include <string>
 #include <vector>
+#include "FilterEngine.h"
 
 namespace AdblockPlus
 {
   /**
    * Stores a mapping between URLs and their referrers.
-   * This can be used to build a chain of referrers for any URL
-   * (see `BuildReferrerChain()`), which approximates the frame structure, see
-   * FilterEngine::Matches().
+   * This can be used to build a frame structure for any URL
+   * (see `BuildFrameStructure()`), it's useful for FilterEngine::Matches().
    */
   class ReferrerMapping
   {
   public:
+    /// The type for URL.
+    typedef std::string Url;
+
+    /// Contains an ordered list of URLs.
+    typedef std::vector<Url> Urls;
+
+    /// Indicates whether the URL is a frame or not.
+    enum FrameIndicator
+    {
+      FRAME_INDICATOR_NOT_FRAME = 0, FRAME_INDICATOR_FRAME = 1
+    };
     /**
      * Constructor.
      * @param maxCachedUrls Number of URL mappings to store. The higher the
@@ -46,21 +57,37 @@ namespace AdblockPlus
      * Records the refferer for a URL.
      * @param url Request URL.
      * @param referrer Request referrer.
+     * @param isFrame Indicates whether the url is a frame.
      */
-    void Add(const std::string& url, const std::string& referrer);
+    void Add(const Url& url, const Url& referrer, FrameIndicator isFrame);
 
     /**
-     * Builds a chain of referrers for the supplied URL.
+     * Builds a frame structure for the supplied URL.
      * This should reconstruct a document's parent frame URLs.
-     * @param url URL to build the chain for.
-     * @return List of URLs, starting with `url`.
+     * @param url URL to build the chain for, it is referrer as well.
+     * @return List of URLs, finishing with `url`.
      */
-    std::vector<std::string> BuildReferrerChain(const std::string& url) const;
+    Urls BuildFrameStructure(const Url& url) const;
 
   private:
     const int maxCachedUrls;
-    std::map<std::string, std::string> mapping;
-    std::list<std::string> cachedUrls;
+    struct RequestInfo
+    {
+      explicit RequestInfo(const Url& referrerArg = Url(),
+        FrameIndicator frameIndicatorArg = FrameIndicator::FRAME_INDICATOR_NOT_FRAME)
+        : referrer(referrerArg), frameIndicator(frameIndicatorArg)
+      {
+      }
+      bool IsFrame() const
+      {
+        return frameIndicator == FrameIndicator::FRAME_INDICATOR_FRAME;
+      }
+      Url referrer;
+      FrameIndicator frameIndicator;
+    };
+    typedef std::map<Url, RequestInfo> ReferrerMap;
+    ReferrerMap mapping;
+    std::list<Url> cachedUrls;
   };
 }
 
