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

Unified Diff: ppapi/proxy/truetype_font_singleton_resource.cc

Issue 12600019: Add Pepper TrueType font API plumbing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix linux_aura. Pango headers missing. Created 7 years, 9 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 | « ppapi/proxy/truetype_font_singleton_resource.h ('k') | ppapi/shared_impl/resource.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/truetype_font_singleton_resource.cc
diff --git a/ppapi/proxy/truetype_font_singleton_resource.cc b/ppapi/proxy/truetype_font_singleton_resource.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b812bf1647fc1186a2dfcc8bc6d2899965630ed4
--- /dev/null
+++ b/ppapi/proxy/truetype_font_singleton_resource.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2013 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 "ppapi/proxy/truetype_font_singleton_resource.h"
+
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/array_writer.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/shared_impl/var.h"
+
+namespace ppapi {
+namespace proxy {
+
+TrueTypeFontSingletonResource::TrueTypeFontSingletonResource(
+ Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(BROWSER, PpapiHostMsg_TrueTypeFontSingleton_Create());
+}
+
+TrueTypeFontSingletonResource::~TrueTypeFontSingletonResource() {
+}
+
+thunk::PPB_TrueTypeFont_Singleton_API*
+TrueTypeFontSingletonResource::AsPPB_TrueTypeFont_Singleton_API() {
+ return this;
+}
+
+int32_t TrueTypeFontSingletonResource::GetFontFamilies(
+ PP_Instance instance,
+ const PP_ArrayOutput& output,
+ const scoped_refptr<TrackedCallback>& callback) {
+ Call<PpapiPluginMsg_TrueTypeFontSingleton_GetFontFamiliesReply>(BROWSER,
+ PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies(),
+ base::Bind(
+ &TrueTypeFontSingletonResource::OnPluginMsgGetFontFamiliesComplete,
+ this, callback, output));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void TrueTypeFontSingletonResource::OnPluginMsgGetFontFamiliesComplete(
+ scoped_refptr<TrackedCallback> callback,
+ PP_ArrayOutput array_output,
+ const ResourceMessageReplyParams& params,
+ const std::vector<std::string>& font_families) {
+ // The result code should contain the data size if it's positive.
+ int32_t result = params.result();
+ DCHECK((result < 0 && font_families.size() == 0) ||
+ result == static_cast<int32_t>(font_families.size()));
+
+ ArrayWriter output;
+ output.set_pp_array_output(array_output);
+ if (output.is_valid()) {
+ std::vector< scoped_refptr<Var> > font_family_vars;
+ for (size_t i = 0; i < font_families.size(); i++)
+ font_family_vars.push_back(
+ scoped_refptr<Var>(new StringVar(font_families[i])));
+ output.StoreVarVector(font_family_vars);
+ } else {
+ result = PP_ERROR_FAILED;
+ }
+
+ callback->Run(result);
+}
+
+} // namespace proxy
+} // namespace ppapi
« no previous file with comments | « ppapi/proxy/truetype_font_singleton_resource.h ('k') | ppapi/shared_impl/resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698