summaryrefslogtreecommitdiff
path: root/chromium/content/browser/mime_registry_impl.cc
blob: f46161e266c597828da30a1ab0a7f9e57b4baeea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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.

#include "content/browser/mime_registry_impl.h"

#include "base/files/file_path.h"
#include "base/memory/ptr_util.h"
#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
#include "net/base/mime_util.h"

namespace content {

MimeRegistryImpl::MimeRegistryImpl() = default;

MimeRegistryImpl::~MimeRegistryImpl() = default;

// static
void MimeRegistryImpl::Create(
    const service_manager::BindSourceInfo& source_info,
    blink::mojom::MimeRegistryRequest request) {
  DCHECK_CURRENTLY_ON(BrowserThread::FILE);
  mojo::MakeStrongBinding(base::MakeUnique<MimeRegistryImpl>(),
                          std::move(request));
}

void MimeRegistryImpl::GetMimeTypeFromExtension(
    const std::string& extension,
    const GetMimeTypeFromExtensionCallback& callback) {
  DCHECK_CURRENTLY_ON(BrowserThread::FILE);
  std::string mime_type;
  net::GetMimeTypeFromExtension(
      base::FilePath::FromUTF8Unsafe(extension).value(), &mime_type);
  callback.Run(mime_type);
}

}  // namespace content