diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-19 17:10:50 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-19 17:10:50 +0000 |
commit | 84350ef4536f877c2e1e5f3b6766a1c9361d76d4 (patch) | |
tree | f30ce70c8b8a979aafe94e94cfe2c7eb447d9fe7 /ppapi | |
parent | 3037a702987ad70ba53e3cf4707c397658ed3f23 (diff) | |
download | chromium_src-84350ef4536f877c2e1e5f3b6766a1c9361d76d4.zip chromium_src-84350ef4536f877c2e1e5f3b6766a1c9361d76d4.tar.gz chromium_src-84350ef4536f877c2e1e5f3b6766a1c9361d76d4.tar.bz2 |
Pepper: Finish support for dev channel APIs.
This change completes the wiring, adding a file to list dev channel interfaces,
analogous to what exists for different permissions today. We only need to
introduce interfaces_ppb_public_dev_channel.h since we don't anticipate
dev channel APIs with permissions other than NONE.
BUG=325403
R=dmichael@chromium.org
Review URL: https://codereview.chromium.org/112343005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241877 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/ppapi_tests.gypi | 1 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.cc | 22 | ||||
-rw-r--r-- | ppapi/proxy/interface_list.h | 9 | ||||
-rw-r--r-- | ppapi/proxy/interface_list_unittest.cc | 66 | ||||
-rw-r--r-- | ppapi/proxy/plugin_main_nacl.cc | 2 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 5 | ||||
-rw-r--r-- | ppapi/shared_impl/ppapi_permissions.h | 11 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_public_dev_channel.h | 12 |
8 files changed, 103 insertions, 25 deletions
diff --git a/ppapi/ppapi_tests.gypi b/ppapi/ppapi_tests.gypi index 4f439ba..0b4570a 100644 --- a/ppapi/ppapi_tests.gypi +++ b/ppapi/ppapi_tests.gypi @@ -171,6 +171,7 @@ 'proxy/device_enumeration_resource_helper_unittest.cc', 'proxy/file_chooser_resource_unittest.cc', 'proxy/flash_resource_unittest.cc', + 'proxy/interface_list_unittest.cc', 'proxy/mock_resource.cc', 'proxy/mock_resource.h', 'proxy/pdf_resource_unittest.cc', diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 57cd79c..bf4a938 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -154,7 +154,6 @@ InterfaceProxy* ProxyFactory(Dispatcher* dispatcher) { } base::LazyInstance<PpapiPermissions> g_process_global_permissions; -base::LazyInstance<bool> g_supports_dev_channel; } // namespace @@ -193,8 +192,14 @@ InterfaceList::InterfaceList() { #include "ppapi/thunk/interfaces_ppb_private_flash.h" #endif // !defined(OS_NACL) } - - // TODO(teravest): Add dev channel interfaces here. + { + // TODO(teravest): These lines should be uncommented when a dev channel + // interface is added. They're commented right now because they cause an + // unused variable warning. + // + // Permission current_required_permission = PERMISSION_DEV_CHANNEL; + // #include "ppapi/thunk/interfaces_ppb_public_dev_channel.h" + } #undef PROXIED_API #undef PROXIED_IFACE @@ -228,8 +233,7 @@ InterfaceList::InterfaceList() { AddPPB(PPB_OPENGLES2_QUERY_INTERFACE_1_0, PPB_OpenGLES2_Shared::GetQueryInterface(), PERMISSION_NONE); AddPPB(PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0, - PPB_Var_Shared::GetVarArrayBufferInterface1_0(), - PERMISSION_NONE); + PPB_Var_Shared::GetVarArrayBufferInterface1_0(), PERMISSION_NONE); AddPPB(PPB_VAR_INTERFACE_1_1, PPB_Var_Shared::GetVarInterface1_1(), PERMISSION_NONE); AddPPB(PPB_VAR_INTERFACE_1_0, @@ -303,12 +307,6 @@ void InterfaceList::SetProcessGlobalPermissions( g_process_global_permissions.Get() = permissions; } -// static -void InterfaceList::SetSupportsDevChannel( - bool supports_dev_channel) { - g_supports_dev_channel.Get() = supports_dev_channel; -} - InterfaceProxy::Factory InterfaceList::GetFactoryForID(ApiID id) const { int index = static_cast<int>(id); COMPILE_ASSERT(API_ID_NONE == 0, none_must_be_zero); @@ -323,8 +321,6 @@ const void* InterfaceList::GetInterfaceForPPB(const std::string& name) const { if (found == name_to_browser_info_.end()) return NULL; - // Dev channel checking goes here. - if (g_process_global_permissions.Get().HasPermission( found->second.required_permission)) return found->second.iface; diff --git a/ppapi/proxy/interface_list.h b/ppapi/proxy/interface_list.h index 27728f7..85b7eb6 100644 --- a/ppapi/proxy/interface_list.h +++ b/ppapi/proxy/interface_list.h @@ -16,7 +16,7 @@ namespace ppapi { namespace proxy { -class InterfaceList { +class PPAPI_PROXY_EXPORT InterfaceList { public: InterfaceList(); ~InterfaceList(); @@ -33,10 +33,7 @@ class InterfaceList { // plugin process. A real security check is required for all IPC messages. // This check just allows us to return NULL for interfaces you "shouldn't" be // using to keep honest plugins honest. - static PPAPI_PROXY_EXPORT void SetProcessGlobalPermissions( - const PpapiPermissions& permissions); - static PPAPI_PROXY_EXPORT void SetSupportsDevChannel( - bool supports_dev_channel); + static void SetProcessGlobalPermissions(const PpapiPermissions& permissions); // Looks up the factory function for the given ID. Returns NULL if not // supported. @@ -48,6 +45,8 @@ class InterfaceList { const void* GetInterfaceForPPP(const std::string& name) const; private: + friend class InterfaceListTest; + struct InterfaceInfo { InterfaceInfo() : iface(NULL), diff --git a/ppapi/proxy/interface_list_unittest.cc b/ppapi/proxy/interface_list_unittest.cc new file mode 100644 index 0000000..17140f0 --- /dev/null +++ b/ppapi/proxy/interface_list_unittest.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/c/ppb_core.h" +#include "ppapi/proxy/interface_list.h" +#include "ppapi/proxy/ppapi_proxy_test.h" + +namespace ppapi { +namespace proxy { + +class InterfaceListTest : public PluginProxyTest { + public: + // Wrapper function so we can use the private InterfaceList::AddPPB. + void AddPPB(InterfaceList* list, + const char* iface_name, void* iface_addr, Permission perm) { + list->AddPPB(iface_name, iface_addr, perm); + } +}; + +// Tests looking up a stable interface. +TEST_F(InterfaceListTest, Stable) { + InterfaceList list; + ASSERT_TRUE(list.GetInterfaceForPPB(PPB_CORE_INTERFACE_1_0) != NULL); + ASSERT_TRUE(list.GetInterfaceForPPB("FakeUnknownInterface") == NULL); +} + +// Tests that dev channel restrictions work properly. +TEST_F(InterfaceListTest, DevChannel) { + InterfaceList list; + // "Dev channel" interface. + static const char* dev_channel_iface_name = "TestDevChannelInterface"; + void* dev_channel_iface_addr = (void*)0xdeadbeef; + // "Dev" interface + static const char* dev_iface_name = "TestDevInterface"; + void* dev_iface_addr = (void*)0xcafefade; + + AddPPB(&list, dev_channel_iface_name, dev_channel_iface_addr, + PERMISSION_DEV_CHANNEL); + AddPPB(&list, dev_iface_name, dev_iface_addr, PERMISSION_DEV); + + InterfaceList::SetProcessGlobalPermissions( + PpapiPermissions(PERMISSION_NONE)); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == NULL); + + InterfaceList::SetProcessGlobalPermissions( + PpapiPermissions(PERMISSION_DEV_CHANNEL)); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == + dev_channel_iface_addr); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == NULL); + + InterfaceList::SetProcessGlobalPermissions( + PpapiPermissions(PERMISSION_DEV)); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == NULL); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); + + InterfaceList::SetProcessGlobalPermissions( + PpapiPermissions(PERMISSION_DEV | PERMISSION_DEV_CHANNEL)); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_channel_iface_name) == + dev_channel_iface_addr); + ASSERT_TRUE(list.GetInterfaceForPPB(dev_iface_name) == dev_iface_addr); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/plugin_main_nacl.cc b/ppapi/proxy/plugin_main_nacl.cc index 985deb7..bced108 100644 --- a/ppapi/proxy/plugin_main_nacl.cc +++ b/ppapi/proxy/plugin_main_nacl.cc @@ -214,8 +214,6 @@ void PpapiDispatcher::OnMsgCreateNaClChannel( // plugin. ppapi::proxy::InterfaceList::SetProcessGlobalPermissions( args.permissions); - ppapi::proxy::InterfaceList::SetSupportsDevChannel( - args.supports_dev_channel); int32_t error = ::PPP_InitializeModule( 0 /* module */, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 086d42a..ca4ea36 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -364,10 +364,9 @@ IPC_STRUCT_TRAITS_END() // These are from the browser to the plugin. // Loads the given plugin. -IPC_MESSAGE_CONTROL3(PpapiMsg_LoadPlugin, +IPC_MESSAGE_CONTROL2(PpapiMsg_LoadPlugin, base::FilePath /* path */, - ppapi::PpapiPermissions /* permissions */, - bool /* supports_dev_channel */) + ppapi::PpapiPermissions /* permissions */) // Creates a channel to talk to a renderer. The plugin will respond with // PpapiHostMsg_ChannelCreated. diff --git a/ppapi/shared_impl/ppapi_permissions.h b/ppapi/shared_impl/ppapi_permissions.h index fb82cfc..3002df6 100644 --- a/ppapi/shared_impl/ppapi_permissions.h +++ b/ppapi/shared_impl/ppapi_permissions.h @@ -14,7 +14,8 @@ enum Permission { // Placeholder/uninitialized permission. PERMISSION_NONE = 0, - // Allows access to dev interfaces. + // Allows access to dev interfaces. These are experimental interfaces not + // tied to any particular release channel. PERMISSION_DEV = 1 << 0, // Allows access to Browser-internal interfaces. @@ -30,6 +31,11 @@ enum Permission { // Flash-related interfaces. PERMISSION_FLASH = 1 << 4, + // "Dev channel" interfaces. This is different than PERMISSION_DEV above; + // these interfaces may only be used on Dev or Canary channel releases of + // Chrome. + PERMISSION_DEV_CHANNEL = 1 << 5, + // NOTE: If you add stuff be sure to update PERMISSION_ALL_BITS. // Meta permission for initializing plugins registered on the command line @@ -38,7 +44,8 @@ enum Permission { PERMISSION_PRIVATE | PERMISSION_BYPASS_USER_GESTURE | PERMISSION_TESTING | - PERMISSION_FLASH + PERMISSION_FLASH | + PERMISSION_DEV_CHANNEL }; class PPAPI_SHARED_EXPORT PpapiPermissions { diff --git a/ppapi/thunk/interfaces_ppb_public_dev_channel.h b/ppapi/thunk/interfaces_ppb_public_dev_channel.h new file mode 100644 index 0000000..a70442b --- /dev/null +++ b/ppapi/thunk/interfaces_ppb_public_dev_channel.h @@ -0,0 +1,12 @@ +// 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. + +// Please see inteface_ppb_public_stable for the documentation on the format of +// this file. + +#include "ppapi/thunk/interfaces_preamble.h" + +// Interfaces go here. + +#include "ppapi/thunk/interfaces_postamble.h" |