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_service.h" | 5 #include "chrome/browser/previews/previews_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
11 #include "base/task_scheduler/post_task.h" | 11 #include "base/task_scheduler/post_task.h" |
12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_featu
res.h" |
13 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 14 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
14 #include "components/previews/core/previews_experiments.h" | 15 #include "components/previews/core/previews_experiments.h" |
15 #include "components/previews/core/previews_io_data.h" | 16 #include "components/previews/core/previews_io_data.h" |
16 #include "components/previews/core/previews_opt_out_store.h" | 17 #include "components/previews/core/previews_opt_out_store.h" |
17 #include "components/previews/core/previews_opt_out_store_sql.h" | 18 #include "components/previews/core/previews_opt_out_store_sql.h" |
18 #include "components/previews/core/previews_ui_service.h" | 19 #include "components/previews/core/previews_ui_service.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Returns true if previews can be shown for |type|. | 24 // Returns true if previews can be shown for |type|. |
24 bool IsPreviewsTypeEnabled(previews::PreviewsType type) { | 25 bool IsPreviewsTypeEnabled(previews::PreviewsType type) { |
| 26 bool server_previews_enabled = base::FeatureList::IsEnabled( |
| 27 data_reduction_proxy::features::kDataReductionProxyDecidesTransform); |
25 switch (type) { | 28 switch (type) { |
26 case previews::PreviewsType::OFFLINE: | 29 case previews::PreviewsType::OFFLINE: |
27 return previews::params::IsOfflinePreviewsEnabled(); | 30 return previews::params::IsOfflinePreviewsEnabled(); |
28 case previews::PreviewsType::LOFI: | 31 case previews::PreviewsType::LOFI: |
29 return previews::params::IsClientLoFiEnabled() || | 32 return server_previews_enabled || |
| 33 previews::params::IsClientLoFiEnabled() || |
30 data_reduction_proxy::params::IsLoFiOnViaFlags() || | 34 data_reduction_proxy::params::IsLoFiOnViaFlags() || |
31 data_reduction_proxy::params::IsIncludedInLoFiEnabledFieldTrial(); | 35 data_reduction_proxy::params::IsIncludedInLoFiEnabledFieldTrial(); |
32 case previews::PreviewsType::LITE_PAGE: | 36 case previews::PreviewsType::LITE_PAGE: |
33 return (data_reduction_proxy::params::IsLoFiOnViaFlags() && | 37 return server_previews_enabled || |
| 38 (data_reduction_proxy::params::IsLoFiOnViaFlags() && |
34 data_reduction_proxy::params::AreLitePagesEnabledViaFlags()) || | 39 data_reduction_proxy::params::AreLitePagesEnabledViaFlags()) || |
35 data_reduction_proxy::params::IsIncludedInLitePageFieldTrial(); | 40 data_reduction_proxy::params::IsIncludedInLitePageFieldTrial(); |
36 case previews::PreviewsType::NONE: | 41 case previews::PreviewsType::NONE: |
37 case previews::PreviewsType::LAST: | 42 case previews::PreviewsType::LAST: |
38 break; | 43 break; |
39 } | 44 } |
40 NOTREACHED(); | 45 NOTREACHED(); |
41 return false; | 46 return false; |
42 } | 47 } |
43 | 48 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 {base::MayBlock(), base::TaskPriority::BACKGROUND}); | 101 {base::MayBlock(), base::TaskPriority::BACKGROUND}); |
97 | 102 |
98 previews_ui_service_ = base::MakeUnique<previews::PreviewsUIService>( | 103 previews_ui_service_ = base::MakeUnique<previews::PreviewsUIService>( |
99 previews_io_data, io_task_runner, | 104 previews_io_data, io_task_runner, |
100 base::MakeUnique<previews::PreviewsOptOutStoreSQL>( | 105 base::MakeUnique<previews::PreviewsOptOutStoreSQL>( |
101 io_task_runner, background_task_runner, | 106 io_task_runner, background_task_runner, |
102 profile_path.Append(chrome::kPreviewsOptOutDBFilename), | 107 profile_path.Append(chrome::kPreviewsOptOutDBFilename), |
103 GetEnabledPreviews()), | 108 GetEnabledPreviews()), |
104 base::Bind(&IsPreviewsTypeEnabled)); | 109 base::Bind(&IsPreviewsTypeEnabled)); |
105 } | 110 } |
OLD | NEW |