Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/previews/previews_infobar_tab_helper.h" | |
| 6 | |
| 7 #include "chrome/browser/previews/previews_infobar_delegate.h" | |
| 8 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 #include "content/public/browser/navigation_handle.h" | |
| 11 #include "content/public/browser/render_frame_host.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 #include "net/http/http_response_headers.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PreviewsInfoBarTabHelper); | |
| 17 | |
| 18 PreviewsInfoBarTabHelper::~PreviewsInfoBarTabHelper() {} | |
| 19 | |
| 20 PreviewsInfoBarTabHelper::PreviewsInfoBarTabHelper( | |
| 21 content::WebContents* web_contents) | |
| 22 : content::WebContentsObserver(web_contents), | |
| 23 displayed_preview_infobar_(false) { | |
| 24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 25 } | |
| 26 | |
| 27 bool PreviewsInfoBarTabHelper::DisplayedPreviewInfoBar() const { | |
| 28 return displayed_preview_infobar_; | |
| 29 } | |
| 30 | |
| 31 void PreviewsInfoBarTabHelper::SetDisplayedPreviewInfoBar(bool displayed) { | |
| 32 displayed_preview_infobar_ = displayed; | |
| 33 } | |
| 34 | |
| 35 void PreviewsInfoBarTabHelper::DidStartProvisionalLoadForFrame( | |
| 36 content::RenderFrameHost* render_frame_host, | |
| 37 const GURL& validated_url, | |
| 38 bool is_error_page, | |
| 39 bool is_iframe_srcdoc) { | |
| 40 if (!render_frame_host->GetParent()) { | |
|
bengr
2016/08/31 23:27:04
Remove curly braces.
megjablon
2016/09/08 00:25:15
Done.
| |
| 41 SetDisplayedPreviewInfoBar(false); | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 void PreviewsInfoBarTabHelper::DidFinishNavigation( | |
| 46 content::NavigationHandle* navigation_handle) { | |
| 47 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) | |
| 48 return; | |
| 49 const net::HttpResponseHeaders* headers = | |
| 50 navigation_handle->GetResponseHeaders(); | |
| 51 if (headers && headers->HasHeaderValue( | |
|
bengr
2016/08/31 23:27:04
Indentation is off.
megjablon
2016/09/08 00:25:15
Done.
| |
| 52 data_reduction_proxy::chrome_proxy_header(), | |
| 53 data_reduction_proxy::chrome_proxy_lo_fi_preview_directive())) { | |
| 54 PreviewsInfoBarDelegate::Create(navigation_handle->GetWebContents(), | |
| 55 PreviewsInfoBarDelegate::LITE_PAGE); | |
| 56 } | |
| 57 } | |
| 58 | |
| OLD | NEW |