summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authordmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-24 21:05:36 +0000
committerdmichael@chromium.org <dmichael@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-24 21:05:36 +0000
commit226dea4944e6ea35b68b40c6d6dab62c370ec410 (patch)
treea3d0882fbb08ce7cbbb90d0e1132ccb43a562b16 /ppapi
parent06dd2317c3d2ec4e4b909906c9fd00a19b321c7f (diff)
downloadchromium_src-226dea4944e6ea35b68b40c6d6dab62c370ec410.zip
chromium_src-226dea4944e6ea35b68b40c6d6dab62c370ec410.tar.gz
chromium_src-226dea4944e6ea35b68b40c6d6dab62c370ec410.tar.bz2
PPAPI: Introduce PPB_NetworkProxy_Dev
This adds support for PPB_NetworkProxy_Dev for out-of-process and NaCl (when using --enable-nacl). Work still to do in future CLs: - Add permissions checking - Translate appropriate error codes from net_errors.h BUG=247225 R=jam@chromium.org, palmer@chromium.org, yzshen@chromium.org Review URL: https://codereview.chromium.org/16819002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/dev/ppb_network_proxy_dev.idl27
-rw-r--r--ppapi/c/dev/ppb_network_proxy_dev.h49
-rw-r--r--ppapi/cpp/dev/network_proxy_dev.cc38
-rw-r--r--ppapi/cpp/dev/network_proxy_dev.h28
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c22
-rw-r--r--ppapi/ppapi_proxy.gypi2
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/ppapi_sources.gypi5
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/network_proxy_resource.cc66
-rw-r--r--ppapi/proxy/network_proxy_resource.h45
-rw-r--r--ppapi/proxy/ppapi_messages.h11
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc10
-rw-r--r--ppapi/shared_impl/resource.h8
-rw-r--r--ppapi/shared_impl/singleton_resource_id.h1
-rw-r--r--ppapi/tests/test_network_proxy.cc77
-rw-r--r--ppapi/tests/test_network_proxy.h23
-rw-r--r--ppapi/thunk/interfaces_ppb_public_dev.h2
-rw-r--r--ppapi/thunk/ppb_network_proxy_api.h38
-rw-r--r--ppapi/thunk/ppb_network_proxy_dev_thunk.cc47
20 files changed, 497 insertions, 5 deletions
diff --git a/ppapi/api/dev/ppb_network_proxy_dev.idl b/ppapi/api/dev/ppb_network_proxy_dev.idl
new file mode 100644
index 0000000..d86836f
--- /dev/null
+++ b/ppapi/api/dev/ppb_network_proxy_dev.idl
@@ -0,0 +1,27 @@
+/* Copyright (c) 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.
+ */
+
+/**
+ * This file defines the <code>PPB_NetworkProxy_Dev</code> interface.
+ */
+
+[generate_thunk]
+
+label Chrome {
+ M29 = 0.1
+};
+
+[singleton]
+interface PPB_NetworkProxy_Dev {
+ /**
+ * Retrieves the proxy that will be used for the given URL. The result will
+ * be a string in PAC format. For more details about PAC format, please see
+ * http://en.wikipedia.org/wiki/Proxy_auto-config
+ */
+ int32_t GetProxyForURL([in] PP_Instance instance,
+ [in] PP_Var url,
+ [out] PP_Var proxy_string,
+ [in] PP_CompletionCallback callback);
+};
diff --git a/ppapi/c/dev/ppb_network_proxy_dev.h b/ppapi/c/dev/ppb_network_proxy_dev.h
new file mode 100644
index 0000000..debda0f
--- /dev/null
+++ b/ppapi/c/dev/ppb_network_proxy_dev.h
@@ -0,0 +1,49 @@
+/* Copyright (c) 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.
+ */
+
+/* From dev/ppb_network_proxy_dev.idl modified Thu Jun 6 10:44:17 2013. */
+
+#ifndef PPAPI_C_DEV_PPB_NETWORK_PROXY_DEV_H_
+#define PPAPI_C_DEV_PPB_NETWORK_PROXY_DEV_H_
+
+#include "ppapi/c/pp_bool.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/pp_stdint.h"
+#include "ppapi/c/pp_var.h"
+
+#define PPB_NETWORKPROXY_DEV_INTERFACE_0_1 "PPB_NetworkProxy(Dev);0.1"
+#define PPB_NETWORKPROXY_DEV_INTERFACE PPB_NETWORKPROXY_DEV_INTERFACE_0_1
+
+/**
+ * @file
+ * This file defines the <code>PPB_NetworkProxy_Dev</code> interface.
+ */
+
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+struct PPB_NetworkProxy_Dev_0_1 {
+ /**
+ * Retrieves the proxy that will be used for the given URL. The result will
+ * be a string in PAC format. For more details about PAC format, please see
+ * http://en.wikipedia.org/wiki/Proxy_auto-config
+ */
+ int32_t (*GetProxyForURL)(PP_Instance instance,
+ struct PP_Var url,
+ struct PP_Var* proxy_string,
+ struct PP_CompletionCallback callback);
+};
+
+typedef struct PPB_NetworkProxy_Dev_0_1 PPB_NetworkProxy_Dev;
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_DEV_PPB_NETWORK_PROXY_DEV_H_ */
+
diff --git a/ppapi/cpp/dev/network_proxy_dev.cc b/ppapi/cpp/dev/network_proxy_dev.cc
new file mode 100644
index 0000000..eb93731
--- /dev/null
+++ b/ppapi/cpp/dev/network_proxy_dev.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 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/dev/network_proxy_dev.h"
+
+#include "ppapi/c/dev/ppb_network_proxy_dev.h"
+#include "ppapi/cpp/module_impl.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_NetworkProxy_Dev_0_1>() {
+ return PPB_NETWORKPROXY_DEV_INTERFACE_0_1;
+}
+
+} // namespace
+
+// static
+bool NetworkProxy::IsAvailable() {
+ return has_interface<PPB_NetworkProxy_Dev_0_1>();
+}
+
+// static
+int32_t NetworkProxy::GetProxyForURL(
+ const InstanceHandle& instance,
+ const Var& url,
+ const CompletionCallbackWithOutput<Var>& callback) {
+ if (!has_interface<PPB_NetworkProxy_Dev_0_1>())
+ return callback.MayForce(PP_ERROR_NOINTERFACE);
+
+ return get_interface<PPB_NetworkProxy_Dev_0_1>()->GetProxyForURL(
+ instance.pp_instance(), url.pp_var(),
+ callback.output(), callback.pp_completion_callback());
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/dev/network_proxy_dev.h b/ppapi/cpp/dev/network_proxy_dev.h
new file mode 100644
index 0000000..482ce67
--- /dev/null
+++ b/ppapi/cpp/dev/network_proxy_dev.h
@@ -0,0 +1,28 @@
+// Copyright (c) 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_NETWORK_PROXY_H_
+#define PPAPI_CPP_NETWORK_PROXY_H_
+
+#include <string>
+
+#include "ppapi/c/dev/ppb_network_proxy_dev.h"
+#include "ppapi/cpp/completion_callback.h"
+#include "ppapi/cpp/instance_handle.h"
+
+namespace pp {
+
+class NetworkProxy {
+ public:
+ static bool IsAvailable();
+
+ static int32_t GetProxyForURL(
+ const InstanceHandle& instance,
+ const Var& url,
+ const pp::CompletionCallbackWithOutput<Var>& callback);
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_NETWORK_PROXY_H_
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index 155fb37..947ea4b 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -19,6 +19,7 @@
#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/dev/ppb_keyboard_input_event_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
+#include "ppapi/c/dev/ppb_network_proxy_dev.h"
#include "ppapi/c/dev/ppb_printing_dev.h"
#include "ppapi/c/dev/ppb_resource_array_dev.h"
#include "ppapi/c/dev/ppb_scrollbar_dev.h"
@@ -172,6 +173,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_FileChooser_Dev_0_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Font_Dev_0_6;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkProxy_Dev_0_1;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_9;
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Dev_0_91;
@@ -1693,6 +1695,15 @@ static void Pnacl_M21_PPB_IMEInputEvent_Dev_GetSelection(PP_Resource ime_event,
/* Not generating wrapper methods for PPB_Memory_Dev_0_1 */
+/* Begin wrapper methods for PPB_NetworkProxy_Dev_0_1 */
+
+static int32_t Pnacl_M29_PPB_NetworkProxy_Dev_GetProxyForURL(PP_Instance instance, struct PP_Var* url, struct PP_Var* proxy_string, struct PP_CompletionCallback* callback) {
+ const struct PPB_NetworkProxy_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_NetworkProxy_Dev_0_1.real_iface;
+ return iface->GetProxyForURL(instance, *url, proxy_string, *callback);
+}
+
+/* End wrapper methods for PPB_NetworkProxy_Dev_0_1 */
+
/* Begin wrapper methods for PPB_Printing_Dev_0_7 */
static PP_Resource Pnacl_M23_PPB_Printing_Dev_Create(PP_Instance instance) {
@@ -4189,6 +4200,10 @@ struct PPB_IMEInputEvent_Dev_0_2 Pnacl_Wrappers_PPB_IMEInputEvent_Dev_0_2 = {
/* Not generating wrapper interface for PPB_Memory_Dev_0_1 */
+struct PPB_NetworkProxy_Dev_0_1 Pnacl_Wrappers_PPB_NetworkProxy_Dev_0_1 = {
+ .GetProxyForURL = (int32_t (*)(PP_Instance instance, struct PP_Var url, struct PP_Var* proxy_string, struct PP_CompletionCallback callback))&Pnacl_M29_PPB_NetworkProxy_Dev_GetProxyForURL
+};
+
struct PPB_Printing_Dev_0_7 Pnacl_Wrappers_PPB_Printing_Dev_0_7 = {
.Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M23_PPB_Printing_Dev_Create,
.GetDefaultPrintSettings = (int32_t (*)(PP_Resource resource, struct PP_PrintSettings_Dev* print_settings, struct PP_CompletionCallback callback))&Pnacl_M23_PPB_Printing_Dev_GetDefaultPrintSettings
@@ -4998,6 +5013,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2 = {
.real_iface = NULL
};
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_NetworkProxy_Dev_0_1 = {
+ .iface_macro = PPB_NETWORKPROXY_DEV_INTERFACE_0_1,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_NetworkProxy_Dev_0_1,
+ .real_iface = NULL
+};
+
static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Printing_Dev_0_7 = {
.iface_macro = PPB_PRINTING_DEV_INTERFACE_0_7,
.wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Printing_Dev_0_7,
@@ -5338,6 +5359,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = {
&Pnacl_WrapperInfo_PPB_Font_Dev_0_6,
&Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_1,
&Pnacl_WrapperInfo_PPB_IMEInputEvent_Dev_0_2,
+ &Pnacl_WrapperInfo_PPB_NetworkProxy_Dev_0_1,
&Pnacl_WrapperInfo_PPB_Printing_Dev_0_7,
&Pnacl_WrapperInfo_PPB_Testing_Dev_0_9,
&Pnacl_WrapperInfo_PPB_Testing_Dev_0_91,
diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index ba427a6..0895a8c 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -80,6 +80,8 @@
'proxy/locking_resource_releaser.h',
'proxy/net_address_resource.cc',
'proxy/net_address_resource.h',
+ 'proxy/network_proxy_resource.cc',
+ 'proxy/network_proxy_resource.h',
'proxy/pdf_resource.cc',
'proxy/pdf_resource.h',
'proxy/plugin_array_buffer_var.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index fb2683d..4b81630 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -216,6 +216,8 @@
'thunk/ppb_network_list_private_thunk.cc',
'thunk/ppb_network_monitor_private_api.h',
'thunk/ppb_network_monitor_private_thunk.cc',
+ 'thunk/ppb_network_proxy_api.h',
+ 'thunk/ppb_network_proxy_dev_thunk.cc',
'thunk/ppb_pdf_api.h',
'thunk/ppb_pdf_thunk.cc',
'thunk/ppb_printing_api.h',
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index 54834e9..f66f98e 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -75,6 +75,7 @@
'c/dev/ppb_font_dev.h',
'c/dev/ppb_ime_input_event_dev.h',
'c/dev/ppb_memory_dev.h',
+ 'c/dev/ppb_network_proxy_dev.h',
'c/dev/ppb_printing_dev.h',
'c/dev/ppb_resource_array_dev.h',
'c/dev/ppb_scrollbar_dev.h',
@@ -245,6 +246,8 @@
'cpp/dev/ime_input_event_dev.h',
'cpp/dev/memory_dev.cc',
'cpp/dev/memory_dev.h',
+ 'cpp/dev/network_proxy_dev.cc',
+ 'cpp/dev/network_proxy_dev.h',
'cpp/dev/printing_dev.cc',
'cpp/dev/printing_dev.h',
'cpp/dev/resource_array_dev.cc',
@@ -442,6 +445,8 @@
'tests/test_net_address_private_untrusted.h',
'tests/test_network_monitor_private.cc',
'tests/test_network_monitor_private.h',
+ 'tests/test_network_proxy.cc',
+ 'tests/test_network_proxy.h',
'tests/test_paint_aggregator.cc',
'tests/test_paint_aggregator.h',
'tests/test_post_message.cc',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index dacc1d5..bb83c81 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -18,6 +18,7 @@
#include "ppapi/c/dev/ppb_ime_input_event_dev.h"
#include "ppapi/c/dev/ppb_keyboard_input_event_dev.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
+#include "ppapi/c/dev/ppb_network_proxy_dev.h"
#include "ppapi/c/dev/ppb_opengles2ext_dev.h"
#include "ppapi/c/dev/ppb_printing_dev.h"
#include "ppapi/c/dev/ppb_resource_array_dev.h"
diff --git a/ppapi/proxy/network_proxy_resource.cc b/ppapi/proxy/network_proxy_resource.cc
new file mode 100644
index 0000000..b004130
--- /dev/null
+++ b/ppapi/proxy/network_proxy_resource.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 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/proxy/network_proxy_resource.h"
+
+#include "base/bind.h"
+#include "ppapi/proxy/dispatch_reply_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/shared_impl/var.h"
+
+namespace ppapi {
+namespace proxy {
+
+NetworkProxyResource::NetworkProxyResource(Connection connection,
+ PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(BROWSER, PpapiHostMsg_NetworkProxy_Create());
+}
+
+NetworkProxyResource::~NetworkProxyResource() {
+}
+
+thunk::PPB_NetworkProxy_API* NetworkProxyResource::AsPPB_NetworkProxy_API() {
+ return this;
+}
+
+int32_t NetworkProxyResource::GetProxyForURL(
+ PP_Instance /* instance */,
+ PP_Var url,
+ PP_Var* proxy_string,
+ scoped_refptr<TrackedCallback> callback) {
+ StringVar* string_url = StringVar::FromPPVar(url);
+ if (!string_url)
+ return PP_ERROR_BADARGUMENT;
+ Call<PpapiPluginMsg_NetworkProxy_GetProxyForURLReply>(
+ BROWSER,
+ PpapiHostMsg_NetworkProxy_GetProxyForURL(string_url->value()),
+ base::Bind(&NetworkProxyResource::OnPluginMsgGetProxyForURLReply,
+ base::Unretained(this),
+ base::Unretained(proxy_string),
+ callback));
+ return PP_OK_COMPLETIONPENDING;
+}
+
+void NetworkProxyResource::OnPluginMsgGetProxyForURLReply(
+ PP_Var* proxy_string_out_param,
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params,
+ const std::string& proxy_string) {
+ if (!TrackedCallback::IsPending(callback)) {
+ // The callback should not have already been run. If this resource is
+ // deleted, LastPluginRefWasReleased in PluginResource should abort the
+ // callback and should not run this callback.
+ NOTREACHED();
+ return;
+ }
+ if (params.result() == PP_OK) {
+ *proxy_string_out_param = (new StringVar(proxy_string))->GetPPVar();
+ }
+ callback->Run(params.result());
+}
+
+} // namespace proxy
+} // namespace ppapi
diff --git a/ppapi/proxy/network_proxy_resource.h b/ppapi/proxy/network_proxy_resource.h
new file mode 100644
index 0000000..f2084ab
--- /dev/null
+++ b/ppapi/proxy/network_proxy_resource.h
@@ -0,0 +1,45 @@
+// Copyright (c) 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_PROXY_NETWORK_PROXY_RESOURCE_H_
+#define PPAPI_PROXY_NETWORK_PROXY_RESOURCE_H_
+
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/thunk/ppb_network_proxy_api.h"
+
+namespace ppapi {
+namespace proxy {
+
+// The proxy-side resource for PPB_NetworkProxy.
+class PPAPI_PROXY_EXPORT NetworkProxyResource
+ : public PluginResource,
+ public thunk::PPB_NetworkProxy_API {
+ public:
+ NetworkProxyResource(Connection connection, PP_Instance instance);
+ virtual ~NetworkProxyResource();
+
+ private:
+ // Resource implementation.
+ virtual thunk::PPB_NetworkProxy_API* AsPPB_NetworkProxy_API() OVERRIDE;
+
+ // PPB_NetworkProxy_API implementation.
+ virtual int32_t GetProxyForURL(
+ PP_Instance instance,
+ PP_Var url,
+ PP_Var* proxy_string,
+ scoped_refptr<TrackedCallback> callback) OVERRIDE;
+
+ void OnPluginMsgGetProxyForURLReply(PP_Var* proxy_string_out_param,
+ scoped_refptr<TrackedCallback> callback,
+ const ResourceMessageReplyParams& params,
+ const std::string& proxy_string);
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkProxyResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_NETWORK_PROXY_RESOURCE_H_
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 2049298..63f23b58 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -1525,6 +1525,17 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_Graphics2D_ReadImageData,
PP_Point /* top_left */)
IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Graphics2D_ReadImageDataAck)
+// NetworkProxy ----------------------------------------------------------------
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_NetworkProxy_Create)
+
+// Query the browser for the proxy server to use for the given URL.
+IPC_MESSAGE_CONTROL1(PpapiHostMsg_NetworkProxy_GetProxyForURL,
+ std::string /* url */)
+
+// Reply message for GetProxyForURL containing the proxy server.
+IPC_MESSAGE_CONTROL1(PpapiPluginMsg_NetworkProxy_GetProxyForURLReply,
+ std::string /* proxy */)
+
// TrueTypeFont.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_TrueTypeFontSingleton_Create)
IPC_MESSAGE_CONTROL0(PpapiHostMsg_TrueTypeFontSingleton_GetFontFamilies)
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index e3948f06a..20b9364 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -26,6 +26,7 @@
#include "ppapi/proxy/flash_resource.h"
#include "ppapi/proxy/gamepad_resource.h"
#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/network_proxy_resource.h"
#include "ppapi/proxy/pdf_resource.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
@@ -370,18 +371,21 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
case BROKER_SINGLETON_ID:
new_singleton = new BrokerResource(connection, instance);
break;
+ case CRX_FILESYSTEM_SINGLETON_ID:
+ new_singleton = new ExtCrxFileSystemPrivateResource(connection, instance);
+ break;
case EXTENSIONS_COMMON_SINGLETON_ID:
new_singleton = new ExtensionsCommonResource(connection, instance);
break;
case GAMEPAD_SINGLETON_ID:
new_singleton = new GamepadResource(connection, instance);
break;
+ case NETWORK_PROXY_SINGLETON_ID:
+ new_singleton = new NetworkProxyResource(connection, instance);
+ break;
case TRUETYPE_FONT_SINGLETON_ID:
new_singleton = new TrueTypeFontSingletonResource(connection, instance);
break;
- case CRX_FILESYSTEM_SINGLETON_ID:
- new_singleton = new ExtCrxFileSystemPrivateResource(connection, instance);
- break;
// Flash/trusted resources aren't needed for NaCl.
#if !defined(OS_NACL) && !defined(NACL_WIN64)
case BROWSER_FONT_SINGLETON_ID:
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index eac6c95..3fb0931 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -56,6 +56,7 @@
F(PPB_NetAddress_API) \
F(PPB_NetworkList_API) \
F(PPB_NetworkMonitor_Private_API) \
+ F(PPB_NetworkProxy_API) \
F(PPB_PDF_API) \
F(PPB_Printing_API) \
F(PPB_ResourceArray_API) \
@@ -194,8 +195,11 @@ class PPAPI_SHARED_EXPORT Resource : public base::RefCounted<Resource> {
FOR_ALL_PPAPI_RESOURCE_APIS(DEFINE_TYPE_GETTER)
#undef DEFINE_TYPE_GETTER
- // Template-based dynamic casting. See specializations below.
- template <typename T> T* GetAs() { return NULL; }
+ // Template-based dynamic casting. See specializations below. This is
+ // unimplemented for the default case. This way, for anything that's not a
+ // resource (or if a developer forgets to add the resource to the list in
+ // this file), the result is a linker error.
+ template <typename T> T* GetAs();
// Called when a PpapiPluginMsg_ResourceReply reply is received for a
// previous CallRenderer. The message is the nested reply message, which may
diff --git a/ppapi/shared_impl/singleton_resource_id.h b/ppapi/shared_impl/singleton_resource_id.h
index 95d387c..2d89de6 100644
--- a/ppapi/shared_impl/singleton_resource_id.h
+++ b/ppapi/shared_impl/singleton_resource_id.h
@@ -22,6 +22,7 @@ enum SingletonResourceID {
FLASH_FULLSCREEN_SINGLETON_ID,
FLASH_SINGLETON_ID,
GAMEPAD_SINGLETON_ID,
+ NETWORK_PROXY_SINGLETON_ID,
PDF_SINGLETON_ID,
TRUETYPE_FONT_SINGLETON_ID,
};
diff --git a/ppapi/tests/test_network_proxy.cc b/ppapi/tests/test_network_proxy.cc
new file mode 100644
index 0000000..4eb4149
--- /dev/null
+++ b/ppapi/tests/test_network_proxy.cc
@@ -0,0 +1,77 @@
+// Copyright (c) 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/tests/test_network_proxy.h"
+
+#include "ppapi/cpp/dev/network_proxy_dev.h"
+#include "ppapi/cpp/instance.h"
+#include "ppapi/cpp/var.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(NetworkProxy);
+
+TestNetworkProxy::TestNetworkProxy(TestingInstance* instance)
+ : TestCase(instance) {
+}
+
+void TestNetworkProxy::RunTests(const std::string& filter) {
+ RUN_CALLBACK_TEST(TestNetworkProxy, GetProxyForURL, filter);
+}
+
+std::string TestNetworkProxy::TestGetProxyForURL() {
+ TestCompletionCallbackWithOutput<pp::Var> callback(instance_->pp_instance(),
+ callback_type());
+ callback.WaitForResult(
+ pp::NetworkProxy::GetProxyForURL(instance_,
+ pp::Var("http://127.0.0.1/foobar/"),
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+ pp::Var output = callback.output();
+ ASSERT_TRUE(output.is_string());
+ // Assume no one configures a proxy for localhost.
+ ASSERT_EQ("DIRECT", callback.output().AsString());
+
+ callback.WaitForResult(
+ pp::NetworkProxy::GetProxyForURL(instance_,
+ pp::Var("http://www.google.com"),
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+ output = callback.output();
+ // Don't know what the proxy might be, but it should be a valid result.
+ ASSERT_TRUE(output.is_string());
+
+ callback.WaitForResult(
+ pp::NetworkProxy::GetProxyForURL(instance_,
+ pp::Var("file:///tmp"),
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_OK, callback.result());
+ output = callback.output();
+ ASSERT_TRUE(output.is_string());
+ // Should get "DIRECT" for file:// URLs.
+ ASSERT_EQ("DIRECT", output.AsString());
+
+ callback.WaitForResult(
+ pp::NetworkProxy::GetProxyForURL(instance_,
+ pp::Var("this isn't a url"),
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ // TODO(dmichael): Use bad address when it's available.
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
+ // TODO(dmichael): Add this check below when crbug.com/250046 is fixed.
+ // ASSERT_TRUE(callback.output().is_undefined());
+
+ callback.WaitForResult(
+ pp::NetworkProxy::GetProxyForURL(instance_,
+ pp::Var(42), // non-string Var
+ callback.GetCallback()));
+ CHECK_CALLBACK_BEHAVIOR(callback);
+ ASSERT_EQ(PP_ERROR_BADARGUMENT, callback.result());
+ // TODO(dmichael): Add this check below when crbug.com/250046 is fixed.
+ // ASSERT_TRUE(callback.output().is_undefined());
+
+ PASS();
+}
diff --git a/ppapi/tests/test_network_proxy.h b/ppapi/tests/test_network_proxy.h
new file mode 100644
index 0000000..4c072de
--- /dev/null
+++ b/ppapi/tests/test_network_proxy.h
@@ -0,0 +1,23 @@
+// Copyright (c) 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 PAPPI_TESTS_TEST_NETWORK_PROXY_H_
+#define PAPPI_TESTS_TEST_NETWORK_PROXY_H_
+
+#include <string>
+
+#include "ppapi/tests/test_case.h"
+
+class TestNetworkProxy : public TestCase {
+ public:
+ explicit TestNetworkProxy(TestingInstance* instance);
+
+ private:
+ // TestCase implementation.
+ virtual void RunTests(const std::string& filter);
+
+ std::string TestGetProxyForURL();
+};
+
+#endif // PAPPI_TESTS_TEST_NETWORK_PROXY_H_
diff --git a/ppapi/thunk/interfaces_ppb_public_dev.h b/ppapi/thunk/interfaces_ppb_public_dev.h
index 23a6039..b2d1968 100644
--- a/ppapi/thunk/interfaces_ppb_public_dev.h
+++ b/ppapi/thunk/interfaces_ppb_public_dev.h
@@ -28,6 +28,8 @@ PROXIED_IFACE(NoAPIName, PPB_IME_INPUT_EVENT_DEV_INTERFACE_0_2,
PROXIED_IFACE(NoAPIName, PPB_KEYBOARD_INPUT_EVENT_DEV_INTERFACE_0_1,
PPB_KeyboardInputEvent_Dev_0_1)
PROXIED_IFACE(NoAPIName, PPB_MEMORY_DEV_INTERFACE_0_1, PPB_Memory_Dev_0_1)
+PROXIED_IFACE(NoAPIName, PPB_NETWORKPROXY_DEV_INTERFACE_0_1,
+ PPB_NetworkProxy_Dev_0_1)
PROXIED_IFACE(NoAPIName, PPB_PRINTING_DEV_INTERFACE_0_7,
PPB_Printing_Dev_0_7)
PROXIED_IFACE(NoAPIName, PPB_RESOURCEARRAY_DEV_INTERFACE_0_1,
diff --git a/ppapi/thunk/ppb_network_proxy_api.h b/ppapi/thunk/ppb_network_proxy_api.h
new file mode 100644
index 0000000..3cefaa0
--- /dev/null
+++ b/ppapi/thunk/ppb_network_proxy_api.h
@@ -0,0 +1,38 @@
+// Copyright (c) 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_THUNK_PPB_NETWORK_PROXY_API_H_
+#define PPAPI_THUNK_PPB_NETWORK_PROXY_API_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/shared_impl/singleton_resource_id.h"
+#include "ppapi/thunk/ppapi_thunk_export.h"
+
+struct PP_Var;
+
+namespace ppapi {
+
+class TrackedCallback;
+
+namespace thunk {
+
+class PPAPI_THUNK_EXPORT PPB_NetworkProxy_API {
+ public:
+ virtual ~PPB_NetworkProxy_API() {}
+
+ virtual int32_t GetProxyForURL(PP_Instance instance,
+ PP_Var url,
+ PP_Var* proxy_string,
+ scoped_refptr<TrackedCallback> callback) = 0;
+
+ static const SingletonResourceID kSingletonResourceID =
+ NETWORK_PROXY_SINGLETON_ID;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_NETWORK_PROXY_API_H_
diff --git a/ppapi/thunk/ppb_network_proxy_dev_thunk.cc b/ppapi/thunk/ppb_network_proxy_dev_thunk.cc
new file mode 100644
index 0000000..829ec2b
--- /dev/null
+++ b/ppapi/thunk/ppb_network_proxy_dev_thunk.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 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.
+
+// From dev/ppb_network_proxy_dev.idl modified Thu Jun 6 12:08:31 2013.
+
+#include "ppapi/c/dev/ppb_network_proxy_dev.h"
+#include "ppapi/c/pp_completion_callback.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_network_proxy_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+int32_t GetProxyForURL(PP_Instance instance,
+ struct PP_Var url,
+ struct PP_Var* proxy_string,
+ struct PP_CompletionCallback callback) {
+ VLOG(4) << "PPB_NetworkProxy_Dev::GetProxyForURL()";
+ EnterInstanceAPI<PPB_NetworkProxy_API> enter(instance, callback);
+ if (enter.failed())
+ return enter.retval();
+ return enter.SetResult(enter.functions()->GetProxyForURL(instance,
+ url,
+ proxy_string,
+ enter.callback()));
+}
+
+const PPB_NetworkProxy_Dev_0_1 g_ppb_networkproxy_dev_thunk_0_1 = {
+ &GetProxyForURL
+};
+
+} // namespace
+
+const PPB_NetworkProxy_Dev_0_1* GetPPB_NetworkProxy_Dev_0_1_Thunk() {
+ return &g_ppb_networkproxy_dev_thunk_0_1;
+}
+
+} // namespace thunk
+} // namespace ppapi