blob: 156551d7e6f74ee559302a95d6fb1a6c3609de85 [file] [log] [blame]
sammcc0fe2742016-06-06 01:37:251// 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#include "content/browser/mime_registry_impl.h"
6
7#include "base/files/file_path.h"
8#include "content/public/browser/browser_thread.h"
9#include "mojo/common/common_type_converters.h"
rockot8e66a08d2016-09-13 00:48:2110#include "mojo/public/cpp/bindings/strong_binding.h"
sammcc0fe2742016-06-06 01:37:2511#include "net/base/mime_util.h"
12
13namespace content {
14
rockot8e66a08d2016-09-13 00:48:2115MimeRegistryImpl::MimeRegistryImpl() = default;
16
17MimeRegistryImpl::~MimeRegistryImpl() = default;
18
sammcc0fe2742016-06-06 01:37:2519// static
20void MimeRegistryImpl::Create(blink::mojom::MimeRegistryRequest request) {
21 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
rockot8e66a08d2016-09-13 00:48:2122 mojo::MakeStrongBinding(base::MakeUnique<MimeRegistryImpl>(),
23 std::move(request));
sammcc0fe2742016-06-06 01:37:2524}
25
sammcc0fe2742016-06-06 01:37:2526void MimeRegistryImpl::GetMimeTypeFromExtension(
27 const mojo::String& extension,
28 const GetMimeTypeFromExtensionCallback& callback) {
29 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
30 std::string mime_type;
31 net::GetMimeTypeFromExtension(extension.To<base::FilePath::StringType>(),
32 &mime_type);
33 callback.Run(mime_type);
34}
35
36} // namespace content