diff options
author | Andras Becsi <andras.becsi@digia.com> | 2013-12-11 21:33:03 +0100 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-12-13 12:34:07 +0100 |
commit | f2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch) | |
tree | 0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/ppapi/cpp | |
parent | 5362912cdb5eea702b68ebe23702468d17c3017a (diff) | |
download | qtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz |
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/ppapi/cpp')
21 files changed, 523 insertions, 233 deletions
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<PPB_Audio_1_0>() { return PPB_AUDIO_INTERFACE_1_0; } +template <> const char* interface_name<PPB_Audio_1_1>() { + 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<PPB_Audio_1_1>()) { + PassRefFromConstructor(get_interface<PPB_Audio_1_1>()->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<PPB_Audio_1_0>()) { PassRefFromConstructor(get_interface<PPB_Audio_1_0>()->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<PPB_Audio_1_0>() && - get_interface<PPB_Audio_1_0>()->StartPlayback(pp_resource()); + if (has_interface<PPB_Audio_1_1>() && !use_1_0_interface_) { + return PP_ToBool(get_interface<PPB_Audio_1_1>()->StartPlayback( + pp_resource())); + } + if (has_interface<PPB_Audio_1_0>()) { + return PP_ToBool(get_interface<PPB_Audio_1_0>()->StartPlayback( + pp_resource())); + } + return false; } bool Audio::StopPlayback() { - return has_interface<PPB_Audio_1_0>() && - get_interface<PPB_Audio_1_0>()->StopPlayback(pp_resource()); + if (has_interface<PPB_Audio_1_1>() && !use_1_0_interface_) { + return PP_ToBool(get_interface<PPB_Audio_1_1>()->StopPlayback( + pp_resource())); + } + if (has_interface<PPB_Audio_1_0>()) { + return PP_ToBool(get_interface<PPB_Audio_1_0>()->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 <code>AudioConfig</code> containing the audio config /// resource. - // /// @param[in] callback A <code>PPB_Audio_Callback</code> 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 <code>AudioConfig</code> containing the audio config + /// resource. + /// @param[in] callback A <code>PPB_Audio_Callback_1_0</code> 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 <code>PPB_AudioConfig</code> /// 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 <code>FileSystem</code> 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 <code>FileRef</code>. 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<PPB_NetworkList_1_0>() { + 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<PPB_NetworkList_1_0>(); +} + +uint32_t NetworkList::GetCount() const { + if (!has_interface<PPB_NetworkList_1_0>()) + return 0; + return get_interface<PPB_NetworkList_1_0>()->GetCount(pp_resource()); +} + +std::string NetworkList::GetName(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_1_0>()->GetName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +PP_NetworkList_Type NetworkList::GetType(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_NETWORKLIST_TYPE_ETHERNET; + return get_interface<PPB_NetworkList_1_0>()->GetType( + pp_resource(), index); +} + +PP_NetworkList_State NetworkList::GetState(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_NETWORKLIST_STATE_DOWN; + return get_interface<PPB_NetworkList_1_0>()->GetState( + pp_resource(), index); +} + +int32_t NetworkList::GetIpAddresses( + uint32_t index, + std::vector<NetAddress>* addresses) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return PP_ERROR_NOINTERFACE; + if (!addresses) + return PP_ERROR_BADARGUMENT; + + ResourceArrayOutputAdapter<NetAddress> adapter(addresses); + return get_interface<PPB_NetworkList_1_0>()->GetIpAddresses( + pp_resource(), index, adapter.pp_array_output()); +} + +std::string NetworkList::GetDisplayName(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return std::string(); + Var result(PASS_REF, + get_interface<PPB_NetworkList_1_0>()->GetDisplayName( + pp_resource(), index)); + return result.is_string() ? result.AsString() : std::string(); +} + +uint32_t NetworkList::GetMTU(uint32_t index) const { + if (!has_interface<PPB_NetworkList_1_0>()) + return 0; + return get_interface<PPB_NetworkList_1_0>()->GetMTU( + pp_resource(), index); +} + +} // namespace pp diff --git a/chromium/ppapi/cpp/private/network_list_private.h b/chromium/ppapi/cpp/network_list.h index 31cd9b598b8..d479129442e 100644 --- a/chromium/ppapi/cpp/private/network_list_private.h +++ b/chromium/ppapi/cpp/network_list.h @@ -2,22 +2,24 @@ // 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_ +#ifndef PPAPI_CPP_NETWORK_LIST_H_ +#define PPAPI_CPP_NETWORK_LIST_H_ #include <string> #include <vector> -#include "ppapi/c/private/ppb_network_list_private.h" +#include "ppapi/c/ppb_network_list.h" #include "ppapi/cpp/pass_ref.h" #include "ppapi/cpp/resource.h" namespace pp { -class NetworkListPrivate : public Resource { +class NetAddress; + +class NetworkList : public Resource { public: - NetworkListPrivate(); - NetworkListPrivate(PassRef, PP_Resource resource); + NetworkList(); + NetworkList(PassRef, PP_Resource resource); /// Returns true if the required interface is available. static bool IsAvailable(); @@ -32,17 +34,17 @@ class NetworkListPrivate : public Resource { /// @return Returns the type of the network interface with the /// specified <code>index</code>. - PP_NetworkListType_Private GetType(uint32_t index) const; + PP_NetworkList_Type GetType(uint32_t index) const; /// @return Returns the current state of the network interface with /// the specified <code>index</code>. - PP_NetworkListState_Private GetState(uint32_t index) const; + PP_NetworkList_State GetState(uint32_t index) const; /// Gets the list of IP addresses for the network interface with the /// specified <code>index</code> and stores them in /// <code>addresses</code>. - void GetIpAddresses(uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const; + int32_t GetIpAddresses(uint32_t index, + std::vector<NetAddress>* addresses) const; /// @return Returns the display name for the network interface with /// the specified <code>index</code>. @@ -55,4 +57,4 @@ class NetworkListPrivate : public Resource { } // namespace pp -#endif // PPAPI_CPP_PRIVATE_NETWORK_LIST_PRIVATE_H_ +#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<PPB_NetworkMonitor_1_0>() { + return PPB_NETWORKMONITOR_INTERFACE_1_0; +} + +} // namespace + +NetworkMonitor::NetworkMonitor(const InstanceHandle& instance) { + if (has_interface<PPB_NetworkMonitor_1_0>()) { + PassRefFromConstructor(get_interface<PPB_NetworkMonitor_1_0>()->Create( + instance.pp_instance())); + } +} + +int32_t NetworkMonitor::UpdateNetworkList( + const CompletionCallbackWithOutput<NetworkList>& callback) { + if (has_interface<PPB_NetworkMonitor_1_0>()) { + return get_interface<PPB_NetworkMonitor_1_0>()->UpdateNetworkList( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +// static +bool NetworkMonitor::IsAvailable() { + return has_interface<PPB_NetworkMonitor_1_0>(); +} + +} // 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 <typename T> class CompletionCallbackWithOutput; + +class NetworkMonitor : public Resource { + public: + explicit NetworkMonitor(const InstanceHandle& instance); + + int32_t UpdateNetworkList( + const CompletionCallbackWithOutput<NetworkList>& 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<Var> { } }; +// 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<bool> { + // 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<ContentDecryptor_Private*>(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<ContentDecryptor_Private*>(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<PPB_ContentDecryptor_Private>()) { - pp::Var key_system_var(key_system); - pp::Var session_id_var(session_id); - - get_interface<PPB_ContentDecryptor_Private>()->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<PPB_ContentDecryptor_Private>()) { 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<PPB_NetworkList_Private>() { - 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<PPB_NetworkList_Private>(); -} - -uint32_t NetworkListPrivate::GetCount() const { - if (!has_interface<PPB_NetworkList_Private>()) - return 0; - return get_interface<PPB_NetworkList_Private>()->GetCount(pp_resource()); -} - -std::string NetworkListPrivate::GetName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return std::string(); - Var result(PASS_REF, - get_interface<PPB_NetworkList_Private>()->GetName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -PP_NetworkListType_Private NetworkListPrivate::GetType(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return PP_NETWORKLIST_ETHERNET; - return get_interface<PPB_NetworkList_Private>()->GetType( - pp_resource(), index); -} - -PP_NetworkListState_Private NetworkListPrivate::GetState(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return PP_NETWORKLIST_DOWN; - return get_interface<PPB_NetworkList_Private>()->GetState( - pp_resource(), index); -} - -void NetworkListPrivate::GetIpAddresses( - uint32_t index, - std::vector<PP_NetAddress_Private>* addresses) const { - if (!has_interface<PPB_NetworkList_Private>()) - return; - - // Most network interfaces don't have more than 3 network - // interfaces. - addresses->resize(3); - - int32_t result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - - if (result < 0) { - addresses->resize(0); - return; - } - - if (result <= static_cast<int32_t>(addresses->size())) { - addresses->resize(result); - return; - } - - addresses->resize(result); - result = get_interface<PPB_NetworkList_Private>()->GetIpAddresses( - pp_resource(), index, &addresses->front(), addresses->size()); - if (result < 0) { - addresses->resize(0); - } else if (result < static_cast<int32_t>(addresses->size())) { - addresses->resize(result); - } -} - -std::string NetworkListPrivate::GetDisplayName(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return std::string(); - Var result(PASS_REF, - get_interface<PPB_NetworkList_Private>()->GetDisplayName( - pp_resource(), index)); - return result.is_string() ? result.AsString() : std::string(); -} - -uint32_t NetworkListPrivate::GetMTU(uint32_t index) const { - if (!has_interface<PPB_NetworkList_Private>()) - return 0; - return get_interface<PPB_NetworkList_Private>()->GetMTU( - pp_resource(), index); -} - -} // namespace pp 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<PPB_NetworkMonitor_Private>() { - return PPB_NETWORKMONITOR_PRIVATE_INTERFACE; -} - -} // namespace - -NetworkMonitorPrivate::NetworkMonitorPrivate( - const InstanceHandle& instance, - PPB_NetworkMonitor_Callback callback, - void* user_data) { - if (has_interface<PPB_NetworkMonitor_Private>()) { - PassRefFromConstructor(get_interface<PPB_NetworkMonitor_Private>()->Create( - instance.pp_instance(), callback, user_data)); - } -} - -// static -bool NetworkMonitorPrivate::IsAvailable() { - return has_interface<PPB_NetworkMonitor_Private>(); -} - -} // 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<PPB_PDF>()) { + return Var(PASS_REF, + get_interface<PPB_PDF>()->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<PPB_PlatformVerification_Private_0_1>() { + return PPB_PLATFORMVERIFICATION_PRIVATE_INTERFACE_0_1; +} + +inline bool HasInterface() { + return has_interface<PPB_PlatformVerification_Private_0_1>(); +} + +inline const PPB_PlatformVerification_Private_0_1* GetInterface() { + return get_interface<PPB_PlatformVerification_Private_0_1>(); +} + +} // namespace + +PlatformVerification::PlatformVerification(const InstanceHandle& instance) { + if (HasInterface()) + PassRefFromConstructor(GetInterface()->Create(instance.pp_instance())); +} + +PlatformVerification::~PlatformVerification() {} + +int32_t PlatformVerification::CanChallengePlatform( + const CompletionCallbackWithOutput<bool>& 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<PP_Var*>(&signed_data->pp_var()), + const_cast<PP_Var*>(&signed_data_signature->pp_var()), + const_cast<PP_Var*>(&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<bool>& 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<PPB_TCPSocket_1_0>() { return PPB_TCPSOCKET_INTERFACE_1_0; } +template <> const char* interface_name<PPB_TCPSocket_1_1>() { + return PPB_TCPSOCKET_INTERFACE_1_1; +} + } // namespace TCPSocket::TCPSocket() { } TCPSocket::TCPSocket(const InstanceHandle& instance) { - if (has_interface<PPB_TCPSocket_1_0>()) { + if (has_interface<PPB_TCPSocket_1_1>()) { + PassRefFromConstructor(get_interface<PPB_TCPSocket_1_1>()->Create( + instance.pp_instance())); + } else if (has_interface<PPB_TCPSocket_1_0>()) { PassRefFromConstructor(get_interface<PPB_TCPSocket_1_0>()->Create( instance.pp_instance())); } @@ -46,11 +53,25 @@ TCPSocket& TCPSocket::operator=(const TCPSocket& other) { // static bool TCPSocket::IsAvailable() { - return has_interface<PPB_TCPSocket_1_0>(); + return has_interface<PPB_TCPSocket_1_1>() || + has_interface<PPB_TCPSocket_1_0>(); +} + +int32_t TCPSocket::Bind(const NetAddress& addr, + const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->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<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Connect( + pp_resource(), addr.pp_resource(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->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<PPB_TCPSocket_1_1>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_1>()->GetLocalAddress(pp_resource())); + } if (has_interface<PPB_TCPSocket_1_0>()) { return NetAddress( PASS_REF, @@ -68,6 +94,11 @@ NetAddress TCPSocket::GetLocalAddress() const { } NetAddress TCPSocket::GetRemoteAddress() const { + if (has_interface<PPB_TCPSocket_1_1>()) { + return NetAddress( + PASS_REF, + get_interface<PPB_TCPSocket_1_1>()->GetRemoteAddress(pp_resource())); + } if (has_interface<PPB_TCPSocket_1_0>()) { 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<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Read( + pp_resource(), buffer, bytes_to_read, + callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->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<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Write( + pp_resource(), buffer, bytes_to_write, + callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->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<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Listen( + pp_resource(), backlog, callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t TCPSocket::Accept( + const CompletionCallbackWithOutput<TCPSocket>& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->Accept( + pp_resource(), callback.output(), callback.pp_completion_callback()); + } + return callback.MayForce(PP_ERROR_NOINTERFACE); +} + void TCPSocket::Close() { - if (has_interface<PPB_TCPSocket_1_0>()) + if (has_interface<PPB_TCPSocket_1_1>()) { + get_interface<PPB_TCPSocket_1_1>()->Close(pp_resource()); + } else if (has_interface<PPB_TCPSocket_1_0>()) { get_interface<PPB_TCPSocket_1_0>()->Close(pp_resource()); + } } int32_t TCPSocket::SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback) { + if (has_interface<PPB_TCPSocket_1_1>()) { + return get_interface<PPB_TCPSocket_1_1>()->SetOption( + pp_resource(), name, value.pp_var(), callback.pp_completion_callback()); + } if (has_interface<PPB_TCPSocket_1_0>()) { return get_interface<PPB_TCPSocket_1_0>()->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 <typename T> class CompletionCallbackWithOutput; + /// The <code>TCPSocket</code> class provides TCP socket operations. /// /// Permissions: Apps permission <code>socket</code> with subrule -/// <code>tcp-connect</code> is required for <code>Connect()</code>. +/// <code>tcp-connect</code> is required for <code>Connect()</code>; subrule +/// <code>tcp-listen</code> is required for <code>Listen()</code>. /// 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 <code>NetAddress</code> object. + /// @param[in] callback A <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>, + /// including (but not limited to): + /// - <code>PP_ERROR_ADDRESS_IN_USE</code>: the address is already in use. + /// - <code>PP_ERROR_ADDRESS_INVALID</code>: 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 <code>NetAddress</code> object. /// @param[in] callback A <code>CompletionCallback</code> to be called upon @@ -77,10 +93,14 @@ class TCPSocket : public Resource { /// - <code>PP_ERROR_CONNECTION_FAILED</code>: the connection attempt failed. /// - <code>PP_ERROR_CONNECTION_TIMEDOUT</code>: 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, <code>Connect()</code> 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 <code>NetAddress</code> 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 <code>PP_ERROR_ABORTED</code> - /// if pending IO was interrupted. After a call to this method, no output - /// buffer pointers passed into previous <code>Read()</code> calls will be - /// accessed. It is not valid to call <code>Connect()</code> 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 <code>CompletionCallback</code> to be called upon + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>, + /// including (but not limited to): + /// - <code>PP_ERROR_NOACCESS</code>: the caller doesn't have required + /// permissions. + /// - <code>PP_ERROR_ADDRESS_IN_USE</code>: 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 <code>CompletionCallbackWithOutput</code> to be + /// called upon completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>, + /// including (but not limited to): + /// - <code>PP_ERROR_CONNECTION_ABORTED</code>: A connection has been aborted. + int32_t Accept(const CompletionCallbackWithOutput<TCPSocket>& callback); + + /// Cancels all pending operations and closes the socket. Any pending + /// callbacks will still run, reporting <code>PP_ERROR_ABORTED</code> if + /// pending IO was interrupted. After a call to this method, no output buffer + /// pointers passed into previous <code>Read()</code> or <code>Accept()</code> + /// calls will be accessed. It is not valid to call <code>Connect()</code> or + /// <code>Listen()</code> 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 <code>pp_errors.h</code>. - //// int32_t SetOption(PP_TCPSocket_Option name, const Var& value, const CompletionCallback& callback); |