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

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

Issue 2619603002: Remove android_java_ui as it is not used (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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"
11 #include "chrome/browser/previews/previews_infobar_delegate.h" 11 #include "chrome/browser/previews/previews_infobar_delegate.h"
12 #include "chrome/browser/previews/previews_service.h" 12 #include "chrome/browser/previews/previews_service.h"
13 #include "chrome/browser/previews/previews_service_factory.h" 13 #include "chrome/browser/previews/previews_service_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/features.h" 15 #include "chrome/common/features.h"
16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h" 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett ings.h"
17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h" 17 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade rs.h"
18 #include "components/previews/core/previews_experiments.h" 18 #include "components/previews/core/previews_experiments.h"
19 #include "components/previews/core/previews_ui_service.h" 19 #include "components/previews/core/previews_ui_service.h"
20 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/navigation_handle.h" 22 #include "content/public/browser/navigation_handle.h"
23 #include "content/public/browser/render_frame_host.h" 23 #include "content/public/browser/render_frame_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 #if BUILDFLAG(ANDROID_JAVA_UI) 28 #if defined(OS_ANDROID)
29 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" 29 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
30 30
31 namespace { 31 namespace {
32 32
33 // Adds the preview navigation to the black list. This method is only used on 33 // Adds the preview navigation to the black list. This method is only used on
34 // android currently. 34 // android currently.
35 void AddPreviewNavigationCallback(content::BrowserContext* browser_context, 35 void AddPreviewNavigationCallback(content::BrowserContext* browser_context,
36 const GURL& url, 36 const GURL& url,
37 previews::PreviewsType type, 37 previews::PreviewsType type,
38 bool opt_out) { 38 bool opt_out) {
39 PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile( 39 PreviewsService* previews_service = PreviewsServiceFactory::GetForProfile(
40 Profile::FromBrowserContext(browser_context)); 40 Profile::FromBrowserContext(browser_context));
41 if (previews_service && previews_service->previews_ui_service()) { 41 if (previews_service && previews_service->previews_ui_service()) {
42 previews_service->previews_ui_service()->AddPreviewNavigation(url, type, 42 previews_service->previews_ui_service()->AddPreviewNavigation(url, type,
43 opt_out); 43 opt_out);
44 } 44 }
45 } 45 }
46 46
47 } // namespace 47 } // namespace
48 48
49 #endif // BUILDFLAG(ANDROID_JAVA_UI) 49 #endif // defined(OS_ANDROID)
50 50
51 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PreviewsInfoBarTabHelper); 51 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PreviewsInfoBarTabHelper);
52 52
53 PreviewsInfoBarTabHelper::~PreviewsInfoBarTabHelper() {} 53 PreviewsInfoBarTabHelper::~PreviewsInfoBarTabHelper() {}
54 54
55 PreviewsInfoBarTabHelper::PreviewsInfoBarTabHelper( 55 PreviewsInfoBarTabHelper::PreviewsInfoBarTabHelper(
56 content::WebContents* web_contents) 56 content::WebContents* web_contents)
57 : content::WebContentsObserver(web_contents), 57 : content::WebContentsObserver(web_contents),
58 displayed_preview_infobar_(false){ 58 displayed_preview_infobar_(false){
59 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 59 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
60 } 60 }
61 61
62 void PreviewsInfoBarTabHelper::DidFinishNavigation( 62 void PreviewsInfoBarTabHelper::DidFinishNavigation(
63 content::NavigationHandle* navigation_handle) { 63 content::NavigationHandle* navigation_handle) {
64 // Only show the infobar if this is a full main frame navigation. 64 // Only show the infobar if this is a full main frame navigation.
65 if (!navigation_handle->IsInMainFrame() || 65 if (!navigation_handle->IsInMainFrame() ||
66 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage()) 66 !navigation_handle->HasCommitted() || navigation_handle->IsSamePage())
67 return; 67 return;
68 displayed_preview_infobar_ = false; 68 displayed_preview_infobar_ = false;
69 69
70 #if BUILDFLAG(ANDROID_JAVA_UI) 70 #if defined(OS_ANDROID)
71 offline_pages::OfflinePageTabHelper* tab_helper = 71 offline_pages::OfflinePageTabHelper* tab_helper =
72 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents()); 72 offline_pages::OfflinePageTabHelper::FromWebContents(web_contents());
73 73
74 if (tab_helper && tab_helper->IsShowingOfflinePreview()) { 74 if (tab_helper && tab_helper->IsShowingOfflinePreview()) {
75 if (navigation_handle->IsErrorPage()) { 75 if (navigation_handle->IsErrorPage()) {
76 // TODO(ryansturm): Add UMA for errors. 76 // TODO(ryansturm): Add UMA for errors.
77 return; 77 return;
78 } 78 }
79 data_reduction_proxy::DataReductionProxySettings* 79 data_reduction_proxy::DataReductionProxySettings*
80 data_reduction_proxy_settings = 80 data_reduction_proxy_settings =
81 DataReductionProxyChromeSettingsFactory::GetForBrowserContext( 81 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(
82 web_contents()->GetBrowserContext()); 82 web_contents()->GetBrowserContext());
83 PreviewsInfoBarDelegate::Create( 83 PreviewsInfoBarDelegate::Create(
84 web_contents(), PreviewsInfoBarDelegate::OFFLINE, 84 web_contents(), PreviewsInfoBarDelegate::OFFLINE,
85 data_reduction_proxy_settings && 85 data_reduction_proxy_settings &&
86 data_reduction_proxy_settings->IsDataReductionProxyEnabled(), 86 data_reduction_proxy_settings->IsDataReductionProxyEnabled(),
87 base::Bind( 87 base::Bind(
88 &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(), 88 &AddPreviewNavigationCallback, web_contents()->GetBrowserContext(),
89 navigation_handle->GetURL(), previews::PreviewsType::OFFLINE)); 89 navigation_handle->GetURL(), previews::PreviewsType::OFFLINE));
90 // Don't try to show other infobars if this is an offline preview. 90 // Don't try to show other infobars if this is an offline preview.
91 return; 91 return;
92 } 92 }
93 #endif // BUILDFLAG(ANDROID_JAVA_UI) 93 #endif // defined(OS_ANDROID)
94 94
95 const net::HttpResponseHeaders* headers = 95 const net::HttpResponseHeaders* headers =
96 navigation_handle->GetResponseHeaders(); 96 navigation_handle->GetResponseHeaders();
97 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) { 97 if (headers && data_reduction_proxy::IsLitePagePreview(*headers)) {
98 PreviewsInfoBarDelegate::Create( 98 PreviewsInfoBarDelegate::Create(
99 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE, 99 web_contents(), PreviewsInfoBarDelegate::LITE_PAGE,
100 true /* is_data_saver_user */, 100 true /* is_data_saver_user */,
101 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback()); 101 PreviewsInfoBarDelegate::OnDismissPreviewsInfobarCallback());
102 } 102 }
103 } 103 }
104 104
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698