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

Side by Side Diff: ppapi/cpp/private/flash_font_file.cc

Issue 1416643002: Enable pp::flash::FontFile support on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Based generated thunk files Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/cpp/private/flash_font_file.h" 5 #include "ppapi/cpp/private/flash_font_file.h"
6 6
7 #include "ppapi/c/dev/ppb_font_dev.h" 7 #include "ppapi/c/dev/ppb_font_dev.h"
8 #include "ppapi/c/private/ppb_flash_font_file.h" 8 #include "ppapi/c/private/ppb_flash_font_file.h"
9 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" 9 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
10 #include "ppapi/cpp/instance_handle.h" 10 #include "ppapi/cpp/instance_handle.h"
11 #include "ppapi/cpp/module_impl.h" 11 #include "ppapi/cpp/module_impl.h"
12 12
13 namespace pp { 13 namespace pp {
14 14
15 namespace { 15 namespace {
16 16
17 template <> const char* interface_name<PPB_Flash_FontFile_0_1>() { 17 template <> const char* interface_name<PPB_Flash_FontFile_0_1>() {
18 return PPB_FLASH_FONTFILE_INTERFACE_0_1; 18 return PPB_FLASH_FONTFILE_INTERFACE_0_1;
19 } 19 }
20 20
21 template <> const char* interface_name<PPB_Flash_FontFile_0_2>() {
22 return PPB_FLASH_FONTFILE_INTERFACE_0_2;
23 }
24
21 } // namespace 25 } // namespace
22 26
23 namespace flash { 27 namespace flash {
24 28
25 FontFile::FontFile() { 29 FontFile::FontFile() {
26 } 30 }
27 31
28 FontFile::FontFile(const InstanceHandle& instance, 32 FontFile::FontFile(const InstanceHandle& instance,
29 const PP_BrowserFont_Trusted_Description* description, 33 const PP_BrowserFont_Trusted_Description* description,
30 PP_PrivateFontCharset charset) { 34 PP_PrivateFontCharset charset) {
31 if (has_interface<PPB_Flash_FontFile_0_1>()) { 35 if (has_interface<PPB_Flash_FontFile_0_2>()) {
36 PassRefFromConstructor(get_interface<PPB_Flash_FontFile_0_2>()->Create(
37 instance.pp_instance(), description, charset));
38 }
39 else if (has_interface<PPB_Flash_FontFile_0_1>()) {
32 PassRefFromConstructor(get_interface<PPB_Flash_FontFile_0_1>()->Create( 40 PassRefFromConstructor(get_interface<PPB_Flash_FontFile_0_1>()->Create(
33 instance.pp_instance(), description, charset)); 41 instance.pp_instance(), description, charset));
34 } 42 }
35 } 43 }
36 44
37 FontFile::~FontFile() { 45 FontFile::~FontFile() {
38 } 46 }
39 47
40 // static 48 // static
41 bool FontFile::IsAvailable() { 49 bool FontFile::IsAvailable() {
42 return has_interface<PPB_Flash_FontFile_0_1>(); 50 return (has_interface<PPB_Flash_FontFile_0_2>() ||
51 has_interface<PPB_Flash_FontFile_0_1>());
52 }
53
54 bool FontFile::IsSupportedForWindows() {
55 if (has_interface<PPB_Flash_FontFile_0_2>())
56 return !!get_interface<PPB_Flash_FontFile_0_2>()->IsSupportedForWindows();
57 return false;
43 } 58 }
44 59
45 bool FontFile::GetFontTable(uint32_t table, 60 bool FontFile::GetFontTable(uint32_t table,
46 void* output, 61 void* output,
47 uint32_t* output_length) { 62 uint32_t* output_length) {
48 if (has_interface<PPB_Flash_FontFile_0_1>()) { 63 if (has_interface<PPB_Flash_FontFile_0_2>()) {
64 return !!get_interface<PPB_Flash_FontFile_0_2>()->
65 GetFontTable(pp_resource(), table, output, output_length);
66 }
67 else if (has_interface<PPB_Flash_FontFile_0_1>()) {
49 return !!get_interface<PPB_Flash_FontFile_0_1>()-> 68 return !!get_interface<PPB_Flash_FontFile_0_1>()->
50 GetFontTable(pp_resource(), table, output, output_length); 69 GetFontTable(pp_resource(), table, output, output_length);
51 } 70 }
52 return false; 71 return false;
53 } 72 }
54 73
55 } // namespace flash 74 } // namespace flash
56 } // namespace pp 75 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698