Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: chrome/browser/previews/previews_infobar_tab_helper.cc

Issue 2256383002: Add PreviewsInfoBarTabHelper (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@newLoFiInfoBarWithoutPercent
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/previews/previews_infobar_tab_helper.h ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 void PreviewsInfoBarTabHelper::DidStartProvisionalLoadForFrame(
28 content::RenderFrameHost* render_frame_host,
29 const GURL& validated_url,
30 bool is_error_page,
31 bool is_iframe_srcdoc) {
32 if (!render_frame_host->GetParent())
33 set_displayed_preview_infobar(false);
34 }
35
36 void PreviewsInfoBarTabHelper::DidFinishNavigation(
37 content::NavigationHandle* navigation_handle) {
38 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
39 return;
40 const net::HttpResponseHeaders* headers =
41 navigation_handle->GetResponseHeaders();
42 if (headers &&
43 headers->HasHeaderValue(
44 data_reduction_proxy::chrome_proxy_header(),
45 data_reduction_proxy::chrome_proxy_lo_fi_preview_directive())) {
46 PreviewsInfoBarDelegate::Create(navigation_handle->GetWebContents(),
47 PreviewsInfoBarDelegate::LITE_PAGE);
48 }
49 }
50
OLDNEW
« no previous file with comments | « chrome/browser/previews/previews_infobar_tab_helper.h ('k') | chrome/browser/ui/tab_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698