diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 19:21:20 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-28 19:21:20 +0000 |
commit | f20cc69fdf1638f0f2c48704f4f42bb5b938e436 (patch) | |
tree | b78df389dcbaf18e9969117f785f2b7ce72327fd | |
parent | 11924815ef76d03622580daa4a1ec7f61d39db58 (diff) | |
download | chromium_src-f20cc69fdf1638f0f2c48704f4f42bb5b938e436.zip chromium_src-f20cc69fdf1638f0f2c48704f4f42bb5b938e436.tar.gz chromium_src-f20cc69fdf1638f0f2c48704f4f42bb5b938e436.tar.bz2 |
Convert the Pepper Talk API to use the new resource system.
This uses the new resource call/reply system and removes the special casing
for the messages in the PPAPI plugin and the special filter attached to all
child process hosts. This also adds permissions checking (it requires private
permissions to use this API).
BUG=
Review URL: https://codereview.chromium.org/11359147
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170017 0039d316-1c4b-4281-b951-d872f2087c98
20 files changed, 266 insertions, 262 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index cd5048a..5537547 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -44,7 +44,6 @@ #include "chrome/browser/net/chrome_net_log.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/notifications/desktop_notification_service_factory.h" -#include "chrome/browser/pepper_gtalk_message_filter.h" #include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" @@ -623,11 +622,6 @@ void ChromeContentBrowserClient::RenderProcessHostCreated( #endif } -void ChromeContentBrowserClient::BrowserChildProcessHostCreated( - content::BrowserChildProcessHost* host) { - host->GetHost()->AddFilter(new PepperGtalkMessageFilter()); -} - content::WebUIControllerFactory* ChromeContentBrowserClient::GetWebUIControllerFactory() { return ChromeWebUIControllerFactory::GetInstance(); diff --git a/chrome/browser/chrome_content_browser_client.h b/chrome/browser/chrome_content_browser_client.h index 0b9e438..75ce0ae 100644 --- a/chrome/browser/chrome_content_browser_client.h +++ b/chrome/browser/chrome_content_browser_client.h @@ -62,8 +62,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { content::RenderViewHost* render_view_host) OVERRIDE; virtual void RenderProcessHostCreated( content::RenderProcessHost* host) OVERRIDE; - virtual void BrowserChildProcessHostCreated( - content::BrowserChildProcessHost* host) OVERRIDE; virtual content::WebUIControllerFactory* GetWebUIControllerFactory() OVERRIDE; virtual bool ShouldUseProcessPerSite(content::BrowserContext* browser_context, const GURL& effective_url) OVERRIDE; diff --git a/chrome/browser/pepper_gtalk_message_filter.cc b/chrome/browser/pepper_gtalk_message_filter.cc deleted file mode 100644 index 1ed1c13..0000000 --- a/chrome/browser/pepper_gtalk_message_filter.cc +++ /dev/null @@ -1,63 +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 "chrome/browser/pepper_gtalk_message_filter.h" - -#include "content/public/browser/browser_thread.h" -#include "grit/generated_resources.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/api_id.h" -#include "ui/base/l10n/l10n_util.h" - -#if defined(USE_ASH) -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "chrome/browser/ui/simple_message_box.h" -#include "ui/aura/window.h" -#endif - -PepperGtalkMessageFilter::PepperGtalkMessageFilter() {} - -void PepperGtalkMessageFilter::OverrideThreadForMessage( - const IPC::Message& message, - content::BrowserThread::ID* thread) { - if (message.type() == PpapiHostMsg_PPBTalk_GetPermission::ID) { - *thread = content::BrowserThread::UI; - } -} - -bool PepperGtalkMessageFilter::OnMessageReceived(const IPC::Message& msg, - bool* message_was_ok) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(PepperGtalkMessageFilter, msg, *message_was_ok) - IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTalk_GetPermission, OnTalkGetPermission) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP_EX() - return handled; -} - -PepperGtalkMessageFilter::~PepperGtalkMessageFilter() {} - -void PepperGtalkMessageFilter::OnTalkGetPermission(uint32 plugin_dispatcher_id, - PP_Resource resource) { - bool user_response = false; -#if defined(USE_ASH) - const string16 title = l10n_util::GetStringUTF16( - IDS_GTALK_SCREEN_SHARE_DIALOG_TITLE); - const string16 message = l10n_util::GetStringUTF16( - IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE); - - aura::Window* parent = ash::Shell::GetContainer( - ash::Shell::GetActiveRootWindow(), - ash::internal::kShellWindowId_SystemModalContainer); - user_response = chrome::ShowMessageBox(parent, title, message, - chrome::MESSAGE_BOX_TYPE_QUESTION) == chrome::MESSAGE_BOX_RESULT_YES; -#else - NOTIMPLEMENTED(); -#endif - Send(new PpapiMsg_PPBTalk_GetPermissionACK(ppapi::API_ID_PPB_TALK, - plugin_dispatcher_id, - resource, - user_response)); -} diff --git a/chrome/browser/pepper_gtalk_message_filter.h b/chrome/browser/pepper_gtalk_message_filter.h deleted file mode 100644 index 17847df..0000000 --- a/chrome/browser/pepper_gtalk_message_filter.h +++ /dev/null @@ -1,32 +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 CHROME_BROWSER_PEPPER_GTALK_MESSAGE_FILTER_H_ -#define CHROME_BROWSER_PEPPER_GTALK_MESSAGE_FILTER_H_ - -#include "content/public/browser/browser_message_filter.h" -#include "ppapi/c/pp_resource.h" - -// A message filter for Gtalk-specific pepper messages. -class PepperGtalkMessageFilter : public content::BrowserMessageFilter { - public: - PepperGtalkMessageFilter(); - - // content::BrowserMessageFilter methods. - virtual void OverrideThreadForMessage( - const IPC::Message& message, - content::BrowserThread::ID* thread) OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message, - bool* message_was_ok) OVERRIDE; - - private: - virtual ~PepperGtalkMessageFilter(); - - void OnTalkGetPermission(uint32 plugin_dispatcher_id, - PP_Resource resource); - - DISALLOW_COPY_AND_ASSIGN(PepperGtalkMessageFilter); -}; - -#endif // CHROME_BROWSER_PEPPER_GTALK_MESSAGE_FILTER_H_ diff --git a/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc b/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc index 5aead89..211fd28 100644 --- a/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc +++ b/chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.cc @@ -5,6 +5,7 @@ #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" #include "chrome/browser/renderer_host/pepper/pepper_flash_device_id_host.h" +#include "chrome/browser/renderer_host/pepper/pepper_talk_host.h" #include "content/public/browser/browser_ppapi_host.h" #include "ppapi/host/ppapi_host.h" #include "ppapi/host/resource_host.h" @@ -41,6 +42,9 @@ scoped_ptr<ResourceHost> ChromeBrowserPepperHostFactory::CreateResourceHost( case PpapiHostMsg_FlashDeviceID_Create::ID: return scoped_ptr<ResourceHost>(new PepperFlashDeviceIDHost( host_, instance, params.pp_resource())); + case PpapiHostMsg_Talk_Create::ID: + return scoped_ptr<ResourceHost>(new PepperTalkHost( + host_, instance, params.pp_resource())); } } return scoped_ptr<ResourceHost>(); diff --git a/chrome/browser/renderer_host/pepper/pepper_talk_host.cc b/chrome/browser/renderer_host/pepper/pepper_talk_host.cc new file mode 100644 index 0000000..b0b51ee --- /dev/null +++ b/chrome/browser/renderer_host/pepper/pepper_talk_host.cc @@ -0,0 +1,102 @@ +// 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 "chrome/browser/renderer_host/pepper/pepper_talk_host.h" + +#include "base/bind.h" +#include "content/public/browser/browser_ppapi_host.h" +#include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_view_host.h" +#include "grit/generated_resources.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/host/host_message_context.h" +#include "ppapi/host/ppapi_host.h" +#include "ppapi/proxy/ppapi_messages.h" +#include "ui/base/l10n/l10n_util.h" + +#if defined(USE_ASH) +#include "ash/shell.h" +#include "ash/shell_window_ids.h" +#include "chrome/browser/ui/simple_message_box.h" +#include "ui/aura/window.h" +#endif + +namespace chrome { + +namespace { + +ppapi::host::ReplyMessageContext GetPermissionOnUIThread( + int render_process_id, + int render_view_id, + ppapi::host::ReplyMessageContext reply) { + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); + reply.params.set_result(0); + + content::RenderViewHost* render_view_host = + content::RenderViewHost::FromID(render_process_id, render_view_id); + if (!render_view_host) + return reply; // RVH destroyed while task was pending. + +#if defined(USE_ASH) + // TODO(brettw). We should not be grabbing the active toplevel window, we + // should use the toplevel window associated with the render view. + const string16 title = l10n_util::GetStringUTF16( + IDS_GTALK_SCREEN_SHARE_DIALOG_TITLE); + const string16 message = l10n_util::GetStringUTF16( + IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE); + + aura::Window* parent = ash::Shell::GetContainer( + ash::Shell::GetActiveRootWindow(), + ash::internal::kShellWindowId_SystemModalContainer); + reply.params.set_result(static_cast<int32_t>( + chrome::ShowMessageBox(parent, title, message, + chrome::MESSAGE_BOX_TYPE_QUESTION) == + chrome::MESSAGE_BOX_RESULT_YES)); +#else + NOTIMPLEMENTED(); +#endif + return reply; +} + +} // namespace + +PepperTalkHost::PepperTalkHost(content::BrowserPpapiHost* host, + PP_Instance instance, + PP_Resource resource) + : ppapi::host::ResourceHost(host->GetPpapiHost(), instance, resource), + weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + browser_ppapi_host_(host) { +} + +PepperTalkHost::~PepperTalkHost() { +} + +int32_t PepperTalkHost::OnResourceMessageReceived( + const IPC::Message& msg, + ppapi::host::HostMessageContext* context) { + // We only have one message with no parameters. + if (msg.type() != PpapiHostMsg_Talk_GetPermission::ID) + return 0; + + int render_process_id = 0; + int render_view_id = 0; + browser_ppapi_host_->GetRenderViewIDsForInstance( + pp_instance(), &render_process_id, &render_view_id); + + content::BrowserThread::PostTaskAndReplyWithResult( + content::BrowserThread::UI, FROM_HERE, + base::Bind(&GetPermissionOnUIThread, render_process_id, render_view_id, + context->MakeReplyMessageContext()), + base::Bind(&PepperTalkHost::GotTalkPermission, + weak_factory_.GetWeakPtr())); + return PP_OK_COMPLETIONPENDING; +} + +void PepperTalkHost::GotTalkPermission( + ppapi::host::ReplyMessageContext reply) { + DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); + host()->SendReply(reply, PpapiPluginMsg_Talk_GetPermissionReply()); +} + +} // namespace chrome diff --git a/chrome/browser/renderer_host/pepper/pepper_talk_host.h b/chrome/browser/renderer_host/pepper/pepper_talk_host.h new file mode 100644 index 0000000..b721b7f --- /dev/null +++ b/chrome/browser/renderer_host/pepper/pepper_talk_host.h @@ -0,0 +1,48 @@ +// 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 CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TALK_HOST_H_ +#define CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TALK_HOST_H_ + +#include "base/memory/weak_ptr.h" +#include "ppapi/host/resource_host.h" +#include "ppapi/proxy/resource_message_params.h" + +namespace content { +class BrowserPpapiHost; +} + +namespace ppapi { +namespace host { +struct ReplyMessageContext; +} +} + +namespace chrome { + +class PepperTalkHost : public ppapi::host::ResourceHost { + public: + PepperTalkHost(content::BrowserPpapiHost* host, + PP_Instance instance, + PP_Resource resource); + virtual ~PepperTalkHost(); + + // ResourceHost override. + virtual int32_t OnResourceMessageReceived( + const IPC::Message& msg, + ppapi::host::HostMessageContext* context) OVERRIDE; + + // Sends the reply. + void GotTalkPermission(ppapi::host::ReplyMessageContext reply); + + private: + base::WeakPtrFactory<PepperTalkHost> weak_factory_; + content::BrowserPpapiHost* browser_ppapi_host_; + + DISALLOW_COPY_AND_ASSIGN(PepperTalkHost); +}; + +} // namespace chrome + +#endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_PEPPER_TALK_HOST_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6439bed..721f676 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1229,8 +1229,6 @@ 'browser/pepper_broker_infobar_delegate.h', 'browser/pepper_flash_settings_manager.cc', 'browser/pepper_flash_settings_manager.h', - 'browser/pepper_gtalk_message_filter.cc', - 'browser/pepper_gtalk_message_filter.h', 'browser/performance_monitor/constants.cc', 'browser/performance_monitor/constants.h', 'browser/performance_monitor/database.cc', @@ -1638,6 +1636,8 @@ 'browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h', 'browser/renderer_host/pepper/pepper_flash_device_id_host.cc', 'browser/renderer_host/pepper/pepper_flash_device_id_host.h', + 'browser/renderer_host/pepper/pepper_talk_host.cc', + 'browser/renderer_host/pepper/pepper_talk_host.h', 'browser/renderer_host/plugin_info_message_filter.cc', 'browser/renderer_host/plugin_info_message_filter.h', 'browser/renderer_host/safe_browsing_resource_throttle.cc', diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index b3259c7..7678780 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -115,8 +115,6 @@ bool PpapiThread::OnMessageReceived(const IPC::Message& msg) { OnPluginDispatcherMessageReceived(msg)) IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBUDPSocket_BindACK, OnPluginDispatcherMessageReceived(msg)) - IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBTalk_GetPermissionACK, - OnPluginDispatcherMessageReceived(msg)) IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBHostResolver_ResolveACK, OnPluginDispatcherMessageReceived(msg)) IPC_MESSAGE_HANDLER_GENERIC(PpapiMsg_PPBNetworkMonitor_NetworkList, diff --git a/ppapi/api/private/ppb_talk_private.idl b/ppapi/api/private/ppb_talk_private.idl index 65265ae..8422fe0 100644 --- a/ppapi/api/private/ppb_talk_private.idl +++ b/ppapi/api/private/ppb_talk_private.idl @@ -22,8 +22,8 @@ interface PPB_Talk_Private { /** * Displays security UI. * - * The callback will be issued with PP_OK as the result of the user gave - * permission, or PP_ERROR_NOACCESS if the user denied. + * The callback will be issued with 1 as the result if the user gave + * permission, or 0 if the user denied. * * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING * if the request is queued, or PP_ERROR_INPROGRESS if there is already a diff --git a/ppapi/c/private/ppb_talk_private.h b/ppapi/c/private/ppb_talk_private.h index 6c51325..5783d8b 100644 --- a/ppapi/c/private/ppb_talk_private.h +++ b/ppapi/c/private/ppb_talk_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_talk_private.idl modified Fri Mar 9 11:03:31 2012. */ +/* From private/ppb_talk_private.idl modified Fri Nov 9 14:42:36 2012. */ #ifndef PPAPI_C_PRIVATE_PPB_TALK_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_TALK_PRIVATE_H_ @@ -38,8 +38,8 @@ struct PPB_Talk_Private_1_0 { /** * Displays security UI. * - * The callback will be issued with PP_OK as the result of the user gave - * permission, or PP_ERROR_NOACCESS if the user denied. + * The callback will be issued with 1 as the result if the user gave + * permission, or 0 if the user denied. * * You can only have one call pending. It will return PP_OK_COMPLETIONPENDING * if the request is queued, or PP_ERROR_INPROGRESS if there is already a diff --git a/ppapi/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi index 601c021..9b98eba 100644 --- a/ppapi/ppapi_proxy.gypi +++ b/ppapi/ppapi_proxy.gypi @@ -105,8 +105,6 @@ 'proxy/ppb_network_monitor_private_proxy.h', 'proxy/ppb_pdf_proxy.cc', 'proxy/ppb_pdf_proxy.h', - 'proxy/ppb_talk_private_proxy.cc', - 'proxy/ppb_talk_private_proxy.h', 'proxy/ppb_tcp_server_socket_private_proxy.cc', 'proxy/ppb_tcp_server_socket_private_proxy.h', 'proxy/ppb_tcp_socket_private_proxy.cc', @@ -158,6 +156,8 @@ 'proxy/proxy_object_var.h', 'proxy/resource_creation_proxy.cc', 'proxy/resource_creation_proxy.h', + 'proxy/talk_resource.cc', + 'proxy/talk_resource.h', 'proxy/url_request_info_resource.cc', 'proxy/url_request_info_resource.h', 'proxy/url_response_info_resource.cc', @@ -193,11 +193,13 @@ 'proxy/ppb_flash_proxy.cc', 'proxy/ppb_pdf_proxy.cc', 'proxy/ppb_talk_private_proxy.cc', + 'proxy/ppb_video_capture_proxy.cc', 'proxy/ppb_video_decoder_proxy.cc', 'proxy/ppp_content_decryptor_private_proxy.cc', 'proxy/ppp_instance_private_proxy.cc', 'proxy/ppp_video_decoder_proxy.cc', 'proxy/serialized_flash_menu.cc', + 'proxy/talk_resource.cc', 'proxy/video_capture_resource.cc', ], }], diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc index 6f2ca2b..4b9e8e6 100644 --- a/ppapi/proxy/interface_list.cc +++ b/ppapi/proxy/interface_list.cc @@ -94,7 +94,6 @@ #include "ppapi/proxy/ppb_message_loop_proxy.h" #include "ppapi/proxy/ppb_network_monitor_private_proxy.h" #include "ppapi/proxy/ppb_pdf_proxy.h" -#include "ppapi/proxy/ppb_talk_private_proxy.h" #include "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h" #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" #include "ppapi/proxy/ppb_testing_proxy.h" diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 7ae4a0e..087540b 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -664,13 +664,6 @@ IPC_MESSAGE_ROUTED4(PpapiMsg_PPPContentDecryptor_DecryptAndDecode, PP_DecryptorStreamType /* decoder_type */, ppapi::proxy::PPPDecryptor_Buffer /* buffer */, std::string /* serialized_block_info */) - -// PPB_Talk -IPC_MESSAGE_ROUTED3( - PpapiMsg_PPBTalk_GetPermissionACK, - uint32 /* plugin_dispatcher_id */, - PP_Resource /* resource */, - int32_t /* result */) #endif // !defined(OS_NACL) && !defined(NACL_WIN64) // PPB_TCPSocket_Private. @@ -1246,13 +1239,6 @@ IPC_SYNC_MESSAGE_ROUTED2_1( ppapi::HostResource /* font_file */, uint32_t /* table */, std::string /* result */) - - -// PPB_Talk. -IPC_MESSAGE_ROUTED2( - PpapiHostMsg_PPBTalk_GetPermission, - uint32 /* plugin_dispatcher_id */, - PP_Resource /* resource */) #endif // !defined(OS_NACL) && !defined(NACL_WIN64) // PPB_Testing. @@ -1685,6 +1671,18 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_VideoCapture_Open, uint32_t /* buffer_count */) IPC_MESSAGE_CONTROL0(PpapiPluginMsg_VideoCapture_OpenReply) +// Talk ------------------------------------------------------------------------ + +IPC_MESSAGE_CONTROL0(PpapiHostMsg_Talk_Create) + +// Requests talk permissions. The host will respond with GetPermissionReply. +IPC_MESSAGE_CONTROL0(PpapiHostMsg_Talk_GetPermission) + +// Response to GetPermission. +// +// The result of this message is the general Pepper "result" in the ReplyParams. +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_Talk_GetPermissionReply) + // VideoCapture_Dev, host -> plugin IPC_MESSAGE_CONTROL3(PpapiPluginMsg_VideoCapture_OnDeviceInfo, PP_VideoCaptureDeviceInfo_Dev /* info */, diff --git a/ppapi/proxy/ppb_talk_private_proxy.cc b/ppapi/proxy/ppb_talk_private_proxy.cc deleted file mode 100644 index 1f647ea..0000000 --- a/ppapi/proxy/ppb_talk_private_proxy.cc +++ /dev/null @@ -1,91 +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/proxy/ppb_talk_private_proxy.h" - -#include "ipc/ipc_message_macros.h" -#include "ppapi/c/pp_errors.h" -#include "ppapi/proxy/plugin_dispatcher.h" -#include "ppapi/proxy/plugin_globals.h" -#include "ppapi/proxy/ppapi_messages.h" -#include "ppapi/shared_impl/resource.h" -#include "ppapi/shared_impl/tracked_callback.h" -#include "ppapi/thunk/enter.h" -#include "ppapi/thunk/ppb_talk_private_api.h" - -namespace ppapi { -namespace proxy { - -namespace { - -class Talk : public Resource, public thunk::PPB_Talk_Private_API { - public: - Talk(PP_Instance instance) : Resource(OBJECT_IS_PROXY, instance) { - } - - // Resource overrides. - thunk::PPB_Talk_Private_API* AsPPB_Talk_Private_API() { return this; } - - // PPB_Talk_API implementation. - int32_t GetPermission(scoped_refptr<TrackedCallback> callback) { - if (TrackedCallback::IsPending(callback_)) - return PP_ERROR_INPROGRESS; - PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( - pp_instance()); - if (!dispatcher) - return PP_ERROR_FAILED; - - callback_ = callback; - - if (PluginGlobals::Get()->GetBrowserSender()->Send( - new PpapiHostMsg_PPBTalk_GetPermission( - API_ID_PPB_TALK, - dispatcher->plugin_dispatcher_id(), - pp_resource()))) - return PP_OK_COMPLETIONPENDING; - return PP_ERROR_FAILED; - } - - void GotCompletion(int32_t result) { - callback_->Run(result); - } - - private: - scoped_refptr<TrackedCallback> callback_; - - DISALLOW_COPY_AND_ASSIGN(Talk); -}; - -} // namespace - -PPB_Talk_Private_Proxy::PPB_Talk_Private_Proxy(Dispatcher* dispatcher) - : InterfaceProxy(dispatcher) { -} - -// static -PP_Resource PPB_Talk_Private_Proxy::CreateProxyResource(PP_Instance instance) { - return (new Talk(instance))->GetReference(); -} - -bool PPB_Talk_Private_Proxy::OnMessageReceived(const IPC::Message& msg) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(PPB_Talk_Private_Proxy, msg) - IPC_MESSAGE_HANDLER(PpapiMsg_PPBTalk_GetPermissionACK, - OnMsgGetPermissionACK) - IPC_MESSAGE_UNHANDLED(handled = false); - IPC_END_MESSAGE_MAP(); - return handled; -} - -void PPB_Talk_Private_Proxy::OnMsgGetPermissionACK(uint32 /* dispatcher_id */, - PP_Resource resource, - int32_t result) { - thunk::EnterResourceNoLock<thunk::PPB_Talk_Private_API> enter( - resource, false); - if (enter.succeeded()) - static_cast<Talk*>(enter.object())->GotCompletion(result); -} - -} // namespace proxy -} // namespace ppapi diff --git a/ppapi/proxy/ppb_talk_private_proxy.h b/ppapi/proxy/ppb_talk_private_proxy.h deleted file mode 100644 index 62b0b80..0000000 --- a/ppapi/proxy/ppb_talk_private_proxy.h +++ /dev/null @@ -1,38 +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_PROXY_PPB_TALK_PRIVATE_PROXY_H_ -#define PPAPI_PROXY_PPB_TALK_PRIVATE_PROXY_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/proxy/interface_proxy.h" -#include "ppapi/shared_impl/api_id.h" - -namespace ppapi { -namespace proxy { - -class PPB_Talk_Private_Proxy : public InterfaceProxy { - public: - PPB_Talk_Private_Proxy(Dispatcher* dispatcher); - - static PP_Resource CreateProxyResource(PP_Instance instance); - - // InterfaceProxy implementation. - virtual bool OnMessageReceived(const IPC::Message& msg); - - static const ApiID kApiID = API_ID_PPB_TALK; - - private: - // Message handlers. - void OnMsgGetPermissionACK(uint32 dispatcher_id, - PP_Resource resource, - int32_t result); - - DISALLOW_COPY_AND_ASSIGN(PPB_Talk_Private_Proxy); -}; - -} // namespace proxy -} // namespace ppapi - -#endif // PPAPI_PROXY_PPB_TALK_PRIVATE_PROXY_H_ diff --git a/ppapi/proxy/resource_creation_proxy.cc b/ppapi/proxy/resource_creation_proxy.cc index 2d7b3ae..c37ff63 100644 --- a/ppapi/proxy/resource_creation_proxy.cc +++ b/ppapi/proxy/resource_creation_proxy.cc @@ -30,7 +30,6 @@ #include "ppapi/proxy/ppb_host_resolver_private_proxy.h" #include "ppapi/proxy/ppb_image_data_proxy.h" #include "ppapi/proxy/ppb_network_monitor_private_proxy.h" -#include "ppapi/proxy/ppb_talk_private_proxy.h" #include "ppapi/proxy/ppb_tcp_server_socket_private_proxy.h" #include "ppapi/proxy/ppb_tcp_socket_private_proxy.h" #include "ppapi/proxy/ppb_udp_socket_private_proxy.h" @@ -38,6 +37,7 @@ #include "ppapi/proxy/ppb_video_decoder_proxy.h" #include "ppapi/proxy/ppb_x509_certificate_private_proxy.h" #include "ppapi/proxy/printing_resource.h" +#include "ppapi/proxy/talk_resource.h" #include "ppapi/proxy/url_request_info_resource.h" #include "ppapi/proxy/url_response_info_resource.h" #include "ppapi/proxy/video_capture_resource.h" @@ -355,7 +355,7 @@ PP_Resource ResourceCreationProxy::CreateScrollbar(PP_Instance instance, } PP_Resource ResourceCreationProxy::CreateTalk(PP_Instance instance) { - return PPB_Talk_Private_Proxy::CreateProxyResource(instance); + return (new TalkResource(GetConnection(), instance))->GetReference(); } PP_Resource ResourceCreationProxy::CreateVideoCapture(PP_Instance instance) { diff --git a/ppapi/proxy/talk_resource.cc b/ppapi/proxy/talk_resource.cc new file mode 100644 index 0000000..557e306 --- /dev/null +++ b/ppapi/proxy/talk_resource.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/proxy/talk_resource.h" + +#include "ppapi/proxy/ppapi_messages.h" + +namespace ppapi { +namespace proxy { + +TalkResource::TalkResource(Connection connection, PP_Instance instance) + : PluginResource(connection, instance) { +} + +TalkResource::~TalkResource() { +} + +thunk::PPB_Talk_Private_API* TalkResource::AsPPB_Talk_Private_API() { + return this; +} + +int32_t TalkResource::GetPermission(scoped_refptr<TrackedCallback> callback) { + if (TrackedCallback::IsPending(callback_)) + return PP_ERROR_INPROGRESS; + callback_ = callback; + + if (!sent_create_to_browser()) + SendCreate(BROWSER, PpapiHostMsg_Talk_Create()); + + Call<PpapiPluginMsg_Talk_GetPermissionReply>( + BROWSER, + PpapiHostMsg_Talk_GetPermission(), + base::Bind(&TalkResource::GetPermissionReply, base::Unretained(this))); + return PP_OK_COMPLETIONPENDING; +} + +void TalkResource::GetPermissionReply( + const ResourceMessageReplyParams& params) { + callback_->Run(params.result()); +} + +} // namespace proxy +} // namespace ppapi diff --git a/ppapi/proxy/talk_resource.h b/ppapi/proxy/talk_resource.h new file mode 100644 index 0000000..c73f458 --- /dev/null +++ b/ppapi/proxy/talk_resource.h @@ -0,0 +1,41 @@ +// 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_PROXY_TALK_RESOURCE_H_ +#define PPAPI_PROXY_TALK_RESOURCE_H_ + +#include "ppapi/proxy/plugin_resource.h" +#include "ppapi/proxy/ppapi_proxy_export.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/ppb_talk_private_api.h" + +namespace ppapi { +namespace proxy { + +class PPAPI_PROXY_EXPORT TalkResource + : public PluginResource, + public NON_EXPORTED_BASE(thunk::PPB_Talk_Private_API) { + public: + TalkResource(Connection connection, PP_Instance instance); + virtual ~TalkResource(); + + // Resource overrides. + thunk::PPB_Talk_Private_API* AsPPB_Talk_Private_API(); + + // PPB_Talk_API implementation. + virtual int32_t GetPermission( + scoped_refptr<TrackedCallback> callback) OVERRIDE; + + private: + void GetPermissionReply(const ResourceMessageReplyParams& params); + + scoped_refptr<TrackedCallback> callback_; + + DISALLOW_COPY_AND_ASSIGN(TalkResource); +}; + +} // namespace proxy +} // namespace ppapi + +#endif // PPAPI_PROXY_TALK_RESOURCE_H_ diff --git a/ppapi/thunk/interfaces_ppb_private.h b/ppapi/thunk/interfaces_ppb_private.h index ac06344..48df662 100644 --- a/ppapi/thunk/interfaces_ppb_private.h +++ b/ppapi/thunk/interfaces_ppb_private.h @@ -17,7 +17,6 @@ PROXIED_IFACE(PPB_X509Certificate_Private, #if !defined(OS_NACL) PROXIED_API(PPB_Broker) -PROXIED_API(PPB_Talk_Private) PROXIED_IFACE(PPB_Broker, PPB_BROKER_TRUSTED_INTERFACE_0_2, PPB_BrokerTrusted_0_2) @@ -41,7 +40,8 @@ PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE_0_1, PPB_FlashFullscreen_0_1) PROXIED_IFACE(PPB_Instance, PPB_FLASHFULLSCREEN_INTERFACE_1_0, PPB_FlashFullscreen_0_1) -PROXIED_IFACE(PPB_Talk_Private, PPB_TALK_PRIVATE_INTERFACE_1_0, + +PROXIED_IFACE(NoAPIName, PPB_TALK_PRIVATE_INTERFACE_1_0, PPB_Talk_Private_1_0) // Hack to keep font working. The Font 0.6 API is binary compatible with |