From f2a33ff9cbc6d19943f1c7fbddd1f23d23975577 Mon Sep 17 00:00:00 2001 From: Andras Becsi Date: Wed, 11 Dec 2013 21:33:03 +0100 Subject: Update Chromium to branch 1650 (31.0.1650.63) Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f Reviewed-by: Jocelyn Turcotte --- chromium/ppapi/cpp/audio.cc | 41 +++++++- chromium/ppapi/cpp/audio.h | 18 +++- chromium/ppapi/cpp/dev/url_util_dev.cc | 7 ++ chromium/ppapi/cpp/dev/url_util_dev.h | 2 + chromium/ppapi/cpp/file_ref.h | 2 +- chromium/ppapi/cpp/network_list.cc | 94 ++++++++++++++++++ chromium/ppapi/cpp/network_list.h | 60 +++++++++++ chromium/ppapi/cpp/network_monitor.cc | 44 +++++++++ chromium/ppapi/cpp/network_monitor.h | 31 ++++++ chromium/ppapi/cpp/output_traits.h | 23 +++++ .../ppapi/cpp/private/content_decryptor_private.cc | 38 ++++--- .../ppapi/cpp/private/content_decryptor_private.h | 8 +- chromium/ppapi/cpp/private/network_list_private.cc | 110 --------------------- chromium/ppapi/cpp/private/network_list_private.h | 58 ----------- .../ppapi/cpp/private/network_monitor_private.cc | 35 ------- .../ppapi/cpp/private/network_monitor_private.h | 28 ------ chromium/ppapi/cpp/private/pdf.cc | 10 ++ chromium/ppapi/cpp/private/pdf.h | 2 + .../ppapi/cpp/private/platform_verification.cc | 66 +++++++++++++ chromium/ppapi/cpp/private/platform_verification.h | 33 +++++++ chromium/ppapi/cpp/tcp_socket.cc | 72 +++++++++++++- chromium/ppapi/cpp/tcp_socket.h | 68 ++++++++++--- 22 files changed, 570 insertions(+), 280 deletions(-) create mode 100644 chromium/ppapi/cpp/network_list.cc create mode 100644 chromium/ppapi/cpp/network_list.h create mode 100644 chromium/ppapi/cpp/network_monitor.cc create mode 100644 chromium/ppapi/cpp/network_monitor.h delete mode 100644 chromium/ppapi/cpp/private/network_list_private.cc delete mode 100644 chromium/ppapi/cpp/private/network_list_private.h delete mode 100644 chromium/ppapi/cpp/private/network_monitor_private.cc delete mode 100644 chromium/ppapi/cpp/private/network_monitor_private.h create mode 100644 chromium/ppapi/cpp/private/platform_verification.cc create mode 100644 chromium/ppapi/cpp/private/platform_verification.h (limited to 'chromium/ppapi/cpp') diff --git a/chromium/ppapi/cpp/audio.cc b/chromium/ppapi/cpp/audio.cc index 89702be0072..04a3062cb18 100644 --- a/chromium/ppapi/cpp/audio.cc +++ b/chromium/ppapi/cpp/audio.cc @@ -15,13 +15,30 @@ template <> const char* interface_name() { return PPB_AUDIO_INTERFACE_1_0; } +template <> const char* interface_name() { + return PPB_AUDIO_INTERFACE_1_1; +} + } // namespace Audio::Audio(const InstanceHandle& instance, const AudioConfig& config, PPB_Audio_Callback callback, void* user_data) - : config_(config) { + : config_(config), + use_1_0_interface_(false) { + if (has_interface()) { + PassRefFromConstructor(get_interface()->Create( + instance.pp_instance(), config.pp_resource(), callback, user_data)); + } +} + +Audio::Audio(const InstanceHandle& instance, + const AudioConfig& config, + PPB_Audio_Callback_1_0 callback, + void* user_data) + : config_(config), + use_1_0_interface_(true) { if (has_interface()) { PassRefFromConstructor(get_interface()->Create( instance.pp_instance(), config.pp_resource(), callback, user_data)); @@ -29,13 +46,27 @@ Audio::Audio(const InstanceHandle& instance, } bool Audio::StartPlayback() { - return has_interface() && - get_interface()->StartPlayback(pp_resource()); + if (has_interface() && !use_1_0_interface_) { + return PP_ToBool(get_interface()->StartPlayback( + pp_resource())); + } + if (has_interface()) { + return PP_ToBool(get_interface()->StartPlayback( + pp_resource())); + } + return false; } bool Audio::StopPlayback() { - return has_interface() && - get_interface()->StopPlayback(pp_resource()); + if (has_interface() && !use_1_0_interface_) { + return PP_ToBool(get_interface()->StopPlayback( + pp_resource())); + } + if (has_interface()) { + return PP_ToBool(get_interface()->StopPlayback( + pp_resource())); + } + return false; } } // namespace pp diff --git a/chromium/ppapi/cpp/audio.h b/chromium/ppapi/cpp/audio.h index a07fcf58067..29a19f364f1 100644 --- a/chromium/ppapi/cpp/audio.h +++ b/chromium/ppapi/cpp/audio.h @@ -41,19 +41,30 @@ class Audio : public Resource { /// /// @param[in] instance The instance with which this resource will be /// associated. - // /// @param[in] config An AudioConfig containing the audio config /// resource. - // /// @param[in] callback A PPB_Audio_Callback callback function /// that the browser calls when it needs more samples to play. - // /// @param[in] user_data A pointer to user data used in the callback function. Audio(const InstanceHandle& instance, const AudioConfig& config, PPB_Audio_Callback callback, void* user_data); + /// A constructor that creates an Audio resource. + /// + /// @param[in] instance The instance with which this resource will be + /// associated. + /// @param[in] config An AudioConfig containing the audio config + /// resource. + /// @param[in] callback A PPB_Audio_Callback_1_0 callback + /// function that the browser calls when it needs more samples to play. + /// @param[in] user_data A pointer to user data used in the callback function. + Audio(const InstanceHandle& instance, + const AudioConfig& config, + PPB_Audio_Callback_1_0 callback, + void* user_data); + /// Getter function for returning the internal PPB_AudioConfig /// struct. /// @@ -79,6 +90,7 @@ class Audio : public Resource { private: AudioConfig config_; + bool use_1_0_interface_; }; } // namespace pp diff --git a/chromium/ppapi/cpp/dev/url_util_dev.cc b/chromium/ppapi/cpp/dev/url_util_dev.cc index 0353883265f..5029a4576c2 100644 --- a/chromium/ppapi/cpp/dev/url_util_dev.cc +++ b/chromium/ppapi/cpp/dev/url_util_dev.cc @@ -82,4 +82,11 @@ Var URLUtil_Dev::GetPluginInstanceURL(const InstanceHandle& instance, components)); } +Var URLUtil_Dev::GetPluginReferrerURL(const InstanceHandle& instance, + PP_URLComponents_Dev* components) const { + return Var(PASS_REF, + interface_->GetPluginReferrerURL(instance.pp_instance(), + components)); +} + } // namespace pp diff --git a/chromium/ppapi/cpp/dev/url_util_dev.h b/chromium/ppapi/cpp/dev/url_util_dev.h index 6c0ecf56b12..9399752514a 100644 --- a/chromium/ppapi/cpp/dev/url_util_dev.h +++ b/chromium/ppapi/cpp/dev/url_util_dev.h @@ -41,6 +41,8 @@ class URLUtil_Dev { Var GetPluginInstanceURL(const InstanceHandle& instance, PP_URLComponents_Dev* components = NULL) const; + Var GetPluginReferrerURL(const InstanceHandle& instance, + PP_URLComponents_Dev* components = NULL) const; private: URLUtil_Dev() : interface_(NULL) {} diff --git a/chromium/ppapi/cpp/file_ref.h b/chromium/ppapi/cpp/file_ref.h index d229c5fd7ad..56828f7e642 100644 --- a/chromium/ppapi/cpp/file_ref.h +++ b/chromium/ppapi/cpp/file_ref.h @@ -48,7 +48,7 @@ class FileRef : public Resource { /// /// @param[in] file_system A FileSystem corresponding to a file /// system type. - /// @param[in] path A path to the file. + /// @param[in] path A path to the file. Must begin with a '/' character. FileRef(const FileSystem& file_system, const char* path); /// The copy constructor for FileRef. diff --git a/chromium/ppapi/cpp/network_list.cc b/chromium/ppapi/cpp/network_list.cc new file mode 100644 index 00000000000..12c3bf4c96c --- /dev/null +++ b/chromium/ppapi/cpp/network_list.cc @@ -0,0 +1,94 @@ +// Copyright (c) 2012 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/cpp/network_list.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/cpp/array_output.h" +#include "ppapi/cpp/logging.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/net_address.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name() { + return PPB_NETWORKLIST_INTERFACE_1_0; +} + +} // namespace + +NetworkList::NetworkList() { +} + +NetworkList::NetworkList(PassRef, PP_Resource resource) + : Resource(PASS_REF, resource) { +} + +// static +bool NetworkList::IsAvailable() { + return has_interface(); +} + +uint32_t NetworkList::GetCount() const { + if (!has_interface()) + return 0; + return get_interface()->GetCount(pp_resource()); +} + +std::string NetworkList::GetName(uint32_t index) const { + if (!has_interface()) + return std::string(); + Var result(PASS_REF, + get_interface()->GetName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +PP_NetworkList_Type NetworkList::GetType(uint32_t index) const { + if (!has_interface()) + return PP_NETWORKLIST_TYPE_ETHERNET; + return get_interface()->GetType( + pp_resource(), index); +} + +PP_NetworkList_State NetworkList::GetState(uint32_t index) const { + if (!has_interface()) + return PP_NETWORKLIST_STATE_DOWN; + return get_interface()->GetState( + pp_resource(), index); +} + +int32_t NetworkList::GetIpAddresses( + uint32_t index, + std::vector* addresses) const { + if (!has_interface()) + return PP_ERROR_NOINTERFACE; + if (!addresses) + return PP_ERROR_BADARGUMENT; + + ResourceArrayOutputAdapter adapter(addresses); + return get_interface()->GetIpAddresses( + pp_resource(), index, adapter.pp_array_output()); +} + +std::string NetworkList::GetDisplayName(uint32_t index) const { + if (!has_interface()) + return std::string(); + Var result(PASS_REF, + get_interface()->GetDisplayName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +uint32_t NetworkList::GetMTU(uint32_t index) const { + if (!has_interface()) + return 0; + return get_interface()->GetMTU( + pp_resource(), index); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/network_list.h b/chromium/ppapi/cpp/network_list.h new file mode 100644 index 00000000000..d479129442e --- /dev/null +++ b/chromium/ppapi/cpp/network_list.h @@ -0,0 +1,60 @@ +// Copyright (c) 2012 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. + +#ifndef PPAPI_CPP_NETWORK_LIST_H_ +#define PPAPI_CPP_NETWORK_LIST_H_ + +#include +#include + +#include "ppapi/c/ppb_network_list.h" +#include "ppapi/cpp/pass_ref.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class NetAddress; + +class NetworkList : public Resource { + public: + NetworkList(); + NetworkList(PassRef, PP_Resource resource); + + /// Returns true if the required interface is available. + static bool IsAvailable(); + + /// @return Returns the number of available network interfaces or 0 + /// if the list has never been updated. + uint32_t GetCount() const; + + /// @return Returns the name for the network interface with the + /// specified index. + std::string GetName(uint32_t index) const; + + /// @return Returns the type of the network interface with the + /// specified index. + PP_NetworkList_Type GetType(uint32_t index) const; + + /// @return Returns the current state of the network interface with + /// the specified index. + PP_NetworkList_State GetState(uint32_t index) const; + + /// Gets the list of IP addresses for the network interface with the + /// specified index and stores them in + /// addresses. + int32_t GetIpAddresses(uint32_t index, + std::vector* addresses) const; + + /// @return Returns the display name for the network interface with + /// the specified index. + std::string GetDisplayName(uint32_t index) const; + + /// @return Returns the MTU for the network interface with the + /// specified index. + uint32_t GetMTU(uint32_t index) const; +}; + +} // namespace pp + +#endif // PPAPI_CPP_NETWORK_LIST_H_ diff --git a/chromium/ppapi/cpp/network_monitor.cc b/chromium/ppapi/cpp/network_monitor.cc new file mode 100644 index 00000000000..b721e965dca --- /dev/null +++ b/chromium/ppapi/cpp/network_monitor.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2012 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/cpp/network_monitor.h" + +#include "ppapi/c/ppb_network_monitor.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/network_list.h" + +namespace pp { + +namespace { + +template <> const char* interface_name() { + return PPB_NETWORKMONITOR_INTERFACE_1_0; +} + +} // namespace + +NetworkMonitor::NetworkMonitor(const InstanceHandle& instance) { + if (has_interface()) { + PassRefFromConstructor(get_interface()->Create( + instance.pp_instance())); + } +} + +int32_t NetworkMonitor::UpdateNetworkList( + const CompletionCallbackWithOutput& callback) { + if (has_interface()) { + return get_interface()->UpdateNetworkList( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +// static +bool NetworkMonitor::IsAvailable() { + return has_interface(); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/network_monitor.h b/chromium/ppapi/cpp/network_monitor.h new file mode 100644 index 00000000000..bce731d90d2 --- /dev/null +++ b/chromium/ppapi/cpp/network_monitor.h @@ -0,0 +1,31 @@ +// Copyright (c) 2012 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. + +#ifndef PPAPI_CPP_NETWORK_MONITOR_H_ +#define PPAPI_CPP_NETWORK_MONITOR_H_ + +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class Instance; +class NetworkList; + +template class CompletionCallbackWithOutput; + +class NetworkMonitor : public Resource { + public: + explicit NetworkMonitor(const InstanceHandle& instance); + + int32_t UpdateNetworkList( + const CompletionCallbackWithOutput& callback); + + // Returns true if the required interface is available. + static bool IsAvailable(); +}; + +} // namespace pp + +#endif // PPAPI_CPP_NETWORK_MONITOR_H_ diff --git a/chromium/ppapi/cpp/output_traits.h b/chromium/ppapi/cpp/output_traits.h index 37a8a656e12..31cdbbe1122 100644 --- a/chromium/ppapi/cpp/output_traits.h +++ b/chromium/ppapi/cpp/output_traits.h @@ -161,6 +161,29 @@ struct CallbackOutputTraits { } }; +// A specialization of CallbackOutputTraits for bool output parameters. +// It passes a PP_Bool* to the browser and converts to a bool when passing +// to the plugin. +template<> +struct CallbackOutputTraits { + // To call the browser, we just pass a PP_Bool* as an output param. + typedef PP_Bool* APIArgType; + typedef PP_Bool StorageType; + + static inline APIArgType StorageToAPIArg(StorageType& t) { + return &t; + } + + // Converts the PP_Bool to a bool object. + static inline bool StorageToPluginArg(StorageType& t) { + return PP_ToBool(t); + } + + static inline void Initialize(StorageType* t) { + *t = PP_FALSE; + } +}; + // Array output parameters ----------------------------------------------------- // Output traits for vectors of all "plain old data" (POD) types. It is diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.cc b/chromium/ppapi/cpp/private/content_decryptor_private.cc index 48690946128..23417c3e155 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.cc +++ b/chromium/ppapi/cpp/private/content_decryptor_private.cc @@ -23,10 +23,9 @@ namespace { static const char kPPPContentDecryptorInterface[] = PPP_CONTENTDECRYPTOR_PRIVATE_INTERFACE; -void GenerateKeyRequest(PP_Instance instance, - PP_Var key_system_arg, - PP_Var type_arg, - PP_Var init_data_arg) { +void Initialize(PP_Instance instance, + PP_Var key_system_arg, + PP_Bool can_challenge_platform) { void* object = Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); if (!object) @@ -36,6 +35,19 @@ void GenerateKeyRequest(PP_Instance instance, if (!key_system_var.is_string()) return; + static_cast(object)->Initialize( + key_system_var.AsString(), + PP_ToBool(can_challenge_platform)); +} + +void GenerateKeyRequest(PP_Instance instance, + PP_Var type_arg, + PP_Var init_data_arg) { + void* object = + Instance::GetPerInstanceObject(instance, kPPPContentDecryptorInterface); + if (!object) + return; + pp::Var type_var(pp::PASS_REF, type_arg); if (!type_var.is_string()) return; @@ -46,7 +58,6 @@ void GenerateKeyRequest(PP_Instance instance, pp::VarArrayBuffer init_data_array_buffer(init_data_var); static_cast(object)->GenerateKeyRequest( - key_system_var.AsString(), type_var.AsString(), init_data_array_buffer); } @@ -184,6 +195,7 @@ void DecryptAndDecode(PP_Instance instance, } const PPP_ContentDecryptor_Private ppp_content_decryptor = { + &Initialize, &GenerateKeyRequest, &AddKey, &CancelKeyRequest, @@ -214,22 +226,6 @@ ContentDecryptor_Private::~ContentDecryptor_Private() { this); } -void ContentDecryptor_Private::NeedKey(const std::string& key_system, - const std::string& session_id, - pp::VarArrayBuffer init_data) { - // session_id can be empty here. - if (has_interface()) { - pp::Var key_system_var(key_system); - pp::Var session_id_var(session_id); - - get_interface()->NeedKey( - associated_instance_.pp_instance(), - key_system_var.pp_var(), - session_id_var.pp_var(), - init_data.pp_var()); - } -} - void ContentDecryptor_Private::KeyAdded(const std::string& key_system, const std::string& session_id) { if (has_interface()) { diff --git a/chromium/ppapi/cpp/private/content_decryptor_private.h b/chromium/ppapi/cpp/private/content_decryptor_private.h index 477c6de5c25..a43a74cfb83 100644 --- a/chromium/ppapi/cpp/private/content_decryptor_private.h +++ b/chromium/ppapi/cpp/private/content_decryptor_private.h @@ -31,8 +31,9 @@ class ContentDecryptor_Private { // TODO(tomfinegan): This could be optimized to pass pp::Var instead of // strings. The change would allow the CDM wrapper to reuse vars when // replying to the browser. - virtual void GenerateKeyRequest(const std::string& key_system, - const std::string& type, + virtual void Initialize(const std::string& key_system, + bool can_challenge_platform) = 0; + virtual void GenerateKeyRequest(const std::string& type, pp::VarArrayBuffer init_data) = 0; virtual void AddKey(const std::string& session_id, pp::VarArrayBuffer key, @@ -58,9 +59,6 @@ class ContentDecryptor_Private { // PPB_ContentDecryptor_Private methods for passing data from the decryptor // to the browser. - void NeedKey(const std::string& key_system, - const std::string& session_id, - pp::VarArrayBuffer init_data); void KeyAdded(const std::string& key_system, const std::string& session_id); void KeyMessage(const std::string& key_system, diff --git a/chromium/ppapi/cpp/private/network_list_private.cc b/chromium/ppapi/cpp/private/network_list_private.cc deleted file mode 100644 index 1297aa3a09c..00000000000 --- a/chromium/ppapi/cpp/private/network_list_private.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) 2012 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/cpp/private/network_list_private.h" - -#include "ppapi/cpp/module_impl.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -namespace { - -template <> const char* interface_name() { - return PPB_NETWORKLIST_PRIVATE_INTERFACE; -} - -} // namespace - -NetworkListPrivate::NetworkListPrivate() { -} - -NetworkListPrivate::NetworkListPrivate(PassRef, PP_Resource resource) - : Resource(PASS_REF, resource) { -} - -// static -bool NetworkListPrivate::IsAvailable() { - return has_interface(); -} - -uint32_t NetworkListPrivate::GetCount() const { - if (!has_interface()) - return 0; - return get_interface()->GetCount(pp_resource()); -} - -std::string NetworkListPrivate::GetName(uint32_t index) const { - if (!has_interface()) - return std::string(); - Var result(PASS_REF, - get_interface()->GetName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { - if (!has_interface()) - return PP_NETWORKLIST_ETHERNET; - return get_interface()->GetType( - pp_resource(), index); -} - -PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { - if (!has_interface()) - return PP_NETWORKLIST_DOWN; - return get_interface()->GetState( - pp_resource(), index); -} - -void NetworkListPrivate::GetIpAddresses( - uint32_t index, - std::vector* addresses) const { - if (!has_interface()) - return; - - // Most network interfaces don't have more than 3 network - // interfaces. - addresses->resize(3); - - int32_t result = get_interface()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - - if (result < 0) { - addresses->resize(0); - return; - } - - if (result <= static_cast(addresses->size())) { - addresses->resize(result); - return; - } - - addresses->resize(result); - result = get_interface()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - if (result < 0) { - addresses->resize(0); - } else if (result < static_cast(addresses->size())) { - addresses->resize(result); - } -} - -std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { - if (!has_interface()) - return std::string(); - Var result(PASS_REF, - get_interface()->GetDisplayName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { - if (!has_interface()) - return 0; - return get_interface()->GetMTU( - pp_resource(), index); -} - -} // namespace pp diff --git a/chromium/ppapi/cpp/private/network_list_private.h b/chromium/ppapi/cpp/private/network_list_private.h deleted file mode 100644 index 31cd9b598b8..00000000000 --- a/chromium/ppapi/cpp/private/network_list_private.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ - -#include -#include - -#include "ppapi/c/private/ppb_network_list_private.h" -#include "ppapi/cpp/pass_ref.h" -#include "ppapi/cpp/resource.h" - -namespace pp { - -class NetworkListPrivate : public Resource { - public: - NetworkListPrivate(); - NetworkListPrivate(PassRef, PP_Resource resource); - - /// Returns true if the required interface is available. - static bool IsAvailable(); - - /// @return Returns the number of available network interfaces or 0 - /// if the list has never been updated. - uint32_t GetCount() const; - - /// @return Returns the name for the network interface with the - /// specified index. - std::string GetName(uint32_t index) const; - - /// @return Returns the type of the network interface with the - /// specified index. - PP_NetworkListType_Private GetType(uint32_t index) const; - - /// @return Returns the current state of the network interface with - /// the specified index. - PP_NetworkListState_Private GetState(uint32_t index) const; - - /// Gets the list of IP addresses for the network interface with the - /// specified index and stores them in - /// addresses. - void GetIpAddresses(uint32_t index, - std::vector* addresses) const; - - /// @return Returns the display name for the network interface with - /// the specified index. - std::string GetDisplayName(uint32_t index) const; - - /// @return Returns the MTU for the network interface with the - /// specified index. - uint32_t GetMTU(uint32_t index) const; -}; - -} // namespace pp - -#endif // PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ diff --git a/chromium/ppapi/cpp/private/network_monitor_private.cc b/chromium/ppapi/cpp/private/network_monitor_private.cc deleted file mode 100644 index 2f931ea4288..00000000000 --- a/chromium/ppapi/cpp/private/network_monitor_private.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2012 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/cpp/private/network_monitor_private.h" - -#include "ppapi/cpp/instance.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name() { - return PPB_NETWORKMONITOR_PRIVATE_INTERFACE; -} - -} // namespace - -NetworkMonitorPrivate::NetworkMonitorPrivate( - const InstanceHandle& instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) { - if (has_interface()) { - PassRefFromConstructor(get_interface()->Create( - instance.pp_instance(), callback, user_data)); - } -} - -// static -bool NetworkMonitorPrivate::IsAvailable() { - return has_interface(); -} - -} // namespace pp diff --git a/chromium/ppapi/cpp/private/network_monitor_private.h b/chromium/ppapi/cpp/private/network_monitor_private.h deleted file mode 100644 index 693bbcdc7fb..00000000000 --- a/chromium/ppapi/cpp/private/network_monitor_private.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ -#define PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ - -#include "ppapi/c/private/ppb_network_monitor_private.h" -#include "ppapi/cpp/resource.h" -#include "ppapi/cpp/instance_handle.h" - -namespace pp { - -class Instance; - -class NetworkMonitorPrivate : public Resource { - public: - NetworkMonitorPrivate(const InstanceHandle& instance, - PPB_NetworkMonitor_Callback callback, - void* user_data); - - // Returns true if the required interface is available. - static bool IsAvailable(); -}; - -} // namespace pp - -#endif // PPAPI_CPP_PRIVATE_NETWORK_MONITOR_PRIVATE_H_ diff --git a/chromium/ppapi/cpp/private/pdf.cc b/chromium/ppapi/cpp/private/pdf.cc index 753613c18a3..9d6bd898251 100644 --- a/chromium/ppapi/cpp/private/pdf.cc +++ b/chromium/ppapi/cpp/private/pdf.cc @@ -184,4 +184,14 @@ ImageData PDF::GetResourceImageForScale(const InstanceHandle& instance, return ImageData(); } +Var PDF::ModalPromptForPassword(const InstanceHandle& instance, + Var message) { + if (has_interface()) { + return Var(PASS_REF, + get_interface()->ModalPromptForPassword( + instance.pp_instance(), + message.pp_var())); + } + return Var(); +} } // namespace pp diff --git a/chromium/ppapi/cpp/private/pdf.h b/chromium/ppapi/cpp/private/pdf.h index 893f9e3f279..1e89dd0c7ed 100644 --- a/chromium/ppapi/cpp/private/pdf.h +++ b/chromium/ppapi/cpp/private/pdf.h @@ -62,6 +62,8 @@ class PDF { static ImageData GetResourceImageForScale(const InstanceHandle& instance, PP_ResourceImage image_id, float scale); + static Var ModalPromptForPassword(const InstanceHandle& instance, + Var message); }; } // namespace pp diff --git a/chromium/ppapi/cpp/private/platform_verification.cc b/chromium/ppapi/cpp/private/platform_verification.cc new file mode 100644 index 00000000000..f9085700696 --- /dev/null +++ b/chromium/ppapi/cpp/private/platform_verification.cc @@ -0,0 +1,66 @@ +// Copyright 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/cpp/private/platform_verification.h" + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_platform_verification_private.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module_impl.h" +#include "ppapi/cpp/var.h" + +namespace pp { + +namespace { + +template <> const char* interface_name() { + return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1; +} + +inline bool HasInterface() { + return has_interface(); +} + +inline const PPB_PlatformVerification_Private_0_1* GetInterface() { + return get_interface(); +} + +} // namespace + +PlatformVerification::PlatformVerification(const InstanceHandle& instance) { + if (HasInterface()) + PassRefFromConstructor(GetInterface()->Create(instance.pp_instance())); +} + +PlatformVerification::~PlatformVerification() {} + +int32_t PlatformVerification::CanChallengePlatform( + const CompletionCallbackWithOutput& callback) { + if (!HasInterface()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return GetInterface()->CanChallengePlatform( + pp_resource(), callback.output(), callback.pp_completion_callback()); +} + +int32_t PlatformVerification::ChallengePlatform( + const Var& service_id, + const Var& challenge, + Var* signed_data, + Var* signed_data_signature, + Var* platform_key_certificate, + const CompletionCallback& callback) { + if (!HasInterface()) + return callback.MayForce(PP_ERROR_NOINTERFACE); + + return GetInterface()->ChallengePlatform( + pp_resource(), service_id.pp_var(), challenge.pp_var(), + const_cast(&signed_data->pp_var()), + const_cast(&signed_data_signature->pp_var()), + const_cast(&platform_key_certificate->pp_var()), + callback.pp_completion_callback()); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/platform_verification.h b/chromium/ppapi/cpp/private/platform_verification.h new file mode 100644 index 00000000000..7f0f8a197ff --- /dev/null +++ b/chromium/ppapi/cpp/private/platform_verification.h @@ -0,0 +1,33 @@ +// Copyright 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. + +#ifndef PPAPI_CPP_PRIVATE_PLATFORM_VERIFICATION_H_ +#define PPAPI_CPP_PRIVATE_PLATFORM_VERIFICATION_H_ + +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/resource.h" + +namespace pp { + +class InstanceHandle; +class Var; + +class PlatformVerification : public Resource { + public: + explicit PlatformVerification(const InstanceHandle& instance); + virtual ~PlatformVerification(); + + int32_t CanChallengePlatform( + const CompletionCallbackWithOutput& callback); + int32_t ChallengePlatform(const Var& service_id, + const Var& challenge, + Var* signed_data, + Var* signed_data_signature, + Var* platform_key_certificate, + const CompletionCallback& callback); +}; + +} // namespace pp + +#endif // PPAPI_CPP_PRIVATE_PLATFORM_VERIFICATION_H_ diff --git a/chromium/ppapi/cpp/tcp_socket.cc b/chromium/ppapi/cpp/tcp_socket.cc index f0002fa5545..ab08ff3626c 100644 --- a/chromium/ppapi/cpp/tcp_socket.cc +++ b/chromium/ppapi/cpp/tcp_socket.cc @@ -17,13 +17,20 @@ template <> const char* interface_name() { return PPB_TCPSOCKET_INTERFACE_1_0; } +template <> const char* interface_name() { + return PPB_TCPSOCKET_INTERFACE_1_1; +} + } // namespace TCPSocket::TCPSocket() { } TCPSocket::TCPSocket(const InstanceHandle& instance) { - if (has_interface()) { + if (has_interface()) { + PassRefFromConstructor(get_interface()->Create( + instance.pp_instance())); + } else if (has_interface()) { PassRefFromConstructor(get_interface()->Create( instance.pp_instance())); } @@ -46,11 +53,25 @@ TCPSocket& TCPSocket::operator=(const TCPSocket& other) { // static bool TCPSocket::IsAvailable() { - return has_interface(); + return has_interface() || + has_interface(); +} + +int32_t TCPSocket::Bind(const NetAddress& addr, + const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->Bind( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); } int32_t TCPSocket::Connect(const NetAddress& addr, const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->Connect( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } if (has_interface()) { return get_interface()->Connect( pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); @@ -59,6 +80,11 @@ int32_t TCPSocket::Connect(const NetAddress& addr, } NetAddress TCPSocket::GetLocalAddress() const { + if (has_interface()) { + return NetAddress( + PASS_REF, + get_interface()->GetLocalAddress(pp_resource())); + } if (has_interface()) { return NetAddress( PASS_REF, @@ -68,6 +94,11 @@ NetAddress TCPSocket::GetLocalAddress() const { } NetAddress TCPSocket::GetRemoteAddress() const { + if (has_interface()) { + return NetAddress( + PASS_REF, + get_interface()->GetRemoteAddress(pp_resource())); + } if (has_interface()) { return NetAddress( PASS_REF, @@ -79,6 +110,11 @@ NetAddress TCPSocket::GetRemoteAddress() const { int32_t TCPSocket::Read(char* buffer, int32_t bytes_to_read, const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->Read( + pp_resource(), buffer, bytes_to_read, + callback.pp_completion_callback()); + } if (has_interface()) { return get_interface()->Read( pp_resource(), buffer, bytes_to_read, @@ -90,6 +126,11 @@ int32_t TCPSocket::Read(char* buffer, int32_t TCPSocket::Write(const char* buffer, int32_t bytes_to_write, const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->Write( + pp_resource(), buffer, bytes_to_write, + callback.pp_completion_callback()); + } if (has_interface()) { return get_interface()->Write( pp_resource(), buffer, bytes_to_write, @@ -98,14 +139,39 @@ int32_t TCPSocket::Write(const char* buffer, return callback.MayForce(PP_ERROR_NOINTERFACE); } +int32_t TCPSocket::Listen(int32_t backlog, + const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->Listen( + pp_resource(), backlog, callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t TCPSocket::Accept( + const CompletionCallbackWithOutput& callback) { + if (has_interface()) { + return get_interface()->Accept( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + void TCPSocket::Close() { - if (has_interface()) + if (has_interface()) { + get_interface()->Close(pp_resource()); + } else if (has_interface()) { get_interface()->Close(pp_resource()); + } } int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback) { + if (has_interface()) { + return get_interface()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } if (has_interface()) { return get_interface()->SetOption( pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); diff --git a/chromium/ppapi/cpp/tcp_socket.h b/chromium/ppapi/cpp/tcp_socket.h index 5a5e0f4149e..578e08fac22 100644 --- a/chromium/ppapi/cpp/tcp_socket.h +++ b/chromium/ppapi/cpp/tcp_socket.h @@ -15,10 +15,13 @@ namespace pp { class CompletionCallback; class InstanceHandle; +template class CompletionCallbackWithOutput; + /// The TCPSocket class provides TCP socket operations. /// /// Permissions: Apps permission socket with subrule -/// tcp-connect is required for Connect(). +/// tcp-connect is required for Connect(); subrule +/// tcp-listen is required for Listen(). /// For more details about network communication permissions, please see: /// http://developer.chrome.com/apps/app_network.html class TCPSocket : public Resource { @@ -60,7 +63,20 @@ class TCPSocket : public Resource { /// @return true if the interface is available, false otherwise. static bool IsAvailable(); - /// Connects the socket to the given address. + /// Binds the socket to the given address. The socket must not be bound. + /// + /// @param[in] addr A NetAddress object. + /// @param[in] callback A CompletionCallback to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from pp_errors.h, + /// including (but not limited to): + /// - PP_ERROR_ADDRESS_IN_USE: the address is already in use. + /// - PP_ERROR_ADDRESS_INVALID: the address is invalid. + int32_t Bind(const NetAddress& addr, const CompletionCallback& callback); + + /// Connects the socket to the given address. The socket must not be + /// listening. Binding the socket beforehand is optional. /// /// @param[in] addr A NetAddress object. /// @param[in] callback A CompletionCallback to be called upon @@ -77,10 +93,14 @@ class TCPSocket : public Resource { /// - PP_ERROR_CONNECTION_FAILED: the connection attempt failed. /// - PP_ERROR_CONNECTION_TIMEDOUT: the connection attempt timed /// out. - int32_t Connect(const NetAddress& addr, - const CompletionCallback& callback); + /// + /// Since version 1.1, if the socket is listening/connected or has a pending + /// listen/connect request, Connect() will fail without starting + /// a connection attempt. Otherwise, any failure during the connection attempt + /// will cause the socket to be closed. + int32_t Connect(const NetAddress& addr, const CompletionCallback& callback); - /// Gets the local address of the socket, if it is connected. + /// Gets the local address of the socket, if it is bound. /// /// @return A NetAddress object. The object will be null /// (i.e., is_null() returns true) on failure. @@ -135,11 +155,38 @@ class TCPSocket : public Resource { int32_t bytes_to_write, const CompletionCallback& callback); - /// Cancels all pending reads and writes and disconnects the socket. Any - /// pending callbacks will still run, reporting PP_ERROR_ABORTED - /// if pending IO was interrupted. After a call to this method, no output - /// buffer pointers passed into previous Read() calls will be - /// accessed. It is not valid to call Connect() again. + /// Starts listening. The socket must be bound and not connected. + /// + /// @param[in] backlog A hint to determine the maximum length to which the + /// queue of pending connections may grow. + /// @param[in] callback A CompletionCallback to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from pp_errors.h, + /// including (but not limited to): + /// - PP_ERROR_NOACCESS: the caller doesn't have required + /// permissions. + /// - PP_ERROR_ADDRESS_IN_USE: Another socket is already + /// listening on the same port. + int32_t Listen(int32_t backlog, + const CompletionCallback& callback); + + /// Accepts a connection. The socket must be listening. + /// + /// @param[in] callback A CompletionCallbackWithOutput to be + /// called upon completion. + /// + /// @return An int32_t containing an error code from pp_errors.h, + /// including (but not limited to): + /// - PP_ERROR_CONNECTION_ABORTED: A connection has been aborted. + int32_t Accept(const CompletionCallbackWithOutput& callback); + + /// Cancels all pending operations and closes the socket. Any pending + /// callbacks will still run, reporting PP_ERROR_ABORTED if + /// pending IO was interrupted. After a call to this method, no output buffer + /// pointers passed into previous Read() or Accept() + /// calls will be accessed. It is not valid to call Connect() or + /// Listen() again. /// /// The socket is implicitly closed if it is destroyed, so you are not /// required to call this method. @@ -155,7 +202,6 @@ class TCPSocket : public Resource { /// completion. /// /// @return An int32_t containing an error code from pp_errors.h. - //// int32_t SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback); -- cgit v1.2.1