Index: content/browser/renderer_host/fontmgr_message_filter.cc |
=================================================================== |
--- content/browser/renderer_host/fontmgr_message_filter.cc (revision 0) |
+++ content/browser/renderer_host/fontmgr_message_filter.cc (working copy) |
@@ -0,0 +1,107 @@ |
+// Copyright (c) 2014 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 "base/bind.h" |
+#include "base/bind_helpers.h" |
+#include "base/location.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/stl_util.h" |
+#include "content/browser/renderer_host/fontmgr_message_filter.h" |
+#include "content/common/fontmgr_messages.h" |
+#include "content/public/browser/browser_context.h" |
+#include "ipc/ipc_message_macros.h" |
+#include "third_party/skia/include/core/SkDataTable.h" |
+#include "third_party/skia/include/core/SkStream.h" |
+#include "third_party/skia/include/ports/SkFontMgr_indirect.h" |
+#include "third_party/skia/include/ports/SkTypeface_win.h" |
+#include "ui/gfx/codec/png_codec.h" |
+#include "ui/gfx/size.h" |
+#include "url/gurl.h" |
+ |
+ |
+namespace content { |
+ |
+FontMgrMessageFilter::FontMgrMessageFilter(SkRemotableFontMgr* fontManager) |
+ : BrowserMessageFilter(FontMsgStart) |
+ , fm(skia::AdoptRef(fontManager)) |
brettw
2014/03/11 21:38:15
Comma on prev line.
bungeman-chromium
2014/03/13 22:33:31
Done.
|
+{ |
+} |
+ |
+bool FontMgrMessageFilter::OnMessageReceived(const IPC::Message& message, |
+ bool* message_was_ok) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP_EX(FontMgrMessageFilter, message, *message_was_ok) |
+ IPC_MESSAGE_HANDLER(FontMsg_GetFamilyNames, OnFontMsg_GetFamilyNames) |
+ IPC_MESSAGE_HANDLER(FontMsg_GetIndexIdentities, |
+ OnFontMsg_GetIndexIdentities) |
+ IPC_MESSAGE_HANDLER(FontMsg_MatchIndexStyle, OnFontMsg_MatchIndexStyle) |
+ IPC_MESSAGE_HANDLER(FontMsg_MatchName, OnFontMsg_MatchName) |
+ IPC_MESSAGE_HANDLER(FontMsg_MatchNameStyle, OnFontMsg_MatchNameStyle) |
+ IPC_MESSAGE_HANDLER(FontMsg_MatchNameStyleCharacter, |
+ OnFontMsg_MatchNameStyleCharacter) |
+ IPC_MESSAGE_HANDLER(FontMsg_GetData, OnFontMsg_GetData) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP_EX() |
+ return handled; |
+} |
+ |
+FontMgrMessageFilter::~FontMgrMessageFilter() { |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_GetFamilyNames( |
+ skia::RefPtr<SkDataTable>* familyNames) |
+{ |
+ *familyNames = skia::AdoptRef(fm->getFamilyNames()); |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_GetIndexIdentities( |
+ int familyIndex, |
+ skia::RefPtr<SkRemotableFontIdentitySet>* styles) |
+{ |
+ *styles = skia::AdoptRef(fm->getIndexIdentities(familyIndex)); |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_MatchIndexStyle( |
+ int familyIndex, |
+ SkFontStyle style, |
+ SkFontIdentity* identity) |
+{ |
+ *identity = fm->matchIndexStyle(familyIndex, style); |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_MatchName(SkString familyName, |
+ skia::RefPtr<SkRemotableFontIdentitySet>* styles) |
brettw
2014/03/11 21:38:15
The two args should be aligned horizontally. So in
bungeman-chromium
2014/03/13 22:33:31
Done.
|
+{ |
brettw
2014/03/11 21:38:15
Fix { placement for this entire patch.
bungeman-chromium
2014/03/13 22:33:31
Done.
|
+ *styles = skia::AdoptRef(fm->matchName(familyName.c_str())); |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_MatchNameStyle( |
+ SkString familyName, |
+ SkFontStyle style, |
+ SkFontIdentity* identity) |
+{ |
+ *identity = fm->matchNameStyle(familyName.c_str(), style); |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_MatchNameStyleCharacter( |
+ SkString familyName, |
brettw
2014/03/11 21:38:15
I'd use Chrome-style for everything that you can,
bungeman-chromium
2014/03/13 22:33:31
Done.
|
+ SkFontStyle style, |
+ SkString bpc47, |
+ uint32_t character, |
+ SkFontIdentity* identity) |
+{ |
+ *identity = fm->matchNameStyleCharacter(familyName.c_str(), |
brettw
2014/03/11 21:38:15
It's not clear why we need to serialize as SkStrin
bungeman-chromium
2014/03/13 22:33:31
Maybe, it's this way currently because I was chang
|
+ style, |
+ bpc47.c_str(), |
+ character); |
+} |
+ |
+void FontMgrMessageFilter::OnFontMsg_GetData( |
+ uint32_t dataId, |
+ skia::RefPtr<SkStream>* fontData) |
+{ |
+ *fontData = skia::AdoptRef(fm->getData(dataId)); |
+} |
+ |
+} // namespace content |