summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-20 15:25:55 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-20 15:25:55 +0000
commitf682ad7ed47cf3cadf5d4c9f12996bb6bd5890f2 (patch)
tree74e15da4da50e5cbb9be7d6a30f96e83f260def3 /ppapi/proxy
parent264fda93befd14308dc1703b53c270cbe63e8dc6 (diff)
downloadchromium_src-f682ad7ed47cf3cadf5d4c9f12996bb6bd5890f2.zip
chromium_src-f682ad7ed47cf3cadf5d4c9f12996bb6bd5890f2.tar.gz
chromium_src-f682ad7ed47cf3cadf5d4c9f12996bb6bd5890f2.tar.bz2
Add an initial crypto interface to fill a given buffer with random data. This
has the same implementation as the WebKit one on ChromeOS. TEST=none BUG=none Review URL: http://codereview.chromium.org/6880053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82291 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/dispatcher.cc3
-rw-r--r--ppapi/proxy/interface_id.h1
-rw-r--r--ppapi/proxy/ppb_crypto_proxy.cc54
-rw-r--r--ppapi/proxy/ppb_crypto_proxy.h33
4 files changed, 91 insertions, 0 deletions
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index 2964835..f5d5668 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -14,6 +14,7 @@
#include "ppapi/c/dev/ppb_buffer_dev.h"
#include "ppapi/c/dev/ppb_char_set_dev.h"
#include "ppapi/c/dev/ppb_context_3d_dev.h"
+#include "ppapi/c/dev/ppb_crypto_dev.h"
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/dev/ppb_gles_chromium_texture_mapping_dev.h"
#include "ppapi/c/dev/ppb_font_dev.h"
@@ -50,6 +51,7 @@
#include "ppapi/proxy/ppb_console_proxy.h"
#include "ppapi/proxy/ppb_context_3d_proxy.h"
#include "ppapi/proxy/ppb_core_proxy.h"
+#include "ppapi/proxy/ppb_crypto_proxy.h"
#include "ppapi/proxy/ppb_cursor_control_proxy.h"
#include "ppapi/proxy/ppb_file_chooser_proxy.h"
#include "ppapi/proxy/ppb_file_ref_proxy.h"
@@ -113,6 +115,7 @@ InterfaceList::InterfaceList() {
AddPPB(PPB_Console_Proxy::GetInfo());
AddPPB(PPB_Context3D_Proxy::GetInfo());
AddPPB(PPB_Core_Proxy::GetInfo());
+ AddPPB(PPB_Crypto_Proxy::GetInfo());
AddPPB(PPB_CursorControl_Proxy::GetInfo());
AddPPB(PPB_FileChooser_Proxy::GetInfo());
AddPPB(PPB_FileRef_Proxy::GetInfo());
diff --git a/ppapi/proxy/interface_id.h b/ppapi/proxy/interface_id.h
index 10ef8c4..c7346b5 100644
--- a/ppapi/proxy/interface_id.h
+++ b/ppapi/proxy/interface_id.h
@@ -21,6 +21,7 @@ enum InterfaceID {
INTERFACE_ID_PPB_CONSOLE,
INTERFACE_ID_PPB_CONTEXT_3D,
INTERFACE_ID_PPB_CORE,
+ INTERFACE_ID_PPB_CRYPTO,
INTERFACE_ID_PPB_CURSORCONTROL,
INTERFACE_ID_PPB_FILE_CHOOSER,
INTERFACE_ID_PPB_FILE_REF,
diff --git a/ppapi/proxy/ppb_crypto_proxy.cc b/ppapi/proxy/ppb_crypto_proxy.cc
new file mode 100644
index 0000000..207b400
--- /dev/null
+++ b/ppapi/proxy/ppb_crypto_proxy.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2011 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/ppb_crypto_proxy.h"
+
+#include "ppapi/c/dev/ppb_crypto_dev.h"
+#include "ppapi/proxy/interface_id.h"
+#include "ppapi/shared_impl/crypto_impl.h"
+
+namespace pp {
+namespace proxy {
+
+namespace {
+
+const PPB_Crypto_Dev crypto_interface = {
+ &pp::shared_impl::CryptoImpl::GetRandomBytes
+};
+
+InterfaceProxy* CreateCryptoProxy(Dispatcher* dispatcher,
+ const void* target_interface) {
+ return new PPB_Crypto_Proxy(dispatcher, target_interface);
+}
+
+} // namespace
+
+PPB_Crypto_Proxy::PPB_Crypto_Proxy(Dispatcher* dispatcher,
+ const void* target_interface)
+ : InterfaceProxy(dispatcher, target_interface) {
+ NOTREACHED(); // See comment in the header file.
+}
+
+PPB_Crypto_Proxy::~PPB_Crypto_Proxy() {
+}
+
+// static
+const InterfaceProxy::Info* PPB_Crypto_Proxy::GetInfo() {
+ static const Info info = {
+ &crypto_interface,
+ PPB_CRYPTO_DEV_INTERFACE,
+ INTERFACE_ID_PPB_CRYPTO,
+ false,
+ &CreateCryptoProxy,
+ };
+ return &info;
+}
+
+bool PPB_Crypto_Proxy::OnMessageReceived(const IPC::Message& msg) {
+ NOTREACHED();
+ return false;
+}
+
+} // namespace proxy
+} // namespace pp
diff --git a/ppapi/proxy/ppb_crypto_proxy.h b/ppapi/proxy/ppb_crypto_proxy.h
new file mode 100644
index 0000000..e801892
--- /dev/null
+++ b/ppapi/proxy/ppb_crypto_proxy.h
@@ -0,0 +1,33 @@
+// Copyright (c) 2011 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_PPB_CRYPTO_PROXY_H_
+#define PPAPI_PROXY_PPB_CRYPTO_PROXY_H_
+
+#include "ppapi/proxy/interface_proxy.h"
+
+namespace pp {
+namespace proxy {
+
+class PPB_Crypto_Proxy : public InterfaceProxy {
+ public:
+ // This class should not normally be instantiated since there's only one
+ // function that's implemented entirely within the plugin. However, we need
+ // to support this so the machinery for automatically handling interfaces
+ // works. As a result, this constructor will assert if it's actually used.
+ PPB_Crypto_Proxy(Dispatcher* dispatcher, const void* target_interface);
+ virtual ~PPB_Crypto_Proxy();
+
+ static const Info* GetInfo();
+
+ private:
+ virtual bool OnMessageReceived(const IPC::Message& msg);
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_Crypto_Proxy);
+};
+
+} // namespace proxy
+} // namespace pp
+
+#endif // PPAPI_PROXY_PPB_CRYPTO_PROXY_H_