Commit 5c74f327 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

Prepare for adding downloadable fonts unique font lookup

Move firmware matching to separate method and rename service_ member in
order to distinguish it from matching against downloadable
fonts (updateable via GMSCore) on the Java browser process side later.

No functional change.

Bug: 1121589
Change-Id: I3f7c25ed86cc7542cfbeeac587e473eec7ff809d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387566Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Dominik Röttsches <drott@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803462}
parent 162e3f72
......@@ -28,7 +28,7 @@ void FontUniqueNameLookupAndroid::PrepareFontUniqueNameLookup(
EnsureServiceConnected();
service_->GetUniqueNameLookupTable(base::BindOnce(
firmware_font_lookup_service_->GetUniqueNameLookupTable(base::BindOnce(
&FontUniqueNameLookupAndroid::ReceiveReadOnlySharedMemoryRegion,
base::Unretained(this)));
}
......@@ -53,8 +53,8 @@ bool FontUniqueNameLookupAndroid::IsFontUniqueNameLookupReadyForSyncLookup() {
bool sync_available_from_mojo = false;
base::ReadOnlySharedMemoryRegion shared_memory_region;
service_->GetUniqueNameLookupTableIfAvailable(&sync_available_from_mojo,
&shared_memory_region);
firmware_font_lookup_service_->GetUniqueNameLookupTableIfAvailable(
&sync_available_from_mojo, &shared_memory_region);
sync_available_ = sync_available_from_mojo;
if (*sync_available_) {
......@@ -74,20 +74,15 @@ sk_sp<SkTypeface> FontUniqueNameLookupAndroid::MatchUniqueName(
const String& font_unique_name) {
if (!IsFontUniqueNameLookupReadyForSyncLookup())
return nullptr;
base::Optional<FontTableMatcher::MatchResult> match_result =
font_table_matcher_->MatchName(font_unique_name.Utf8().c_str());
if (!match_result)
return nullptr;
return SkTypeface::MakeFromFile(match_result->font_path.c_str(),
match_result->ttc_index);
return MatchUniqueNameFromFirmwareFonts(font_unique_name);
}
void FontUniqueNameLookupAndroid::EnsureServiceConnected() {
if (service_)
if (firmware_font_lookup_service_)
return;
Platform::Current()->GetBrowserInterfaceBroker()->GetInterface(
service_.BindNewPipeAndPassReceiver());
firmware_font_lookup_service_.BindNewPipeAndPassReceiver());
}
void FontUniqueNameLookupAndroid::ReceiveReadOnlySharedMemoryRegion(
......@@ -100,4 +95,13 @@ void FontUniqueNameLookupAndroid::ReceiveReadOnlySharedMemoryRegion(
}
}
sk_sp<SkTypeface> FontUniqueNameLookupAndroid::MatchUniqueNameFromFirmwareFonts(
const String& font_unique_name) {
base::Optional<FontTableMatcher::MatchResult> match_result =
font_table_matcher_->MatchName(font_unique_name.Utf8().c_str());
if (!match_result)
return nullptr;
return SkTypeface::MakeFromFile(match_result->font_path.c_str(),
match_result->ttc_index);
}
} // namespace blink
......@@ -33,7 +33,10 @@ class FontUniqueNameLookupAndroid : public FontUniqueNameLookup {
void ReceiveReadOnlySharedMemoryRegion(
base::ReadOnlySharedMemoryRegion shared_memory_region);
mojo::Remote<mojom::blink::FontUniqueNameLookup> service_;
sk_sp<SkTypeface> MatchUniqueNameFromFirmwareFonts(const String&);
mojo::Remote<mojom::blink::FontUniqueNameLookup>
firmware_font_lookup_service_;
WTF::Deque<NotifyFontUniqueNameLookupReady> pending_callbacks_;
base::Optional<bool> sync_available_;
......
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