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

Side by Side Diff: components/data_reduction_proxy/content/browser/content_lofi_decider.cc

Issue 2887423002: Add an about:flag to support alternative data saver features (Closed)
Patch Set: enums feature Created 3 years, 7 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 "components/data_reduction_proxy/content/browser/content_lofi_decider.h " 5 #include "components/data_reduction_proxy/content/browser/content_lofi_decider.h "
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 std::string transform_type; 173 std::string transform_type;
174 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &transform_type); 174 base::TrimWhitespaceASCII(tokens[0], base::TRIM_ALL, &transform_type);
175 return transform_type == lite_page_directive(); 175 return transform_type == lite_page_directive();
176 } 176 }
177 177
178 void ContentLoFiDecider::RemoveAcceptTransformHeader( 178 void ContentLoFiDecider::RemoveAcceptTransformHeader(
179 net::HttpRequestHeaders* headers) const { 179 net::HttpRequestHeaders* headers) const {
180 headers->RemoveHeader(chrome_proxy_accept_transform_header()); 180 headers->RemoveHeader(chrome_proxy_accept_transform_header());
181 } 181 }
182 182
183 void ContentLoFiDecider::MaybeSetIgnorePreviewsBlacklistDirective(
tbansal1 2017/05/19 16:27:23 Thanks for the cleanup. The new logic is much bett
RyanSturm 2017/05/23 22:04:57 Acknowledged.
184 net::HttpRequestHeaders* headers) const {
185 if (!headers || !params::AreLitePagesEnabledViaFlags() ||
186 !IsLitePagePreviewRequested(*headers)) {
187 return;
188 }
189 std::string chrome_proxy_header_value;
190 headers->GetHeader(chrome_proxy_header(), &chrome_proxy_header_value);
191 headers->RemoveHeader(chrome_proxy_header());
192 if (!chrome_proxy_header_value.empty())
193 chrome_proxy_header_value += ", ";
194 chrome_proxy_header_value +=
195 chrome_proxy_lite_page_ignore_blacklist_directive();
196 headers->SetHeader(chrome_proxy_header(), chrome_proxy_header_value);
197 }
198
199 bool ContentLoFiDecider::ShouldRecordLoFiUMA( 183 bool ContentLoFiDecider::ShouldRecordLoFiUMA(
200 const net::URLRequest& request) const { 184 const net::URLRequest& request) const {
201 const content::ResourceRequestInfo* request_info = 185 const content::ResourceRequestInfo* request_info =
202 content::ResourceRequestInfo::ForRequest(&request); 186 content::ResourceRequestInfo::ForRequest(&request);
203 187
204 // User is not using Lo-Fi. 188 // User is not using Lo-Fi.
205 if (!request_info || 189 if (!request_info ||
206 !(request_info->GetPreviewsState() & content::SERVER_LOFI_ON || 190 !(request_info->GetPreviewsState() & content::SERVER_LOFI_ON ||
207 request_info->GetPreviewsState() & content::SERVER_LITE_PAGE_ON)) { 191 request_info->GetPreviewsState() & content::SERVER_LITE_PAGE_ON)) {
208 return false; 192 return false;
(...skipping 13 matching lines...) Expand all
222 } 206 }
223 207
224 bool ContentLoFiDecider::IsClientLoFiAutoReloadRequest( 208 bool ContentLoFiDecider::IsClientLoFiAutoReloadRequest(
225 const net::URLRequest& request) const { 209 const net::URLRequest& request) const {
226 const content::ResourceRequestInfo* request_info = 210 const content::ResourceRequestInfo* request_info =
227 content::ResourceRequestInfo::ForRequest(&request); 211 content::ResourceRequestInfo::ForRequest(&request);
228 return request_info && 212 return request_info &&
229 (request_info->GetPreviewsState() & content::CLIENT_LOFI_AUTO_RELOAD); 213 (request_info->GetPreviewsState() & content::CLIENT_LOFI_AUTO_RELOAD);
230 } 214 }
231 } // namespace data_reduction_proxy 215 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698