Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..30ed6d27d192f1a766fcd93e4597e36463f462de |
| --- /dev/null |
| +++ b/chrome/browser/previews/previews_infobar_tab_helper.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/previews/previews_infobar_tab_helper.h" |
| + |
| +#include "chrome/browser/previews/previews_infobar_delegate.h" |
| +#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/navigation_handle.h" |
| +#include "content/public/browser/render_frame_host.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "net/http/http_response_headers.h" |
| +#include "url/gurl.h" |
| + |
| +DEFINE_WEB_CONTENTS_USER_DATA_KEY(PreviewsInfoBarTabHelper); |
| + |
| +PreviewsInfoBarTabHelper::~PreviewsInfoBarTabHelper() {} |
| + |
| +PreviewsInfoBarTabHelper::PreviewsInfoBarTabHelper( |
| + content::WebContents* web_contents) |
| + : content::WebContentsObserver(web_contents), |
| + displayed_preview_infobar_(false) { |
| + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| +} |
| + |
| +bool PreviewsInfoBarTabHelper::DisplayedPreviewInfoBar() const { |
| + return displayed_preview_infobar_; |
| +} |
| + |
| +void PreviewsInfoBarTabHelper::SetDisplayedPreviewInfoBar(bool displayed) { |
| + displayed_preview_infobar_ = displayed; |
| +} |
| + |
| +void PreviewsInfoBarTabHelper::DidStartProvisionalLoadForFrame( |
| + content::RenderFrameHost* render_frame_host, |
| + const GURL& validated_url, |
| + bool is_error_page, |
| + bool is_iframe_srcdoc) { |
| + if (!render_frame_host->GetParent()) { |
|
bengr
2016/08/31 23:27:04
Remove curly braces.
megjablon
2016/09/08 00:25:15
Done.
|
| + SetDisplayedPreviewInfoBar(false); |
| + } |
| +} |
| + |
| +void PreviewsInfoBarTabHelper::DidFinishNavigation( |
| + content::NavigationHandle* navigation_handle) { |
| + if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
| + return; |
| + const net::HttpResponseHeaders* headers = |
| + navigation_handle->GetResponseHeaders(); |
| + if (headers && headers->HasHeaderValue( |
|
bengr
2016/08/31 23:27:04
Indentation is off.
megjablon
2016/09/08 00:25:15
Done.
|
| + data_reduction_proxy::chrome_proxy_header(), |
| + data_reduction_proxy::chrome_proxy_lo_fi_preview_directive())) { |
| + PreviewsInfoBarDelegate::Create(navigation_handle->GetWebContents(), |
| + PreviewsInfoBarDelegate::LITE_PAGE); |
| + } |
| +} |
| + |