Chromium Code Reviews| Index: chrome/browser/pepper_gtalk_message_filter.cc |
| diff --git a/chrome/browser/pepper_gtalk_message_filter.cc b/chrome/browser/pepper_gtalk_message_filter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f03098cb8aee6dd649b444adbe0c40727a4009cc |
| --- /dev/null |
| +++ b/chrome/browser/pepper_gtalk_message_filter.cc |
| @@ -0,0 +1,61 @@ |
| +// 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 "chrome/browser/simple_message_box.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "grit/generated_resources.h" |
| +#include "ipc/ipc_message_macros.h" |
| +#include "ppapi/proxy/ppapi_messages.h" |
| +#include "ppapi/shared_impl/api_id.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| + |
| +PepperGtalkMessageFilter::PepperGtalkMessageFilter() { |
| +} |
| + |
| +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; |
| +} |
| + |
| +void PepperGtalkMessageFilter::OnTalkGetPermission(uint32 plugin_dispatcher_id, |
| + PP_Resource resource, |
| + int renderer_id) { |
| + |
| + bool user_response = false; |
| +#if defined(USE_AURA) |
| + string16 title = l10n_util::GetStringUTF16( |
| + IDS_GTALK_SCREEN_SHARE_DIALOG_TITLE); |
| + string16 message = l10n_util::GetStringUTF16( |
| + IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE); |
| + |
| + // TODO(varunjain): use the renderer_id to get current renderer. |
|
jam
2012/03/16 21:49:45
why is this a todo?
to get the current TabContent
|
| + user_response = browser::ShowYesNoBox( |
| + BrowserList::GetLastActive()->window()->GetNativeHandle(), title, |
| + message); |
| +#endif |
| + Send(new PpapiMsg_PPBTalk_GetPermissionACK(ppapi::API_ID_PPB_TALK, |
| + plugin_dispatcher_id, |
| + resource, |
| + user_response)); |
| +} |