| Index: src/ReferrerMapping.cpp | 
| diff --git a/src/ReferrerMapping.cpp b/src/ReferrerMapping.cpp | 
| index 7ac6cddff5bf2452670c6d2b986f0802fb5de4d2..0dae687e90bbd7af59ce89c117f6294411e0c937 100644 | 
| --- a/src/ReferrerMapping.cpp | 
| +++ b/src/ReferrerMapping.cpp | 
| @@ -24,12 +24,12 @@ ReferrerMapping::ReferrerMapping(const int maxCachedUrls) | 
| { | 
| } | 
|  | 
| -void ReferrerMapping::Add(const std::string& url, const std::string& referrer) | 
| +void ReferrerMapping::Add(const Url& url, const Url& referrer, FrameIndicator isFrame) | 
| { | 
| if (mapping.find(url) != mapping.end()) | 
| cachedUrls.remove(url); | 
| cachedUrls.push_back(url); | 
| -  mapping[url] = referrer; | 
| +  mapping[url] = RequestInfo(referrer, isFrame); | 
|  | 
| const int urlsToPop = cachedUrls.size() - maxCachedUrls; | 
| for (int i = 0; i < urlsToPop; i++) | 
| @@ -40,21 +40,35 @@ void ReferrerMapping::Add(const std::string& url, const std::string& referrer) | 
| } | 
| } | 
|  | 
| -std::vector<std::string> ReferrerMapping::BuildReferrerChain( | 
| -  const std::string& url) const | 
| +ReferrerMapping::Urls ReferrerMapping::BuildFrameStructure(const Url& url) const | 
| { | 
| -  std::vector<std::string> referrerChain; | 
| -  referrerChain.push_back(url); | 
| +  Urls frames; | 
| // We need to limit the chain length to ensure we don't block indefinitely | 
| // if there's a referrer loop. | 
| const int maxChainLength = 10; | 
| -  std::map<std::string, std::string>::const_iterator currentEntry = | 
| +  ReferrerMap::const_iterator currentEntry = url.empty() ? mapping.end() : | 
| mapping.find(url); | 
| +  ReferrerMap::const_iterator prevEntry = mapping.end(); | 
| for (int i = 0; i < maxChainLength && currentEntry != mapping.end(); i++) | 
| { | 
| -    const std::string& currentUrl = currentEntry->second; | 
| -    referrerChain.insert(referrerChain.begin(), currentUrl); | 
| -    currentEntry = mapping.find(currentUrl); | 
| +    if (currentEntry->second.IsFrame()) | 
| +    { | 
| +      frames.insert(frames.begin(), currentEntry->first); | 
| +    } | 
| +    prevEntry = currentEntry; | 
| +    currentEntry = mapping.find(currentEntry->second.referrer); | 
| } | 
| -  return referrerChain; | 
| +  if (prevEntry == mapping.end()) | 
| +  { | 
| +    if (!url.empty()) | 
| +    { | 
| +      // No data, just assume that the url is a frame. | 
| +      frames.push_back(url); | 
| +    } | 
| +  } | 
| +  else if (!prevEntry->second.referrer.empty()) | 
| +  { | 
| +    frames.insert(frames.begin(), prevEntry->second.referrer); | 
| +  } | 
| +  return frames; | 
| } | 
|  |