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 |
index b812bf1647fc1186a2dfcc8bc6d2899965630ed4..5b5f7138e1007477750748d3e5f15ead698705c4 100644 |
--- a/ppapi/proxy/truetype_font_singleton_resource.cc |
+++ b/ppapi/proxy/truetype_font_singleton_resource.cc |
@@ -39,6 +39,23 @@ int32_t TrueTypeFontSingletonResource::GetFontFamilies( |
return PP_OK_COMPLETIONPENDING; |
} |
+int32_t TrueTypeFontSingletonResource::GetFontsInFamily( |
+ PP_Instance instance, |
+ PP_Var family, |
+ const PP_ArrayOutput& output, |
+ const scoped_refptr<TrackedCallback>& callback) { |
+ scoped_refptr<StringVar> family_var = StringVar::FromPPVar(family); |
+ const uint32_t kMaxFamilySizeInBytes = 1024; |
+ if (!family_var || family_var->value().size() > kMaxFamilySizeInBytes) |
+ return PP_ERROR_BADARGUMENT; |
+ Call<PpapiPluginMsg_TrueTypeFontSingleton_GetFontsInFamilyReply>(BROWSER, |
+ PpapiHostMsg_TrueTypeFontSingleton_GetFontsInFamily(family_var->value()), |
+ base::Bind( |
+ &TrueTypeFontSingletonResource::OnPluginMsgGetFontsInFamilyComplete, |
+ this, callback, output)); |
+ return PP_OK_COMPLETIONPENDING; |
+} |
+ |
void TrueTypeFontSingletonResource::OnPluginMsgGetFontFamiliesComplete( |
scoped_refptr<TrackedCallback> callback, |
PP_ArrayOutput array_output, |
@@ -64,5 +81,31 @@ void TrueTypeFontSingletonResource::OnPluginMsgGetFontFamiliesComplete( |
callback->Run(result); |
} |
+void TrueTypeFontSingletonResource::OnPluginMsgGetFontsInFamilyComplete( |
+ scoped_refptr<TrackedCallback> callback, |
+ PP_ArrayOutput array_output, |
+ const ResourceMessageReplyParams& params, |
+ const std::vector<SerializedTrueTypeFontDesc>& fonts) { |
+ // The result code should contain the data size if it's positive. |
dmichael (off chromium)
2013/04/12 23:34:18
It's possible that you can get here in a situation
bbudge
2013/04/13 00:44:44
Is that possible on a singleton resource?
On 2013/
dmichael (off chromium)
2013/04/15 18:11:44
Oh, forgot about that. Yes, I think that would sti
bbudge
2013/04/17 23:49:19
I added the check at the beginning of this method
|
+ int32_t result = params.result(); |
+ DCHECK((result < 0 && fonts.size() == 0) || |
+ result == static_cast<int32_t>(fonts.size())); |
+ ArrayWriter output; |
+ output.set_pp_array_output(array_output); |
+ if (output.is_valid()) { |
+ // Convvert the message data to an array of PP_TrueTypeFontDesc_Dev structs. |
dmichael (off chromium)
2013/04/12 23:34:18
nit: Convvert->Convert
bbudge
2013/04/13 00:44:44
Done.
|
+ // The embedded family PP_Var is null so we don't worry about refs. |
dmichael (off chromium)
2013/04/12 23:34:18
The family is NULL? That seems like it might be co
bbudge
2013/04/13 00:44:44
I initially thought I could sidestep problems with
|
+ std::vector<PP_TrueTypeFontDesc_Dev> pp_fonts(fonts.size()); |
+ for (size_t i = 0; i < fonts.size(); i++) |
+ fonts[i].CopyToPPTrueTypeFontDesc(&pp_fonts[i]); |
+ |
+ output.StoreVector(pp_fonts); |
+ } else { |
+ result = PP_ERROR_FAILED; |
+ } |
+ |
+ callback->Run(result); |
+} |
+ |
} // namespace proxy |
} // namespace ppapi |