summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-14 01:20:41 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-14 01:20:41 +0000
commitbae0ea1f95c5c3a02761d942c0802ec877c1a106 (patch)
tree456d3b2eb7cc4fc497870385223c88312db8a914 /webkit
parent8a5deb2ef0a4cc84b06a3466b32e94375110106c (diff)
downloadchromium_src-bae0ea1f95c5c3a02761d942c0802ec877c1a106.zip
chromium_src-bae0ea1f95c5c3a02761d942c0802ec877c1a106.tar.gz
chromium_src-bae0ea1f95c5c3a02761d942c0802ec877c1a106.tar.bz2
Change mime type utils to operate on platform-specific string types for filenames/file extensions.
Review URL: http://codereview.chromium.org/21327 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9809 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/chromium_bridge_impl.cc14
-rw-r--r--webkit/glue/glue_util.cc18
-rw-r--r--webkit/glue/glue_util.h4
-rw-r--r--webkit/glue/plugins/plugin_stream.cc7
-rw-r--r--webkit/glue/webkit_glue.h7
-rwxr-xr-xwebkit/tools/test_shell/test_shell.cc7
6 files changed, 43 insertions, 14 deletions
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
index 771c54b..fe2582e 100644
--- a/webkit/glue/chromium_bridge_impl.cc
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -277,7 +277,7 @@ bool ChromiumBridge::isSupportedNonImageMIMEType(const char* mime_type) {
bool ChromiumBridge::matchesMIMEType(const String& pattern,
const String& type) {
- return net::MatchesMimeType(webkit_glue::StringToStdString(pattern),
+ return net::MatchesMimeType(webkit_glue::StringToStdString(pattern),
webkit_glue::StringToStdString(type));
}
@@ -286,8 +286,8 @@ String ChromiumBridge::mimeTypeForExtension(const String& ext) {
return String();
std::string type;
- webkit_glue::GetMimeTypeFromExtension(webkit_glue::StringToStdWString(ext),
- &type);
+ webkit_glue::GetMimeTypeFromExtension(
+ webkit_glue::StringToFilePathString(ext), &type);
return webkit_glue::StdStringToString(type);
}
@@ -296,8 +296,8 @@ String ChromiumBridge::mimeTypeFromFile(const String& file_path) {
return String();
std::string type;
- webkit_glue::GetMimeTypeFromFile(webkit_glue::StringToStdWString(file_path),
- &type);
+ webkit_glue::GetMimeTypeFromFile(
+ FilePath(webkit_glue::StringToFilePathString(file_path)), &type);
return webkit_glue::StdStringToString(type);
}
@@ -305,10 +305,10 @@ String ChromiumBridge::preferredExtensionForMIMEType(const String& mime_type) {
if (mime_type.isEmpty())
return String();
- std::wstring stdext;
+ FilePath::StringType stdext;
webkit_glue::GetPreferredExtensionForMimeType(
webkit_glue::StringToStdString(mime_type), &stdext);
- return webkit_glue::StdWStringToString(stdext);
+ return webkit_glue::FilePathStringToString(stdext);
}
// Plugin ---------------------------------------------------------------------
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc
index 3759b2b..52ace87 100644
--- a/webkit/glue/glue_util.cc
+++ b/webkit/glue/glue_util.cc
@@ -8,7 +8,9 @@
#include "webkit/glue/glue_util.h"
#include "base/compiler_specific.h"
#include "base/gfx/rect.h"
+#include "base/string_part.h"
#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
MSVC_PUSH_WARNING_LEVEL(0);
#undef LOG
@@ -75,6 +77,22 @@ WebCore::String StdStringToString(const std::string& str) {
static_cast<unsigned>(str.length()));
}
+FilePath::StringType StringToFilePathString(const WebCore::String& str) {
+#if defined(OS_WIN)
+ return StringToStdWString(str);
+#elif defined(OS_POSIX)
+ return base::SysWideToNativeMB(StringToStdWString(str));
+#endif
+}
+
+WebCore::String FilePathStringToString(const FilePath::StringType& str) {
+#if defined(OS_WIN)
+ return StdWStringToString(str);
+#elif defined(OS_POSIX)
+ return StdWStringToString(base::SysNativeMBToWide(str));
+#endif
+}
+
// URL conversions -------------------------------------------------------------
GURL KURLToGURL(const WebCore::KURL& url) {
diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h
index b9ebf41..0bb7106 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -7,6 +7,7 @@
#include <string>
+#include "base/file_path.h"
#include "base/string16.h"
#include "googleurl/src/gurl.h"
@@ -43,6 +44,9 @@ WebCore::String String16ToString(const string16& str);
std::string StringToStdString(const WebCore::String& str);
WebCore::String StdStringToString(const std::string& str);
+FilePath::StringType StringToFilePathString(const WebCore::String& str);
+WebCore::String FilePathStringToString(const FilePath::StringType& str);
+
GURL KURLToGURL(const WebCore::KURL& url);
WebCore::KURL GURLToKURL(const GURL& url);
GURL StringToGURL(const WebCore::String& spec);
diff --git a/webkit/glue/plugins/plugin_stream.cc b/webkit/glue/plugins/plugin_stream.cc
index c5893f2..af7fbe9 100644
--- a/webkit/glue/plugins/plugin_stream.cc
+++ b/webkit/glue/plugins/plugin_stream.cc
@@ -51,7 +51,12 @@ bool PluginStream::Open(const std::string &mime_type,
char_mime_type = mime_type.c_str();
} else {
GURL gurl(stream_.url);
- std::wstring path(UTF8ToWide(gurl.path()));
+
+#if defined(OS_WIN)
+ FilePath path(UTF8ToWide(gurl.path()));
+#elif defined(OS_POSIX)
+ FilePath path(gurl.path());
+#endif
if (webkit_glue::GetMimeTypeFromFile(path, &temp_mime_type))
char_mime_type = temp_mime_type.c_str();
}
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index 44dc8a4..aca3250 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -164,17 +164,18 @@ void AppendToLog(const char* filename, int line, const char* message);
// Get the mime type (if any) that is associated with the given file extension.
// Returns true if a corresponding mime type exists.
-bool GetMimeTypeFromExtension(const std::wstring& ext, std::string* mime_type);
+bool GetMimeTypeFromExtension(const FilePath::StringType& ext,
+ std::string* mime_type);
// Get the mime type (if any) that is associated with the given file.
// Returns true if a corresponding mime type exists.
-bool GetMimeTypeFromFile(const std::wstring& file_path, std::string* mime_type);
+bool GetMimeTypeFromFile(const FilePath& file_path, std::string* mime_type);
// Get the preferred extension (if any) associated with the given mime type.
// Returns true if a corresponding file extension exists. The extension does
// not include a prefixed dot, ex "html".
bool GetPreferredExtensionForMimeType(const std::string& mime_type,
- std::wstring* ext);
+ FilePath::StringType* ext);
// Sets a cookie string for the given URL. The policy_url argument indicates
// the URL of the topmost frame, which may be useful for determining whether or
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index aa9dca7..f40dcbd 100755
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -559,17 +559,18 @@ void AppendToLog(const char* file, int line, const char* msg) {
logging::LogMessage(file, line).stream() << msg;
}
-bool GetMimeTypeFromExtension(const std::wstring &ext, std::string *mime_type) {
+bool GetMimeTypeFromExtension(const FilePath::StringType& ext,
+ std::string *mime_type) {
return net::GetMimeTypeFromExtension(ext, mime_type);
}
-bool GetMimeTypeFromFile(const std::wstring &file_path,
+bool GetMimeTypeFromFile(const FilePath& file_path,
std::string *mime_type) {
return net::GetMimeTypeFromFile(file_path, mime_type);
}
bool GetPreferredExtensionForMimeType(const std::string& mime_type,
- std::wstring* ext) {
+ FilePath::StringType* ext) {
return net::GetPreferredExtensionForMimeType(mime_type, ext);
}