| Index: chrome/browser/previews/previews_infobar_tab_helper.cc
 | 
| diff --git a/chrome/browser/previews/previews_infobar_tab_helper.cc b/chrome/browser/previews/previews_infobar_tab_helper.cc
 | 
| index 917d3ebfe75f971b74c06c06e12e3d47bda40eee..3083f0c3483687a308b5bbdb2dee1819fabd85ee 100644
 | 
| --- a/chrome/browser/previews/previews_infobar_tab_helper.cc
 | 
| +++ b/chrome/browser/previews/previews_infobar_tab_helper.cc
 | 
| @@ -6,12 +6,15 @@
 | 
|  
 | 
|  #include "base/bind.h"
 | 
|  #include "base/bind_helpers.h"
 | 
| +#include "chrome/browser/loader/chrome_navigation_data.h"
 | 
|  #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
 | 
|  #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_factory.h"
 | 
|  #include "chrome/browser/previews/previews_infobar_delegate.h"
 | 
|  #include "chrome/browser/previews/previews_service.h"
 | 
|  #include "chrome/browser/previews/previews_service_factory.h"
 | 
|  #include "chrome/browser/profiles/profile.h"
 | 
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h"
 | 
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
 | 
|  #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
 | 
|  #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
 | 
|  #include "components/previews/core/previews_experiments.h"
 | 
| @@ -49,12 +52,15 @@ void AddPreviewNavigationCallback(content::BrowserContext* browser_context,
 | 
|  
 | 
|  DEFINE_WEB_CONTENTS_USER_DATA_KEY(PreviewsInfoBarTabHelper);
 | 
|  
 | 
| -PreviewsInfoBarTabHelper::~PreviewsInfoBarTabHelper() {}
 | 
| +PreviewsInfoBarTabHelper::~PreviewsInfoBarTabHelper() {
 | 
| +  ClearLastNavigationAsync();
 | 
| +}
 | 
|  
 | 
|  PreviewsInfoBarTabHelper::PreviewsInfoBarTabHelper(
 | 
|      content::WebContents* web_contents)
 | 
|      : content::WebContentsObserver(web_contents),
 | 
| -      displayed_preview_infobar_(false){
 | 
| +      browser_context_(web_contents->GetBrowserContext()),
 | 
| +      displayed_preview_infobar_(false) {
 | 
|    DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
 | 
|  }
 | 
|  
 | 
| @@ -65,6 +71,26 @@ void PreviewsInfoBarTabHelper::DidFinishNavigation(
 | 
|        !navigation_handle->HasCommitted() || navigation_handle->IsSameDocument())
 | 
|      return;
 | 
|    displayed_preview_infobar_ = false;
 | 
| +  ClearLastNavigationAsync();
 | 
| +  committed_data_saver_navigation_id_.reset();
 | 
| +
 | 
| +  // As documented in content/public/browser/navigation_handle.h, this
 | 
| +  // NavigationData is a clone of the NavigationData instance returned from
 | 
| +  // ResourceDispatcherHostDelegate::GetNavigationData during commit.
 | 
| +  // Because ChromeResourceDispatcherHostDelegate always returns a
 | 
| +  // ChromeNavigationData, it is safe to static_cast here.
 | 
| +  ChromeNavigationData* chrome_navigation_data =
 | 
| +      static_cast<ChromeNavigationData*>(
 | 
| +          navigation_handle->GetNavigationData());
 | 
| +  if (chrome_navigation_data) {
 | 
| +    data_reduction_proxy::DataReductionProxyData* data =
 | 
| +        chrome_navigation_data->GetDataReductionProxyData();
 | 
| +
 | 
| +    if (data && data->page_id()) {
 | 
| +      committed_data_saver_navigation_id_ = data_reduction_proxy::NavigationID(
 | 
| +          data->page_id().value(), data->session_key());
 | 
| +    }
 | 
| +  }
 | 
|  
 | 
|  #if defined(OS_ANDROID)
 | 
|    offline_pages::OfflinePageTabHelper* tab_helper =
 | 
| @@ -83,9 +109,9 @@ void PreviewsInfoBarTabHelper::DidFinishNavigation(
 | 
|          web_contents(), PreviewsInfoBarDelegate::OFFLINE,
 | 
|          data_reduction_proxy_settings &&
 | 
|              data_reduction_proxy_settings->IsDataReductionProxyEnabled(),
 | 
| -        base::Bind(
 | 
| -            &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(),
 | 
| -            navigation_handle->GetURL(), previews::PreviewsType::OFFLINE));
 | 
| +        base::Bind(&AddPreviewNavigationCallback, browser_context_,
 | 
| +                   navigation_handle->GetURL(),
 | 
| +                   previews::PreviewsType::OFFLINE));
 | 
|      // Don't try to show other infobars if this is an offline preview.
 | 
|      return;
 | 
|    }
 | 
| @@ -101,3 +127,17 @@ void PreviewsInfoBarTabHelper::DidFinishNavigation(
 | 
|    }
 | 
|  }
 | 
|  
 | 
| +void PreviewsInfoBarTabHelper::ClearLastNavigationAsync() const {
 | 
| +  if (!committed_data_saver_navigation_id_)
 | 
| +    return;
 | 
| +  auto* data_reduction_proxy_settings =
 | 
| +      DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
 | 
| +          browser_context_);
 | 
| +  if (!data_reduction_proxy_settings ||
 | 
| +      !data_reduction_proxy_settings->data_reduction_proxy_service()) {
 | 
| +    return;
 | 
| +  }
 | 
| +  data_reduction_proxy_settings->data_reduction_proxy_service()
 | 
| +      ->pingback_client()
 | 
| +      ->ClearNavigationKeyAsync(committed_data_saver_navigation_id_.value());
 | 
| +}
 | 
| 
 |