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

Side by Side Diff: net/base/mime_sniffer.cc

Issue 7811006: Add full support for filesystem URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Test updates Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Detecting mime types is a tricky business because we need to balance 5 // Detecting mime types is a tricky business because we need to balance
6 // compatibility concerns with security issues. Here is a survey of how other 6 // compatibility concerns with security issues. Here is a survey of how other
7 // browsers behave and then a description of how we intend to behave. 7 // browsers behave and then a description of how we intend to behave.
8 // 8 //
9 // HTML payload, no Content-Type header: 9 // HTML payload, no Content-Type header:
10 // * IE 7: Render as HTML 10 // * IE 7: Render as HTML
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 } 560 }
561 561
562 return true; 562 return true;
563 } 563 }
564 564
565 bool ShouldSniffMimeType(const GURL& url, const std::string& mime_type) { 565 bool ShouldSniffMimeType(const GURL& url, const std::string& mime_type) {
566 static base::Histogram* should_sniff_counter(NULL); 566 static base::Histogram* should_sniff_counter(NULL);
567 if (!should_sniff_counter) 567 if (!should_sniff_counter)
568 should_sniff_counter = 568 should_sniff_counter =
569 UMASnifferHistogramGet("mime_sniffer.ShouldSniffMimeType2", 3); 569 UMASnifferHistogramGet("mime_sniffer.ShouldSniffMimeType2", 3);
570 // We are willing to sniff the mime type for HTTP, HTTPS, and FTP 570 // We are willing to sniff the mime type for HTTP, HTTPS, and FTP
eroman 2012/02/15 06:07:13 You should probably update this comment to match.
abarth-chromium 2012/02/15 08:43:20 Or just remove the comment. I'm sorry to have add
ericu 2012/02/15 22:48:09 I'll kill the comment and convert to the constants
ericu 2012/02/16 01:42:56 Actually, I don't think the constants I've been us
571 bool sniffable_scheme = url.is_empty() || 571 bool sniffable_scheme = url.is_empty() ||
572 url.SchemeIs("http") || 572 url.SchemeIs("http") ||
573 url.SchemeIs("https") || 573 url.SchemeIs("https") ||
574 url.SchemeIs("ftp") || 574 url.SchemeIs("ftp") ||
575 url.SchemeIsFile(); 575 url.SchemeIsFile() ||
576 url.SchemeIsFileSystem();
576 if (!sniffable_scheme) { 577 if (!sniffable_scheme) {
577 should_sniff_counter->Add(1); 578 should_sniff_counter->Add(1);
578 return false; 579 return false;
579 } 580 }
580 581
581 static const char* kSniffableTypes[] = { 582 static const char* kSniffableTypes[] = {
582 // Many web servers are misconfigured to send text/plain for many 583 // Many web servers are misconfigured to send text/plain for many
583 // different types of content. 584 // different types of content.
584 "text/plain", 585 "text/plain",
585 // We want to sniff application/octet-stream for 586 // We want to sniff application/octet-stream for
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // Now we look in our large table of magic numbers to see if we can find 681 // Now we look in our large table of magic numbers to see if we can find
681 // anything that matches the content. 682 // anything that matches the content.
682 if (SniffForMagicNumbers(content, content_size, 683 if (SniffForMagicNumbers(content, content_size,
683 &have_enough_content, result)) 684 &have_enough_content, result))
684 return true; // We've matched a magic number. No more content needed. 685 return true; // We've matched a magic number. No more content needed.
685 686
686 return have_enough_content; 687 return have_enough_content;
687 } 688 }
688 689
689 } // namespace net 690 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698