Commit 541bea6d authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Add a Mojo IPC service to connect to FontUniqueNameLookup implementation

Add a Mojo service to RenderProcessHost for renderers being able to
connect to the FontUniqueNameLookup implementation on Android when the
feature is enabled. Preparation for Blink performing font-face { src:
local() } lookups correctly.

I have not found a good way to test this service on its own. Instead, I
aim to test font lookup through a browsertest once the font lookup is
hooked up in Blink. This would test the chain end to end. The
FontUniqueNameLookup implementation itself is tested extensively with
unit tests.

Bug: 868366
Change-Id: Ie4f4cca88d6e98efdecfee04221cdb11d5b3c302
Reviewed-on: https://chromium-review.googlesource.com/1152970Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarKen Buchanan <kenrb@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580122}
parent a9438c2a
......@@ -2180,6 +2180,8 @@ jumbo_source_set("browser") {
"font_unique_name_lookup/font_table_matcher.h",
"font_unique_name_lookup/font_unique_name_lookup.cc",
"font_unique_name_lookup/font_unique_name_lookup.h",
"font_unique_name_lookup/font_unique_name_lookup_service.cc",
"font_unique_name_lookup/font_unique_name_lookup_service.h",
"font_unique_name_lookup/icu_fold_case_util.cc",
"font_unique_name_lookup/icu_fold_case_util.h",
"frame_host/render_frame_host_android.cc",
......
......@@ -101,9 +101,10 @@ include_rules = [
"+third_party/blink/public/platform/web_touch_event.h",
"+third_party/blink/public/platform/web_text_input_type.h",
"+third_party/blink/public/platform/mac/web_scrollbar_theme.h",
"+third_party/blink/public/platform/modules/locks/lock_manager.mojom.h",
"+third_party/blink/public/platform/modules/font_unique_name_lookup/font_unique_name_lookup.mojom.h",
"+third_party/blink/public/platform/modules/indexeddb/web_idb_database_exception.h",
"+third_party/blink/public/platform/modules/indexeddb/web_idb_types.h",
"+third_party/blink/public/platform/modules/locks/lock_manager.mojom.h",
"+third_party/blink/public/platform/modules/notifications/web_notification_constants.h",
"+third_party/blink/public/platform/modules/service_worker/web_service_worker_error.h",
"+third_party/blink/public/public_buildflags.h",
......
// Copyright 2018 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/font_unique_name_lookup/font_unique_name_lookup_service.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/task_scheduler/post_task.h"
#include "content/browser/font_unique_name_lookup/font_unique_name_lookup.h"
#include "content/public/common/content_features.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
namespace content {
FontUniqueNameLookupService::FontUniqueNameLookupService()
: font_unique_name_lookup_(::content::FontUniqueNameLookup::GetInstance()) {
DCHECK(base::FeatureList::IsEnabled(features::kFontSrcLocalMatching));
}
FontUniqueNameLookupService::~FontUniqueNameLookupService() {}
// static
void FontUniqueNameLookupService::Create(
blink::mojom::FontUniqueNameLookupRequest request) {
mojo::MakeStrongBinding(std::make_unique<FontUniqueNameLookupService>(),
std::move(request));
}
// static
scoped_refptr<base::SequencedTaskRunner>
FontUniqueNameLookupService::GetTaskRunner() {
CR_DEFINE_STATIC_LOCAL(
scoped_refptr<base::SequencedTaskRunner>, runner,
(base::CreateSequencedTaskRunnerWithTraits(
{base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
base::TaskPriority::USER_BLOCKING})));
return runner;
}
void FontUniqueNameLookupService::GetUniqueNameLookupTable(
GetUniqueNameLookupTableCallback callback) {
DCHECK(GetTaskRunner()->RunsTasksInCurrentSequence());
std::move(callback).Run(
font_unique_name_lookup_.GetUniqueNameTableAsSharedMemoryRegion());
}
} // namespace content
// Copyright 2018 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.
#ifndef CONTENT_BROWSER_FONT_UNIQUE_NAME_LOOKUP_FONT_UNIQUE_NAME_LOOKUP_SERVICE_H_
#define CONTENT_BROWSER_FONT_UNIQUE_NAME_LOOKUP_FONT_UNIQUE_NAME_LOOKUP_SERVICE_H_
#include "base/files/file_path.h"
#include "base/macros.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "third_party/blink/public/platform/modules/font_unique_name_lookup/font_unique_name_lookup.mojom.h"
namespace content {
class FontUniqueNameLookup;
class FontUniqueNameLookupService : public blink::mojom::FontUniqueNameLookup {
public:
FontUniqueNameLookupService();
~FontUniqueNameLookupService() override;
static void Create(blink::mojom::FontUniqueNameLookupRequest);
static scoped_refptr<base::SequencedTaskRunner> GetTaskRunner();
void GetUniqueNameLookupTable(
GetUniqueNameLookupTableCallback callback) override;
private:
DISALLOW_COPY_AND_ASSIGN(FontUniqueNameLookupService);
::content::FontUniqueNameLookup& font_unique_name_lookup_;
};
} // namespace content
#endif // CONTENT_BROWSER_FONT_UNIQUE_NAME_LOOKUP_FONT_UNIQUE_NAME_LOOKUP_SERVICE_H_
......@@ -87,6 +87,7 @@
#include "content/browser/dom_storage/dom_storage_message_filter.h"
#include "content/browser/field_trial_recorder.h"
#include "content/browser/fileapi/fileapi_message_filter.h"
#include "content/browser/font_unique_name_lookup/font_unique_name_lookup_service.h"
#include "content/browser/frame_host/render_frame_message_filter.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/gpu/gpu_client_impl.h"
......@@ -1975,6 +1976,13 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
registry->AddInterface(base::Bind(&hyphenation::HyphenationImpl::Create),
hyphenation::HyphenationImpl::GetTaskRunner());
#endif
#if defined(OS_ANDROID)
if (base::FeatureList::IsEnabled(features::kFontSrcLocalMatching)) {
registry->AddInterface(
base::BindRepeating(&FontUniqueNameLookupService::Create),
FontUniqueNameLookupService::GetTaskRunner());
}
#endif
registry->AddInterface(base::Bind(&device::GamepadHapticsManager::Create));
......
......@@ -38,6 +38,7 @@
"blink.mojom.BlobRegistry",
"blink.mojom.BroadcastChannelProvider",
"blink.mojom.ClipboardHost",
"blink.mojom.FontUniqueNameLookup",
"blink.mojom.EmbeddedFrameSinkProvider",
"blink.mojom.FileUtilitiesHost",
"blink.mojom.LockManager",
......
......@@ -704,6 +704,7 @@ mojom("mojo_bindings") {
"platform/modules/cache_storage/cache_storage.mojom",
"platform/modules/credentialmanager/credential_manager.mojom",
"platform/modules/fetch/fetch_api_request.mojom",
"platform/modules/font_unique_name_lookup/font_unique_name_lookup.mojom",
"platform/modules/geolocation/geolocation_service.mojom",
"platform/modules/hyphenation/hyphenation.mojom",
"platform/modules/insecure_input/insecure_input_service.mojom",
......
drott@chromium.org
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
// Copyright 2018 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.
module blink.mojom;
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
interface FontUniqueNameLookup {
// Make the protobuf structured lookup list of
// (full_font_name|postscript_name) => (font_file + ttc_index) available to
// the renderer process.
[Sync] GetUniqueNameLookupTable() =>
(mojo_base.mojom.ReadOnlySharedMemoryRegion font_lookup_table);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment