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

Unified Diff: grit/format/html_inline.py

Issue 15981005: Normalize image/x-png mime type to the standard one (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/html_inline.py
===================================================================
--- grit/format/html_inline.py (revision 123)
+++ grit/format/html_inline.py (working copy)
@@ -47,6 +47,16 @@
+def FixupMimeType(mime_type):
+ """Helper function that normalizes platform differences in the mime type
+ returned by the Python's mimetypes.guess_type API.
+ """
+ mappings = {
+ 'image/x-png': 'image/png'
+ }
+ return mappings[mime_type] if mime_type in mappings else mime_type
+
+
def GetDistribution():
"""Helper function that gets the distribution we are building.
@@ -96,7 +106,7 @@
if names_only:
return ""
- mimetype = mimetypes.guess_type(filename)[0] or 'text/plain'
+ mimetype = FixupMimeType(mimetypes.guess_type(filename)[0]) or 'text/plain'
inline_data = base64.standard_b64encode(util.ReadFile(filepath, util.BINARY))
prefix = src_match.string[src_match.start():src_match.start('filename')]
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698