Index: third_party/WebKit/Source/platform/network/mime/MockMimeRegistry.h |
diff --git a/third_party/WebKit/Source/platform/network/mime/MockMimeRegistry.h b/third_party/WebKit/Source/platform/network/mime/MockMimeRegistry.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d41ff932da7ec6e25e913ddb604347361a857163 |
--- /dev/null |
+++ b/third_party/WebKit/Source/platform/network/mime/MockMimeRegistry.h |
@@ -0,0 +1,35 @@ |
+// Copyright 2016 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 MockMimeRegistry_h |
+#define MockMimeRegistry_h |
+ |
+#include "mojo/public/cpp/bindings/binding.h" |
+#include "net/base/mime_util.h" |
+#include "public/platform/FilePathConversion.h" |
+#include "public/platform/mime_registry.mojom-blink.h" |
+ |
+namespace blink { |
+ |
+// Used for unit tests. |
+class MockMimeRegistry : public mojom::blink::MimeRegistry { |
+ public: |
+ MockMimeRegistry(mojom::blink::MimeRegistryRequest request) |
+ : m_binding(this, std::move(request)) {} |
+ ~MockMimeRegistry() {} |
+ |
+ void GetMimeTypeFromExtension( |
+ const String& ext, |
+ const GetMimeTypeFromExtensionCallback& callback) override { |
+ std::string mimeType; |
+ net::GetMimeTypeFromExtension(WebStringToFilePath(ext).value(), &mimeType); |
+ callback.Run(String::fromUTF8(mimeType.data(), mimeType.length())); |
+ } |
+ |
+ mojo::Binding<mojom::blink::MimeRegistry> m_binding; |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // MockMimeRegistry_h |