summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorerikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 21:38:57 +0000
committererikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 21:38:57 +0000
commit1c4446962c60801c4ab86b5592fc13653a3293ae (patch)
treeae8e50984ce07534462c48ddf74143ca717c04eb /webkit
parent2a006f2a0c71c671157686f66fa80168f6ca6624 (diff)
downloadchromium_src-1c4446962c60801c4ab86b5592fc13653a3293ae.zip
chromium_src-1c4446962c60801c4ab86b5592fc13653a3293ae.tar.gz
chromium_src-1c4446962c60801c4ab86b5592fc13653a3293ae.tar.bz2
* add MIME type functions to ChromiumBridge
* add resource protocol to ChromiumBridge Review URL: http://codereview.chromium.org/10836 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5297 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/chromium_bridge_impl.cc38
-rw-r--r--webkit/port/bindings/v8/v8_proxy.cpp5
-rw-r--r--webkit/port/platform/chromium/ChromiumBridge.h8
-rw-r--r--webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp27
4 files changed, 55 insertions, 23 deletions
diff --git a/webkit/glue/chromium_bridge_impl.cc b/webkit/glue/chromium_bridge_impl.cc
index b11ab8d..f27955ff 100644
--- a/webkit/glue/chromium_bridge_impl.cc
+++ b/webkit/glue/chromium_bridge_impl.cc
@@ -208,6 +208,44 @@ bool ChromiumBridge::layoutTestMode() {
return webkit_glue::IsLayoutTestMode();
}
+// MimeType -------------------------------------------------------------------
+
+String ChromiumBridge::mimeTypeFromExtension(const String& ext) {
+ if (ext.isEmpty())
+ return String();
+
+ std::string type;
+ webkit_glue::GetMimeTypeFromExtension(webkit_glue::StringToStdWString(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(webkit_glue::StringToStdWString(file_path),
+ &type);
+ return webkit_glue::StdStringToString(type);
+}
+
+String ChromiumBridge::preferredExtensionForMimeType(const String& mime_type) {
+ if (mime_type.isEmpty())
+ return String();
+
+ std::wstring stdext;
+ webkit_glue::GetPreferredExtensionForMimeType(
+ webkit_glue::StringToStdString(mime_type), &stdext);
+ return webkit_glue::StdWStringToString(stdext);
+}
+
+// Protocol -------------------------------------------------------------------
+
+String ChromiumBridge::uiResourceProtocol() {
+ return webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol());
+}
+
// Screen ---------------------------------------------------------------------
int ChromiumBridge::screenDepth(Widget* widget) {
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp
index 5ab4bad..c770e5b 100644
--- a/webkit/port/bindings/v8/v8_proxy.cpp
+++ b/webkit/port/bindings/v8/v8_proxy.cpp
@@ -43,6 +43,7 @@
#include "RefCounted.h" // for Peerable
+#include "ChromiumBridge.h"
#include "DOMCoreException.h"
#include "EventException.h"
#include "ExceptionCode.h"
@@ -1550,7 +1551,7 @@ bool V8Proxy::isEnabled()
if (origin->protocol() == "http" || origin->protocol() == "https")
return false; // Web site
- if (origin->protocol() == webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol()))
+ if (origin->protocol() == ChromiumBridge::uiResourceProtocol())
return true; // Embedder's scripts are ok to run
// If the scheme is ftp: or file:, an empty file name indicates a directory
@@ -1674,7 +1675,7 @@ bool V8Proxy::CanAccessPrivate(DOMWindow* target_window)
const SecurityOrigin* active_security_origin = origin_window->securityOrigin();
const SecurityOrigin* target_security_origin = target_window->securityOrigin();
- String ui_resource_protocol = webkit_glue::StdStringToString(webkit_glue::GetUIResourceProtocol());
+ String ui_resource_protocol = ChromiumBridge::uiResourceProtocol();
if (active_security_origin->protocol() == ui_resource_protocol) {
KURL inspector_url = webkit_glue::GURLToKURL(webkit_glue::GetInspectorURL());
ASSERT(inspector_url.protocol() == ui_resource_protocol);
diff --git a/webkit/port/platform/chromium/ChromiumBridge.h b/webkit/port/platform/chromium/ChromiumBridge.h
index 4fe339d..0f67a36 100644
--- a/webkit/port/platform/chromium/ChromiumBridge.h
+++ b/webkit/port/platform/chromium/ChromiumBridge.h
@@ -70,6 +70,14 @@ namespace WebCore {
// LayoutTestMode -----------------------------------------------------
static bool layoutTestMode();
+ // MimeType -----------------------------------------------------------
+ static String mimeTypeFromExtension(const String& ext);
+ static String mimeTypeFromFile(const String& file_path);
+ static String preferredExtensionForMimeType(const String& mime_type);
+
+ // Protocol -----------------------------------------------------------
+ static String uiResourceProtocol();
+
// Screen -------------------------------------------------------------
static int screenDepth(Widget*);
static int screenDepthPerComponent(Widget*);
diff --git a/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp b/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp
index a7f2d6c..d72a47d 100644
--- a/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp
+++ b/webkit/port/platform/chromium/MimeTypeRegistryChromium.cpp
@@ -28,11 +28,9 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "config.h"
+#include "ChromiumBridge.h"
#include "MIMETypeRegistry.h"
-#include "webkit/glue/glue_util.h"
-#include "webkit/glue/webkit_glue.h"
-
namespace WebCore
{
@@ -60,29 +58,16 @@ String MIMETypeRegistry::getPreferredExtensionForMIMEType(const String& type)
// TODO(darin): Is this really necessary??
String mimeType = type.substring(0, static_cast<unsigned>(type.find(';')));
- if (mimeType.isEmpty())
- return String();
-
- std::wstring ext;
- webkit_glue::GetPreferredExtensionForMimeType(
- std::string(type.characters(), type.characters() + type.length()),
- &ext);
- if (!ext.empty() && ext[0] == L'.')
- ext = ext.substr(1);
+ String ext = ChromiumBridge::preferredExtensionForMimeType(type);
+ if (!ext.isEmpty() && ext[0] == L'.')
+ ext = ext.substring(1);
- return webkit_glue::StdWStringToString(ext);
+ return ext;
}
String MIMETypeRegistry::getMIMETypeForExtension(const String &ext)
{
- if (ext.isEmpty())
- return String();
-
- std::string mime_type;
- webkit_glue::GetMimeTypeFromExtension(
- webkit_glue::StringToStdWString(ext), &mime_type);
-
- return String(mime_type.data(), mime_type.size());
+ return ChromiumBridge::mimeTypeFromExtension(ext);
}
}