summaryrefslogtreecommitdiff
path: root/chromium/ppapi/cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/ppapi/cpp
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
downloadqtwebengine-chromium-399c965b6064c440ddcf4015f5f8e9d131c7a0a6.tar.gz
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/ppapi/cpp')
-rw-r--r--chromium/ppapi/cpp/graphics_2d.cc15
-rw-r--r--chromium/ppapi/cpp/graphics_2d.h3
-rw-r--r--chromium/ppapi/cpp/vpn_provider.cc68
-rw-r--r--chromium/ppapi/cpp/vpn_provider.h135
4 files changed, 221 insertions, 0 deletions
diff --git a/chromium/ppapi/cpp/graphics_2d.cc b/chromium/ppapi/cpp/graphics_2d.cc
index 3a766c83546..d196cabd583 100644
--- a/chromium/ppapi/cpp/graphics_2d.cc
+++ b/chromium/ppapi/cpp/graphics_2d.cc
@@ -26,6 +26,11 @@ template <> const char* interface_name<PPB_Graphics2D_1_1>() {
return PPB_GRAPHICS_2D_INTERFACE_1_1;
}
+template <> const char* interface_name<PPB_Graphics2D_1_2>() {
+ return PPB_GRAPHICS_2D_INTERFACE_1_2;
+}
+
+
} // namespace
Graphics2D::Graphics2D() : Resource() {
@@ -152,4 +157,14 @@ float Graphics2D::GetScale() {
return get_interface<PPB_Graphics2D_1_1>()->GetScale(pp_resource());
}
+bool Graphics2D::SetLayerTransform(float scale,
+ const Point& origin,
+ const Point& translate) {
+ if (!has_interface<PPB_Graphics2D_1_2>())
+ return false;
+ return PP_ToBool(get_interface<PPB_Graphics2D_1_2>()->SetLayerTransform(
+ pp_resource(), scale, &origin.pp_point(), &translate.pp_point()));
+}
+
+
} // namespace pp
diff --git a/chromium/ppapi/cpp/graphics_2d.h b/chromium/ppapi/cpp/graphics_2d.h
index c6a23905d6f..86b89c77efb 100644
--- a/chromium/ppapi/cpp/graphics_2d.h
+++ b/chromium/ppapi/cpp/graphics_2d.h
@@ -284,6 +284,9 @@ class Graphics2D : public Resource {
/// is 1.0.
float GetScale();
+ bool SetLayerTransform(float scale,
+ const Point& origin,
+ const Point& translate);
private:
Size size_;
};
diff --git a/chromium/ppapi/cpp/vpn_provider.cc b/chromium/ppapi/cpp/vpn_provider.cc
new file mode 100644
index 00000000000..d44b7bc94d4
--- /dev/null
+++ b/chromium/ppapi/cpp/vpn_provider.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 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/vpn_provider.h"
+
+#include "ppapi/c/ppb_vpn_provider.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/module.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var_array.h"
+
+namespace pp {
+
+namespace {
+
+template <>
+const char* interface_name<PPB_VpnProvider_0_1>() {
+ return PPB_VPNPROVIDER_INTERFACE_0_1;
+}
+} // namespace
+
+VpnProvider::VpnProvider(const InstanceHandle& instance)
+ : associated_instance_(instance) {
+ if (has_interface<PPB_VpnProvider_0_1>()) {
+ PassRefFromConstructor(get_interface<PPB_VpnProvider_0_1>()->Create(
+ associated_instance_.pp_instance()));
+ }
+}
+
+VpnProvider::~VpnProvider() {}
+
+// static
+bool VpnProvider::IsAvailable() {
+ return has_interface<PPB_VpnProvider_0_1>();
+}
+
+int32_t VpnProvider::Bind(const Var& configuration_id,
+ const Var& configuration_name,
+ const CompletionCallback& callback) {
+ if (has_interface<PPB_VpnProvider_0_1>()) {
+ return get_interface<PPB_VpnProvider_0_1>()->Bind(
+ pp_resource(), configuration_id.pp_var(), configuration_name.pp_var(),
+ callback.pp_completion_callback());
+ }
+ return PP_ERROR_NOINTERFACE;
+}
+
+int32_t VpnProvider::SendPacket(const Var& packet,
+ const CompletionCallback& callback) {
+ if (has_interface<PPB_VpnProvider_0_1>()) {
+ return get_interface<PPB_VpnProvider_0_1>()->SendPacket(
+ pp_resource(), packet.pp_var(), callback.pp_completion_callback());
+ }
+ return PP_ERROR_NOINTERFACE;
+}
+
+int32_t VpnProvider::ReceivePacket(
+ const CompletionCallbackWithOutput<Var>& callback) {
+ if (has_interface<PPB_VpnProvider_0_1>()) {
+ return get_interface<PPB_VpnProvider_0_1>()->ReceivePacket(
+ pp_resource(), callback.output(), callback.pp_completion_callback());
+ }
+ return PP_ERROR_NOINTERFACE;
+}
+
+} // namespace pp
diff --git a/chromium/ppapi/cpp/vpn_provider.h b/chromium/ppapi/cpp/vpn_provider.h
new file mode 100644
index 00000000000..9d94981e586
--- /dev/null
+++ b/chromium/ppapi/cpp/vpn_provider.h
@@ -0,0 +1,135 @@
+// Copyright 2016 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_VPN_PROVIDER_H_
+#define PPAPI_CPP_VPN_PROVIDER_H_
+
+#include <string>
+
+#include "ppapi/c/ppb_vpn_provider.h"
+#include "ppapi/cpp/completion_callback.h"
+
+namespace pp {
+
+class InstanceHandle;
+
+/// @file
+/// This file defines the VpnProvider interface providing a way to implement a
+/// VPN client.
+/// Important: This API is available only on Chrome OS.
+
+/// The <code>VpnProvider</code> class enhances the
+/// <code>chrome.vpnProvider</code> JavaScript API by providing a high
+/// performance path for packet handling.
+///
+/// Permissions: Apps permission <code>vpnProvider</code> is required for
+/// <code>VpnProvider.Bind()</code>.
+///
+/// Typical usage:
+/// - Create a <code>VpnProvider</code> instance.
+/// - Register the callback for <code>VpnProvider.ReceivePacket()</code>.
+/// - In the extension follow the usual workflow for configuring a VPN
+/// connection via the <code>chrome.vpnProvider</code> API until the step for
+/// notifying the connection state as "connected".
+/// - Bind to the previously created connection using
+/// <code>VpnProvider.Bind()</code>.
+/// - Notify the connection state as "connected" from JavaScript using
+/// <code>chrome.vpnProvider.notifyConnectionStateChanged</code>.
+/// - When the steps above are completed without errors, a virtual tunnel is
+/// created to the network stack of Chrome OS. IP packets can be sent through
+/// the tunnel using <code>VpnProvider.SendPacket()</code> and any packets
+/// originating on the Chrome OS device will be received using the callback
+/// registered for <code>VpnProvider.ReceivePacket()</code>.
+/// - When the user disconnects from the VPN configuration or there is an error
+/// the extension will be notfied via
+/// <code>chrome.vpnProvider.onPlatformMessage</code>.
+class VpnProvider : public Resource {
+ public:
+ /// Constructs a VpnProvider object.
+ ///
+ /// @param[in] instance The instance with which this resource will be
+ /// associated.
+ explicit VpnProvider(const InstanceHandle& instance);
+
+ /// Destructs a VpnProvider object.
+ virtual ~VpnProvider();
+
+ /// Static function for determining whether the browser supports the
+ /// <code>VpnProvider</code> interface.
+ ///
+ /// @return true if the interface is available, false otherwise.
+ static bool IsAvailable();
+
+ /// Binds to an existing configuration created from JavaScript by
+ /// <code>chrome.vpnProvider.createConfig</code>. All packets will be routed
+ /// via <code>SendPacket</code> and <code>ReceivePacket</code>. The user
+ /// should register the callback for <code>ReceivePacket</code> before calling
+ /// <code>Bind()</code>.
+ ///
+ /// @param[in] configuration_id The configuration id from the callback of
+ /// <code>chrome.vpnProvider.createConfig</code>. This <code>Var</code> must
+ /// be of string type.
+ ///
+ /// @param[in] configuration_name The configuration name as defined by the
+ /// user when calling <code>chrome.vpnProvider.createConfig</code>. This
+ /// <code>Var</code> must be of string type.
+ ///
+ /// @param[in] callback A <code>CompletionCallback</code> to be called on
+ /// completion.
+ ///
+ /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ /// Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
+ /// <code>Bind()</code> has not completed.
+ /// Returns <code>PP_ERROR_BADARGUMENT</code> if the <code>Var</code> type of
+ /// either <code>configuration_id</code> or <code>configuration_name</code> is
+ /// not of string type.
+ /// Returns <code>PP_ERROR_NOACCESS</code> if the caller does the have the
+ /// required "vpnProvider" permission.
+ /// Returns <code>PP_ERROR_FAILED</code> if <code>connection_id</code> and
+ /// <code>connection_name</code> could not be matched with the existing
+ /// connection, or if the plugin originates from a different extension than
+ /// the one that created the connection.
+ int32_t Bind(const Var& configuration_id,
+ const Var& configuration_name,
+ const CompletionCallback& callback);
+
+ /// Sends an IP packet through the tunnel created for the VPN session. This
+ /// will succeed only when the VPN session is owned by the module and
+ /// connection is bound.
+ ///
+ /// @param[in] packet IP packet to be sent to the platform. The
+ /// <code>Var</code> must be of ArrayBuffer type.
+ ///
+ /// @param[in] callback A <code>CompletionCallback</code> to be called on
+ /// completion.
+ ///
+ /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ /// Returns <code>PP_ERROR_FAILED</code> if the connection is not bound.
+ /// Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
+ /// <code>SendPacket()</code> has not completed.
+ /// Returns <code>PP_ERROR_BADARGUMENT</code> if the <code>Var</code> type of
+ /// <code>packet</code> is not of ArrayBuffer type.
+ int32_t SendPacket(const Var& packet, const CompletionCallback& callback);
+
+ /// Receives an IP packet from the tunnel for the VPN session. This function
+ /// only returns a single packet. That is, this function must be called at
+ /// least N times to receive N packets, no matter the size of each packet. The
+ /// callback should be registered before calling <code>Bind()</code>.
+ ///
+ /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
+ /// called upon completion of ReceivePacket. It will be passed an ArrayBuffer
+ /// type <code>Var</code> containing an IP packet to be sent to the platform.
+ ///
+ /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
+ /// Returns <code>PP_ERROR_INPROGRESS</code> if a previous call to
+ /// <code>ReceivePacket()</code> has not completed.
+ int32_t ReceivePacket(const CompletionCallbackWithOutput<Var>& callback);
+
+ private:
+ InstanceHandle associated_instance_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_VPN_PROVIDER_H_