OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MockMimeRegistry_h |
| 6 #define MockMimeRegistry_h |
| 7 |
| 8 #include "mojo/public/cpp/bindings/binding.h" |
| 9 #include "net/base/mime_util.h" |
| 10 #include "public/platform/FilePathConversion.h" |
| 11 #include "public/platform/mime_registry.mojom-blink.h" |
| 12 |
| 13 namespace blink { |
| 14 |
| 15 // Used for unit tests. |
| 16 class MockMimeRegistry : public mojom::blink::MimeRegistry { |
| 17 public: |
| 18 MockMimeRegistry(mojom::blink::MimeRegistryRequest request) |
| 19 : m_binding(this, std::move(request)) {} |
| 20 ~MockMimeRegistry() {} |
| 21 |
| 22 void GetMimeTypeFromExtension( |
| 23 const String& ext, |
| 24 const GetMimeTypeFromExtensionCallback& callback) override { |
| 25 std::string mimeType; |
| 26 net::GetMimeTypeFromExtension(WebStringToFilePath(ext).value(), &mimeType); |
| 27 callback.Run(String::fromUTF8(mimeType.data(), mimeType.length())); |
| 28 } |
| 29 |
| 30 mojo::Binding<mojom::blink::MimeRegistry> m_binding; |
| 31 }; |
| 32 |
| 33 } // namespace blink |
| 34 |
| 35 #endif // MockMimeRegistry_h |
OLD | NEW |