| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 import os | 5 import os |
| 6 | 6 |
| 7 # W0232: 15,0:ContentHelper: Class has no __init__ method | 7 # W0232: 15,0:ContentHelper: Class has no __init__ method |
| 8 # pylint: disable=W0232 | 8 # pylint: disable=W0232 |
| 9 class ContentHelper: | 9 class ContentHelper: |
| 10 content_extensions = { | 10 content_extensions = { |
| 11 '.html' : 'text/html', | 11 '.html' : 'text/html', |
| 12 '.jpg' : 'image/jpeg', | 12 '.jpg' : 'image/jpeg', |
| 13 '.gif' : 'image/gif', | 13 '.gif' : 'image/gif', |
| 14 '.png' : 'image/png', | 14 '.png' : 'image/png', |
| 15 '.js' : 'application/x-javascript', | 15 '.js' : 'application/x-javascript', |
| 16 '.css' : 'text/css', | 16 '.css' : 'text/css', |
| 17 '.manifest': 'text/cache-manifest' } | 17 '.manifest': 'text/cache-manifest', |
| 18 '.zip' : 'application/zip' } |
| 18 | 19 |
| 19 @staticmethod | 20 @staticmethod |
| 20 def content_type_from_path(path): | 21 def content_type_from_path(path): |
| 21 _, extension = os.path.splitext(path) | 22 _, extension = os.path.splitext(path) |
| 22 return ContentHelper.content_extensions.get(extension, 'text/plain') | 23 return ContentHelper.content_extensions.get(extension, 'text/plain') |
| 23 | 24 |
| 24 def from_path(path): | 25 def from_path(path): |
| 25 return ContentHelper.content_type_from_path(path) | 26 return ContentHelper.content_type_from_path(path) |
| OLD | NEW |