Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: content/browser/mime_registry_impl.cc

Issue 2024363002: Convert MimeRegistry to use mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@message-mojom-magic
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/mime_registry_impl.h ('k') | content/browser/mime_registry_message_filter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/mime_registry_impl.cc
diff --git a/content/browser/mime_registry_impl.cc b/content/browser/mime_registry_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aa3562535cf42816098225bee395d73c0654ceb1
--- /dev/null
+++ b/content/browser/mime_registry_impl.cc
@@ -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.
+
+#include "content/browser/mime_registry_impl.h"
+
+#include "base/files/file_path.h"
+#include "content/public/browser/browser_thread.h"
+#include "mojo/common/common_type_converters.h"
+#include "net/base/mime_util.h"
+
+namespace content {
+
+// static
+void MimeRegistryImpl::Create(blink::mojom::MimeRegistryRequest request) {
+ DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ new MimeRegistryImpl(std::move(request));
+}
+
+MimeRegistryImpl::MimeRegistryImpl(blink::mojom::MimeRegistryRequest request)
+ : binding_(this, std::move(request)) {}
+
+MimeRegistryImpl::~MimeRegistryImpl() = default;
+
+void MimeRegistryImpl::GetMimeTypeFromExtension(
+ const mojo::String& extension,
+ const GetMimeTypeFromExtensionCallback& callback) {
+ DCHECK_CURRENTLY_ON(BrowserThread::FILE);
+ std::string mime_type;
+ net::GetMimeTypeFromExtension(extension.To<base::FilePath::StringType>(),
+ &mime_type);
+ callback.Run(mime_type);
+}
+
+} // namespace content
« no previous file with comments | « content/browser/mime_registry_impl.h ('k') | content/browser/mime_registry_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698