blob: b6b853c51ff33d5c2602776da5e34c7959f05b9f [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"
fdorayba121422016-12-23 19:51:488#include "base/memory/ptr_util.h"
sammcc0fe2742016-06-06 01:37:259#include "content/public/browser/browser_thread.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
bena5c972c2017-05-04 01:38:4320void MimeRegistryImpl::Create(
bena5c972c2017-05-04 01:38:4321 blink::mojom::MimeRegistryRequest request) {
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(
yzshen6b5ad7f22016-11-22 21:38:2127 const std::string& extension,
tzikcf7bcd652017-06-15 04:19:3028 GetMimeTypeFromExtensionCallback callback) {
Sam McNally83733882017-07-13 00:59:0129 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
sammcc0fe2742016-06-06 01:37:2530 std::string mime_type;
yzshen6b5ad7f22016-11-22 21:38:2131 net::GetMimeTypeFromExtension(
sammc5a2900a2017-01-05 07:45:5432 base::FilePath::FromUTF8Unsafe(extension).value(), &mime_type);
tzikcf7bcd652017-06-15 04:19:3033 std::move(callback).Run(mime_type);
sammcc0fe2742016-06-06 01:37:2534}
35
36} // namespace content