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

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

Issue 7538029: Upstream certificate and mime Android implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DEPS Created 9 years, 4 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "net/base/platform_mime_util.h" 5 #include "net/base/platform_mime_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #if defined(OS_ANDROID)
10 #include "net/android/network_library.h"
11 #else
9 #include "base/mime_util.h" 12 #include "base/mime_util.h"
13 #endif
wtc 2011/08/09 18:47:22 This should be done as follows: #include "base/mi
michaelbai 2011/08/11 16:10:18 Done.
10 14
11 namespace net { 15 namespace net {
12 16
17 #if defined(OS_ANDROID)
18
19 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
20 const FilePath::StringType& ext, std::string* result) const {
21 return android::GetMimeTypeFromExtension(ext, result);
22 }
23
24 #else
25
13 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension( 26 bool PlatformMimeUtil::GetPlatformMimeTypeFromExtension(
14 const FilePath::StringType& ext, std::string* result) const { 27 const FilePath::StringType& ext, std::string* result) const {
15 // TODO(thestig) This is a temporary hack until we can fix this 28 // TODO(thestig) This is a temporary hack until we can fix this
16 // properly in test shell / webkit. 29 // properly in test shell / webkit.
17 // We have to play dumb and not return application/x-perl here 30 // We have to play dumb and not return application/x-perl here
18 // to make the reload-subframe-object layout test happy. 31 // to make the reload-subframe-object layout test happy.
19 if (ext == "pl") 32 if (ext == "pl")
20 return false; 33 return false;
21 34
22 FilePath dummy_path("foo." + ext); 35 FilePath dummy_path("foo." + ext);
23 std::string out = mime_util::GetFileMimeType(dummy_path); 36 std::string out = mime_util::GetFileMimeType(dummy_path);
24 37
25 // GetFileMimeType likes to return application/octet-stream 38 // GetFileMimeType likes to return application/octet-stream
26 // for everything it doesn't know - ignore that. 39 // for everything it doesn't know - ignore that.
27 if (out == "application/octet-stream" || out.empty()) 40 if (out == "application/octet-stream" || out.empty())
28 return false; 41 return false;
29 42
30 // GetFileMimeType returns image/x-ico because that's what's in the XDG 43 // GetFileMimeType returns image/x-ico because that's what's in the XDG
31 // mime database. That database is the merger of the Gnome and KDE mime 44 // mime database. That database is the merger of the Gnome and KDE mime
32 // databases. Apparently someone working on KDE in 2001 decided .ico 45 // databases. Apparently someone working on KDE in 2001 decided .ico
33 // resolves to image/x-ico, whereas the rest of the world uses image/x-icon. 46 // resolves to image/x-ico, whereas the rest of the world uses image/x-icon.
34 // FWIW, image/vnd.microsoft.icon is the official IANA assignment. 47 // FWIW, image/vnd.microsoft.icon is the official IANA assignment.
35 if (out == "image/x-ico") 48 if (out == "image/x-ico")
36 out = "image/x-icon"; 49 out = "image/x-icon";
37 50
38 *result = out; 51 *result = out;
39 return true; 52 return true;
40 } 53 }
41 54
55 #endif
wtc 2011/08/09 18:47:22 Add a // defined(OS_ANDROID) comment.
michaelbai 2011/08/11 16:10:18 Done.
56
42 struct MimeToExt { 57 struct MimeToExt {
43 const char* mime_type; 58 const char* mime_type;
44 const char* ext; 59 const char* ext;
45 }; 60 };
46 61
47 const struct MimeToExt mime_type_ext_map[] = { 62 const struct MimeToExt mime_type_ext_map[] = {
48 {"application/pdf", "pdf"}, 63 {"application/pdf", "pdf"},
49 {"application/x-tar", "tar"}, 64 {"application/x-tar", "tar"},
50 {"audio/mpeg", "mp3"}, 65 {"audio/mpeg", "mp3"},
51 {"image/gif", "gif"}, 66 {"image/gif", "gif"},
(...skipping 25 matching lines...) Expand all
77 // 92 //
78 // If we wanted to do this properly, we would read the mime.cache file which 93 // If we wanted to do this properly, we would read the mime.cache file which
79 // has a section where they assign a glob (*.gif) to a mimetype 94 // has a section where they assign a glob (*.gif) to a mimetype
80 // (image/gif). We look up the "heaviest" glob for a certain mime type and 95 // (image/gif). We look up the "heaviest" glob for a certain mime type and
81 // then then try to chop off "*.". 96 // then then try to chop off "*.".
82 97
83 return false; 98 return false;
84 } 99 }
85 100
86 } // namespace net 101 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698