OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/data_reduction_proxy_tamper_de
tection.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_tamper_de
tection.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 std::string mime_type; | 299 std::string mime_type; |
300 response_headers_->GetMimeType(&mime_type); | 300 response_headers_->GetMimeType(&mime_type); |
301 | 301 |
302 std::string JS1 = "text/javascript"; | 302 std::string JS1 = "text/javascript"; |
303 std::string JS2 = "application/x-javascript"; | 303 std::string JS2 = "application/x-javascript"; |
304 std::string JS3 = "application/javascript"; | 304 std::string JS3 = "application/javascript"; |
305 std::string CSS = "text/css"; | 305 std::string CSS = "text/css"; |
306 std::string IMAGE = "image/"; | 306 std::string IMAGE = "image/"; |
307 | 307 |
308 size_t mime_type_size = mime_type.size(); | 308 size_t mime_type_size = mime_type.size(); |
309 if ((mime_type_size >= JS1.size() && | 309 if ((mime_type_size >= JS1.size() && LowerCaseEqualsASCII(mime_type.begin(), |
310 base::LowerCaseEqualsASCII(mime_type.begin(), | |
311 mime_type.begin() + JS1.size(), JS1.c_str())) || | 310 mime_type.begin() + JS1.size(), JS1.c_str())) || |
312 (mime_type_size >= JS2.size() && | 311 (mime_type_size >= JS2.size() && LowerCaseEqualsASCII(mime_type.begin(), |
313 base::LowerCaseEqualsASCII(mime_type.begin(), | |
314 mime_type.begin() + JS2.size(), JS2.c_str())) || | 312 mime_type.begin() + JS2.size(), JS2.c_str())) || |
315 (mime_type_size >= JS3.size() && | 313 (mime_type_size >= JS3.size() && LowerCaseEqualsASCII(mime_type.begin(), |
316 base::LowerCaseEqualsASCII(mime_type.begin(), | |
317 mime_type.begin() + JS3.size(), JS3.c_str()))) { | 314 mime_type.begin() + JS3.size(), JS3.c_str()))) { |
318 REPORT_TAMPER_DETECTION_UMA( | 315 REPORT_TAMPER_DETECTION_UMA( |
319 scheme_is_https_, | 316 scheme_is_https_, |
320 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_JS", | 317 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_JS", |
321 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_JS", | 318 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_JS", |
322 carrier_id_); | 319 carrier_id_); |
323 } else if (mime_type_size >= CSS.size() && | 320 } else if (mime_type_size >= CSS.size() && |
324 base::LowerCaseEqualsASCII(mime_type.begin(), | 321 LowerCaseEqualsASCII(mime_type.begin(), |
325 mime_type.begin() + CSS.size(), CSS.c_str())) { | 322 mime_type.begin() + CSS.size(), CSS.c_str())) { |
326 REPORT_TAMPER_DETECTION_UMA( | 323 REPORT_TAMPER_DETECTION_UMA( |
327 scheme_is_https_, | 324 scheme_is_https_, |
328 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_CSS", | 325 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_CSS", |
329 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_CSS", | 326 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_CSS", |
330 carrier_id_); | 327 carrier_id_); |
331 } else if (mime_type_size >= IMAGE.size() && | 328 } else if (mime_type_size >= IMAGE.size() && |
332 base::LowerCaseEqualsASCII(mime_type.begin(), | 329 LowerCaseEqualsASCII(mime_type.begin(), |
333 mime_type.begin() + IMAGE.size(), IMAGE.c_str())) { | 330 mime_type.begin() + IMAGE.size(), IMAGE.c_str())) { |
334 REPORT_TAMPER_DETECTION_UMA( | 331 REPORT_TAMPER_DETECTION_UMA( |
335 scheme_is_https_, | 332 scheme_is_https_, |
336 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Image", | 333 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Image", |
337 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_Image", | 334 "DataReductionProxy.HeaderTamperedHTTP_ContentLength_Image", |
338 carrier_id_); | 335 carrier_id_); |
339 } else { | 336 } else { |
340 REPORT_TAMPER_DETECTION_UMA( | 337 REPORT_TAMPER_DETECTION_UMA( |
341 scheme_is_https_, | 338 scheme_is_https_, |
342 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Other", | 339 "DataReductionProxy.HeaderTamperedHTTPS_ContentLength_Other", |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 std::vector<std::string> values; | 375 std::vector<std::string> values; |
379 std::string value; | 376 std::string value; |
380 void* iter = NULL; | 377 void* iter = NULL; |
381 while (headers->EnumerateHeader(&iter, header_name, &value)) { | 378 while (headers->EnumerateHeader(&iter, header_name, &value)) { |
382 values.push_back(value); | 379 values.push_back(value); |
383 } | 380 } |
384 return values; | 381 return values; |
385 } | 382 } |
386 | 383 |
387 } // namespace data_reduction_proxy | 384 } // namespace data_reduction_proxy |
OLD | NEW |