Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_clipboard.h" | 5 #include "ppapi/cpp/private/flash_clipboard.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ppapi/c/pp_bool.h" | 9 #include "ppapi/c/pp_bool.h" |
| 10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
| 11 #include "ppapi/cpp/instance_handle.h" | 11 #include "ppapi/cpp/instance_handle.h" |
| 12 #include "ppapi/cpp/module_impl.h" | 12 #include "ppapi/cpp/module_impl.h" |
| 13 #include "ppapi/cpp/var.h" | 13 #include "ppapi/cpp/var.h" |
| 14 | 14 |
| 15 namespace pp { | 15 namespace pp { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 template <> const char* interface_name<PPB_Flash_Clipboard_4_0>() { | 19 template <> const char* interface_name<PPB_Flash_Clipboard_4_0>() { |
| 20 return PPB_FLASH_CLIPBOARD_INTERFACE_4_0; | 20 return PPB_FLASH_CLIPBOARD_INTERFACE_4_0; |
| 21 } | 21 } |
| 22 | 22 |
| 23 template <> const char* interface_name<PPB_Flash_Clipboard_5_0>() { | 23 template <> const char* interface_name<PPB_Flash_Clipboard_5_0>() { |
| 24 return PPB_FLASH_CLIPBOARD_INTERFACE_5_0; | 24 return PPB_FLASH_CLIPBOARD_INTERFACE_5_0; |
| 25 } | 25 } |
| 26 | 26 |
| 27 template <> const char* interface_name<PPB_Flash_Clipboard_5_1>() { | |
| 28 return PPB_FLASH_CLIPBOARD_INTERFACE_5_1; | |
| 29 } | |
| 30 | |
| 27 } // namespace | 31 } // namespace |
| 28 | 32 |
| 29 namespace flash { | 33 namespace flash { |
| 30 | 34 |
| 31 // static | 35 // static |
| 32 bool Clipboard::IsAvailable() { | 36 bool Clipboard::IsAvailable() { |
| 33 return has_interface<PPB_Flash_Clipboard_5_0>() || | 37 return has_interface<PPB_Flash_Clipboard_5_1>() || |
| 38 has_interface<PPB_Flash_Clipboard_5_0>() || | |
| 34 has_interface<PPB_Flash_Clipboard_4_0>() ; | 39 has_interface<PPB_Flash_Clipboard_4_0>() ; |
| 35 } | 40 } |
| 36 | 41 |
| 37 // static | 42 // static |
| 38 uint32_t Clipboard::RegisterCustomFormat(const InstanceHandle& instance, | 43 uint32_t Clipboard::RegisterCustomFormat(const InstanceHandle& instance, |
| 39 const std::string& format_name) { | 44 const std::string& format_name) { |
| 40 uint32_t rv = PP_FLASH_CLIPBOARD_FORMAT_INVALID; | 45 uint32_t rv = PP_FLASH_CLIPBOARD_FORMAT_INVALID; |
| 41 if (has_interface<PPB_Flash_Clipboard_5_0>()) { | 46 if (has_interface<PPB_Flash_Clipboard_5_0>()) { |
| 42 rv = get_interface<PPB_Flash_Clipboard_5_0>()->RegisterCustomFormat( | 47 rv = get_interface<PPB_Flash_Clipboard_5_0>()->RegisterCustomFormat( |
| 43 instance.pp_instance(), format_name.c_str()); | 48 instance.pp_instance(), format_name.c_str()); |
| 44 } | 49 } |
| 45 return rv; | 50 return rv; |
| 46 } | 51 } |
| 47 | 52 |
| 48 // static | 53 // static |
| 49 bool Clipboard::IsFormatAvailable(const InstanceHandle& instance, | 54 bool Clipboard::IsFormatAvailable(const InstanceHandle& instance, |
| 50 PP_Flash_Clipboard_Type clipboard_type, | 55 PP_Flash_Clipboard_Type clipboard_type, |
| 51 uint32_t format) { | 56 uint32_t format) { |
| 52 bool rv = false; | 57 bool rv = false; |
| 53 if (has_interface<PPB_Flash_Clipboard_5_0>()) { | 58 if (has_interface<PPB_Flash_Clipboard_5_0>()) { |
|
teravest
2014/01/21 14:31:55
For all the existing methods, I think you need to
raymes
2014/01/22 23:23:18
Done.
| |
| 54 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard_5_0>()->IsFormatAvailable( | 59 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard_5_0>()->IsFormatAvailable( |
| 55 instance.pp_instance(), clipboard_type, format)); | 60 instance.pp_instance(), clipboard_type, format)); |
| 56 } else if (has_interface<PPB_Flash_Clipboard_4_0>()) { | 61 } else if (has_interface<PPB_Flash_Clipboard_4_0>()) { |
| 57 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard_4_0>()->IsFormatAvailable( | 62 rv = PP_ToBool(get_interface<PPB_Flash_Clipboard_4_0>()->IsFormatAvailable( |
| 58 instance.pp_instance(), clipboard_type, | 63 instance.pp_instance(), clipboard_type, |
| 59 static_cast<PP_Flash_Clipboard_Format>(format))); | 64 static_cast<PP_Flash_Clipboard_Format>(format))); |
| 60 } | 65 } |
| 61 return rv; | 66 return rv; |
| 62 } | 67 } |
| 63 | 68 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 instance.pp_instance(), | 146 instance.pp_instance(), |
| 142 clipboard_type, | 147 clipboard_type, |
| 143 data_items.size(), | 148 data_items.size(), |
| 144 formats_ptr, | 149 formats_ptr, |
| 145 data_items_ptr) == PP_OK); | 150 data_items_ptr) == PP_OK); |
| 146 } | 151 } |
| 147 | 152 |
| 148 return rv; | 153 return rv; |
| 149 } | 154 } |
| 150 | 155 |
| 156 // static | |
| 157 bool Clipboard::GetSequenceNumber(const InstanceHandle& instance, | |
| 158 PP_Flash_Clipboard_Type clipboard_type, | |
| 159 uint64_t* sequence_number) { | |
| 160 if (has_interface<PPB_Flash_Clipboard_5_1>()) { | |
| 161 return PP_ToBool( | |
| 162 get_interface<PPB_Flash_Clipboard_5_1>()->GetSequenceNumber( | |
| 163 instance.pp_instance(), clipboard_type, sequence_number)); | |
| 164 } | |
| 165 return false; | |
| 166 } | |
| 167 | |
| 151 } // namespace flash | 168 } // namespace flash |
| 152 } // namespace pp | 169 } // namespace pp |
| OLD | NEW |