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

Side by Side Diff: chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.cc

Issue 2250223002: Add InfoBar delegate for previews (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: optimize png files 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" 5 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/net/spdyproxy/chrome_data_use_group_provider.h" 12 #include "chrome/browser/net/spdyproxy/chrome_data_use_group_provider.h"
13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" 13 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
14 #include "chrome/browser/previews/previews_infobar_delegate.h"
14 #include "chrome/common/channel_info.h" 15 #include "chrome/common/channel_info.h"
15 #include "chrome/common/chrome_content_client.h" 16 #include "chrome/common/chrome_content_client.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h " 18 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h "
18 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h" 19 #include "components/data_reduction_proxy/content/browser/content_lofi_ui_servic e.h"
19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" 20 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h"
20 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" 21 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h"
21 #include "components/prefs/pref_service.h" 22 #include "components/prefs/pref_service.h"
22 #include "components/version_info/version_info.h" 23 #include "components/version_info/version_info.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 26
26 #if defined(OS_ANDROID) 27 #if defined(OS_ANDROID)
27 #include "base/android/build_info.h" 28 #include "base/android/build_info.h"
28 #include "chrome/browser/android/tab_android.h"
29 #endif 29 #endif
30 30
31 namespace content { 31 namespace content {
32 class BrowserContext; 32 class BrowserContext;
33 } 33 }
34 34
35 using data_reduction_proxy::DataReductionProxyParams; 35 using data_reduction_proxy::DataReductionProxyParams;
36 36
37 namespace { 37 namespace {
38 38
39 // For Android builds, notifies the TabAndroid associated with |web_contents| 39 // If this is the first Lo-Fi response for a page load, a
40 // that a Lo-Fi response has been received. The TabAndroid then handles showing 40 // PreviewsInfoBarDelegate is created which handles showing Lo-Fi UI
bengr 2016/08/31 23:37:34 created which -> created, which showing -> showing
Peter Kasting 2016/09/01 07:16:55 For this piece of your suggestion: On 2016/08/31
megjablon 2016/09/08 00:25:45 Changed the other two
41 // Lo-Fi UI if this is the first Lo-Fi response for a page load. |is_preview| 41 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents) {
42 // indicates whether the response was a Lo-Fi preview response.
43 void OnLoFiResponseReceivedOnUI(content::WebContents* web_contents,
44 bool is_preview) {
45 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
46 #if defined(OS_ANDROID) 43 PreviewsInfoBarDelegate::Create(web_contents, PreviewsInfoBarDelegate::LOFI);
47 TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
48 if (tab)
49 tab->OnLoFiResponseReceived(is_preview);
50 #endif
51 } 44 }
52 45
53 } // namespace 46 } // namespace
54 47
55 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> 48 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
56 CreateDataReductionProxyChromeIOData( 49 CreateDataReductionProxyChromeIOData(
57 net::NetLog* net_log, 50 net::NetLog* net_log,
58 PrefService* prefs, 51 PrefService* prefs,
59 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, 52 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
60 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { 53 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) {
(...skipping 26 matching lines...) Expand all
87 data_reduction_proxy_io_data->set_lofi_decider( 80 data_reduction_proxy_io_data->set_lofi_decider(
88 base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider())); 81 base::WrapUnique(new data_reduction_proxy::ContentLoFiDecider()));
89 data_reduction_proxy_io_data->set_lofi_ui_service( 82 data_reduction_proxy_io_data->set_lofi_ui_service(
90 base::WrapUnique(new data_reduction_proxy::ContentLoFiUIService( 83 base::WrapUnique(new data_reduction_proxy::ContentLoFiUIService(
91 ui_task_runner, base::Bind(&OnLoFiResponseReceivedOnUI)))); 84 ui_task_runner, base::Bind(&OnLoFiResponseReceivedOnUI))));
92 data_reduction_proxy_io_data->set_data_usage_source_provider( 85 data_reduction_proxy_io_data->set_data_usage_source_provider(
93 base::WrapUnique(new ChromeDataUseGroupProvider())); 86 base::WrapUnique(new ChromeDataUseGroupProvider()));
94 87
95 return data_reduction_proxy_io_data; 88 return data_reduction_proxy_io_data;
96 } 89 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698