OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/previews/previews_infobar_tab_helper.h" | 5 #include "chrome/browser/previews/previews_infobar_tab_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | 9 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | 10 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 content::WebContents* web_contents) | 55 content::WebContents* web_contents) |
56 : content::WebContentsObserver(web_contents), | 56 : content::WebContentsObserver(web_contents), |
57 displayed_preview_infobar_(false){ | 57 displayed_preview_infobar_(false){ |
58 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 58 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
59 } | 59 } |
60 | 60 |
61 void PreviewsInfoBarTabHelper::DidFinishNavigation( | 61 void PreviewsInfoBarTabHelper::DidFinishNavigation( |
62 content::NavigationHandle* navigation_handle) { | 62 content::NavigationHandle* navigation_handle) { |
63 // Only show the infobar if this is a full main frame navigation. | 63 // Only show the infobar if this is a full main frame navigation. |
64 if (!navigation_handle->IsInMainFrame() || | 64 if (!navigation_handle->IsInMainFrame() || |
65 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage()) | 65 !navigation_handle->HasCommitted() || navigation_handle->IsSameDocument()) |
66 return; | 66 return; |
67 displayed_preview_infobar_ = false; | 67 displayed_preview_infobar_ = false; |
68 | 68 |
69 #if defined(OS_ANDROID) | 69 #if defined(OS_ANDROID) |
70 offline_pages::OfflinePageTabHelper* tab_helper = | 70 offline_pages::OfflinePageTabHelper* tab_helper = |
71 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents()); | 71 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents()); |
72 | 72 |
73 if (tab_helper && tab_helper->IsShowingOfflinePreview()) { | 73 if (tab_helper && tab_helper->IsShowingOfflinePreview()) { |
74 if (navigation_handle->IsErrorPage()) { | 74 if (navigation_handle->IsErrorPage()) { |
75 // TODO(ryansturm): Add UMA for errors. | 75 // TODO(ryansturm): Add UMA for errors. |
(...skipping 18 matching lines...) Expand all Loading... |
94 const net::HttpResponseHeaders* headers = | 94 const net::HttpResponseHeaders* headers = |
95 navigation_handle->GetResponseHeaders(); | 95 navigation_handle->GetResponseHeaders(); |
96 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { | 96 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { |
97 PreviewsInfoBarDelegate::Create( | 97 PreviewsInfoBarDelegate::Create( |
98 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, | 98 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, |
99 true /* is_data_saver_user */, | 99 true /* is_data_saver_user */, |
100 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); | 100 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
OLD | NEW |