summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 23:37:55 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-26 23:37:55 +0000
commit8d86fce009d9dc39300a5ec9b0559ce17ff0e44e (patch)
tree74d2f7779a00c20f7ca9ef5e88852b01f4f4619d /webkit/glue
parent5c935c135c544163d9b3923fd9e6d612cedf05c1 (diff)
downloadchromium_src-8d86fce009d9dc39300a5ec9b0559ce17ff0e44e.zip
chromium_src-8d86fce009d9dc39300a5ec9b0559ce17ff0e44e.tar.gz
chromium_src-8d86fce009d9dc39300a5ec9b0559ce17ff0e44e.tar.bz2
Chrome side to implement WebMimeRegistry.
R=dglazkov Review URL: http://codereview.chromium.org/27222 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10532 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/SConscript3
-rw-r--r--webkit/glue/chromium_bridge_impl.cc51
-rw-r--r--webkit/glue/glue.vcproj20
-rw-r--r--webkit/glue/glue_util.cc19
-rw-r--r--webkit/glue/glue_util.h7
-rw-r--r--webkit/glue/plugins/plugin_stream.cc4
-rw-r--r--webkit/glue/simple_webmimeregistry_impl.cc61
-rw-r--r--webkit/glue/simple_webmimeregistry_impl.h26
-rw-r--r--webkit/glue/webkit_glue.h15
-rw-r--r--webkit/glue/webkitclient_impl.cc (renamed from webkit/glue/webkit_client_impl.cc)6
-rw-r--r--webkit/glue/webkitclient_impl.h (renamed from webkit/glue/webkit_client_impl.h)3
11 files changed, 134 insertions, 81 deletions
diff --git a/webkit/glue/SConscript b/webkit/glue/SConscript
index 375b8de..555f657 100644
--- a/webkit/glue/SConscript
+++ b/webkit/glue/SConscript
@@ -78,6 +78,7 @@ input_files = [
'resource_handle_impl.cc',
'resource_loader_bridge.cc',
'searchable_form_data.cc',
+ 'simple_webmimeregistry_impl.cc',
'stacking_order_iterator.cc',
'webclipboard_impl.cc',
'webcursor.cc',
@@ -87,7 +88,7 @@ input_files = [
'webframe_impl.cc',
'webframeloaderclient_impl.cc',
'webhistoryitem_impl.cc',
- 'webkit_client_impl.cc',
+ 'webkitclient_impl.cc',
'webkit_glue.cc',
'webmediaplayer_impl.cc',
'webplugin_delegate.cc',
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
index aeb5f40..4fb80c4 100644
--- a/webkit/glue/chromium_bridge_impl.cc
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -34,7 +34,6 @@
#include "base/trace_event.h"
#include "build/build_config.h"
#include "googleurl/src/url_util.h"
-#include "net/base/mime_util.h"
#include "skia/ext/skia_utils_win.h"
#if USE(V8)
#include <v8.h>
@@ -142,56 +141,6 @@ bool ChromiumBridge::layoutTestMode() {
return webkit_glue::IsLayoutTestMode();
}
-// MimeType -------------------------------------------------------------------
-
-bool ChromiumBridge::isSupportedImageMIMEType(const char* mime_type) {
- return net::IsSupportedImageMimeType(mime_type);
-}
-
-bool ChromiumBridge::isSupportedJavascriptMIMEType(const char* mime_type) {
- return net::IsSupportedJavascriptMimeType(mime_type);
-}
-
-bool ChromiumBridge::isSupportedNonImageMIMEType(const char* mime_type) {
- return net::IsSupportedNonImageMimeType(mime_type);
-}
-
-bool ChromiumBridge::matchesMIMEType(const String& pattern,
- const String& type) {
- return net::MatchesMimeType(webkit_glue::StringToStdString(pattern),
- webkit_glue::StringToStdString(type));
-}
-
-String ChromiumBridge::mimeTypeForExtension(const String& ext) {
- if (ext.isEmpty())
- return String();
-
- std::string type;
- webkit_glue::GetMimeTypeFromExtension(
- webkit_glue::StringToFilePathString(ext), &type);
- return webkit_glue::StdStringToString(type);
-}
-
-String ChromiumBridge::mimeTypeFromFile(const String& file_path) {
- if (file_path.isEmpty())
- return String();
-
- std::string type;
- webkit_glue::GetMimeTypeFromFile(
- FilePath(webkit_glue::StringToFilePathString(file_path)), &type);
- return webkit_glue::StdStringToString(type);
-}
-
-String ChromiumBridge::preferredExtensionForMIMEType(const String& mime_type) {
- if (mime_type.isEmpty())
- return String();
-
- FilePath::StringType stdext;
- webkit_glue::GetPreferredExtensionForMimeType(
- webkit_glue::StringToStdString(mime_type), &stdext);
- return webkit_glue::FilePathStringToString(stdext);
-}
-
// Plugin ---------------------------------------------------------------------
bool ChromiumBridge::plugins(bool refresh, Vector<PluginInfo*>* results) {
diff --git a/webkit/glue/glue.vcproj b/webkit/glue/glue.vcproj
index 6dae503..bb0d3e3 100644
--- a/webkit/glue/glue.vcproj
+++ b/webkit/glue/glue.vcproj
@@ -525,6 +525,14 @@
>
</File>
<File
+ RelativePath=".\simple_webmimeregistry_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\simple_webmimeregistry_impl.h"
+ >
+ </File>
+ <File
RelativePath=".\stacking_order_iterator.cc"
>
</File>
@@ -609,27 +617,27 @@
>
</File>
<File
- RelativePath=".\webinputevent_win.cc"
+ RelativePath=".\webinputevent_utils.cc"
>
</File>
<File
- RelativePath=".\webkit_client_impl.cc"
+ RelativePath=".\webkit_glue.cc"
>
</File>
<File
- RelativePath=".\webkit_client_impl.h"
+ RelativePath=".\webkit_glue.h"
>
</File>
<File
- RelativePath=".\webkit_glue.cc"
+ RelativePath=".\webkit_glue_win.cc"
>
</File>
<File
- RelativePath=".\webkit_glue.h"
+ RelativePath=".\webkitclient_impl.cc"
>
</File>
<File
- RelativePath=".\webkit_glue_win.cc"
+ RelativePath=".\webkitclient_impl.h"
>
</File>
<File
diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc
index 113d413..359eb40 100644
--- a/webkit/glue/glue_util.cc
+++ b/webkit/glue/glue_util.cc
@@ -16,8 +16,9 @@ MSVC_PUSH_WARNING_LEVEL(0);
#include "KURL.h"
MSVC_POP_WARNING();
-#undef LOG
+#include "WebString.h"
+#undef LOG
#include "base/compiler_specific.h"
#include "base/gfx/rect.h"
#include "base/string_piece.h"
@@ -98,6 +99,22 @@ WebCore::String FilePathStringToString(const FilePath::StringType& str) {
#endif
}
+FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str) {
+#if defined(OS_POSIX)
+ return base::SysWideToNativeMB(UTF16ToWide(str));
+#elif defined(OS_WIN)
+ return UTF16ToWide(str);
+#endif
+}
+
+WebKit::WebString FilePathStringToWebString(const FilePath::StringType& str) {
+#if defined(OS_POSIX)
+ return WideToUTF16(base::SysNativeMBToWide(str));
+#elif defined(OS_WIN)
+ return WideToUTF16(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 576ec34..adbaffc 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -17,6 +17,10 @@ class KURL;
class String;
}
+namespace WebKit {
+class WebString;
+}
+
namespace gfx {
class Rect;
}
@@ -46,6 +50,9 @@ WebCore::String StdStringToString(const std::string& str);
FilePath::StringType StringToFilePathString(const WebCore::String& str);
WebCore::String FilePathStringToString(const FilePath::StringType& str);
+FilePath::StringType WebStringToFilePathString(const WebKit::WebString& str);
+WebKit::WebString FilePathStringToWebString(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 af7fbe9..e66182b 100644
--- a/webkit/glue/plugins/plugin_stream.cc
+++ b/webkit/glue/plugins/plugin_stream.cc
@@ -12,8 +12,8 @@
#include "base/string_util.h"
#include "base/message_loop.h"
+#include "net/base/mime_util.h"
#include "webkit/glue/plugins/plugin_instance.h"
-#include "webkit/glue/webkit_glue.h"
#include "googleurl/src/gurl.h"
namespace NPAPI {
@@ -57,7 +57,7 @@ bool PluginStream::Open(const std::string &mime_type,
#elif defined(OS_POSIX)
FilePath path(gurl.path());
#endif
- if (webkit_glue::GetMimeTypeFromFile(path, &temp_mime_type))
+ if (net::GetMimeTypeFromFile(path, &temp_mime_type))
char_mime_type = temp_mime_type.c_str();
}
diff --git a/webkit/glue/simple_webmimeregistry_impl.cc b/webkit/glue/simple_webmimeregistry_impl.cc
new file mode 100644
index 0000000..a662958
--- /dev/null
+++ b/webkit/glue/simple_webmimeregistry_impl.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+// TODO(darin): This include should not be necessary, but for some reason the
+// Mac build requires it.
+#include "config.h"
+
+#include "webkit/glue/simple_webmimeregistry_impl.h"
+
+#include "WebString.h"
+
+#include "base/string_util.h"
+#include "base/sys_string_conversions.h"
+#include "net/base/mime_util.h"
+#include "webkit/glue/glue_util.h"
+
+using WebKit::WebString;
+
+namespace webkit_glue {
+
+bool SimpleWebMimeRegistryImpl::supportsImageMIMEType(
+ const WebString& mime_type) {
+ return net::IsSupportedImageMimeType(UTF16ToASCII(mime_type).c_str());
+}
+
+bool SimpleWebMimeRegistryImpl::supportsJavaScriptMIMEType(
+ const WebString& mime_type) {
+ return net::IsSupportedJavascriptMimeType(UTF16ToASCII(mime_type).c_str());
+}
+
+bool SimpleWebMimeRegistryImpl::supportsNonImageMIMEType(
+ const WebString& mime_type) {
+ return net::IsSupportedNonImageMimeType(UTF16ToASCII(mime_type).c_str());
+}
+
+WebString SimpleWebMimeRegistryImpl::mimeTypeForExtension(
+ const WebString& file_extension) {
+ std::string mime_type;
+ net::GetMimeTypeFromExtension(
+ WebStringToFilePathString(file_extension), &mime_type);
+ return ASCIIToUTF16(mime_type);
+}
+
+WebString SimpleWebMimeRegistryImpl::mimeTypeFromFile(
+ const WebString& file_path) {
+ std::string mime_type;
+ net::GetMimeTypeFromFile(
+ FilePath(WebStringToFilePathString(file_path)), &mime_type);
+ return ASCIIToUTF16(mime_type);
+}
+
+WebString SimpleWebMimeRegistryImpl::preferredExtensionForMIMEType(
+ const WebString& mime_type) {
+ FilePath::StringType file_extension;
+ net::GetPreferredExtensionForMimeType(UTF16ToASCII(mime_type),
+ &file_extension);
+ return FilePathStringToWebString(file_extension);
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/simple_webmimeregistry_impl.h b/webkit/glue/simple_webmimeregistry_impl.h
new file mode 100644
index 0000000..778dee0
--- /dev/null
+++ b/webkit/glue/simple_webmimeregistry_impl.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
+// source code is governed by a BSD-style license that can be found in the
+// LICENSE file.
+
+#ifndef WEBMIMEREGISTRY_IMPL_H_
+#define WEBMIMEREGISTRY_IMPL_H_
+
+#include "WebMimeRegistry.h"
+
+namespace webkit_glue {
+
+class SimpleWebMimeRegistryImpl : public WebKit::WebMimeRegistry {
+ public:
+ // WebMimeRegistry methods:
+ virtual bool supportsImageMIMEType(const WebKit::WebString&);
+ virtual bool supportsJavaScriptMIMEType(const WebKit::WebString&);
+ virtual bool supportsNonImageMIMEType(const WebKit::WebString&);
+ virtual WebKit::WebString mimeTypeForExtension(const WebKit::WebString&);
+ virtual WebKit::WebString mimeTypeFromFile(const WebKit::WebString&);
+ virtual WebKit::WebString preferredExtensionForMIMEType(
+ const WebKit::WebString&);
+};
+
+} // namespace webkit_glue
+
+#endif // WEBMIMEREGISTRY_IMPL_H_
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index aca3250..579ca5d 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -162,21 +162,6 @@ void PrecacheUrl(const char16* url, int url_length);
// This function is called to add a line to the application's log file.
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 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 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,
- 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
// not to allow this cookie setting. NOTE: the cookie string is a standard
diff --git a/webkit/glue/webkit_client_impl.cc b/webkit/glue/webkitclient_impl.cc
index 2389a71..a243716 100644
--- a/webkit/glue/webkit_client_impl.cc
+++ b/webkit/glue/webkitclient_impl.cc
@@ -6,14 +6,12 @@
// Mac build requires it.
#include "config.h"
-#include "webkit/glue/webkit_client_impl.h"
+#include "webkit/glue/webkitclient_impl.h"
namespace webkit_glue {
WebKit::WebClipboard* WebKitClientImpl::clipboard() {
- if (!clipboard_.get())
- clipboard_.reset(new WebClipboardImpl());
- return clipboard_.get();
+ return &clipboard_;
}
} // namespace webkit_glue
diff --git a/webkit/glue/webkit_client_impl.h b/webkit/glue/webkitclient_impl.h
index e2ff98a..481a5fe 100644
--- a/webkit/glue/webkit_client_impl.h
+++ b/webkit/glue/webkitclient_impl.h
@@ -16,9 +16,10 @@ class WebKitClientImpl : public WebKit::WebKitClient {
public:
// WebKitClient methods:
virtual WebKit::WebClipboard* clipboard();
+ virtual WebKit::WebMimeRegistry* mimeRegistry() = 0;
private:
- scoped_ptr<WebClipboardImpl> clipboard_;
+ WebClipboardImpl clipboard_;
};
} // namespace webkit_glue