OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/pepper_gtalk_message_filter.h" |
| 6 |
| 7 #include "chrome/browser/simple_message_box.h" |
| 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "grit/generated_resources.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" |
| 11 #include "ppapi/shared_impl/api_id.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
| 13 |
| 14 #if defined(USE_AURA) |
| 15 #include "ash/shell.h" |
| 16 #include "ash/shell_window_ids.h" |
| 17 #include "ui/aura/window.h" |
| 18 #endif |
| 19 |
| 20 PepperGtalkMessageFilter::PepperGtalkMessageFilter() { |
| 21 } |
| 22 |
| 23 PepperGtalkMessageFilter::~PepperGtalkMessageFilter() {} |
| 24 |
| 25 void PepperGtalkMessageFilter::OverrideThreadForMessage( |
| 26 const IPC::Message& message, |
| 27 content::BrowserThread::ID* thread) { |
| 28 if (message.type() == PpapiHostMsg_PPBTalk_GetPermission::ID) { |
| 29 *thread = content::BrowserThread::UI; |
| 30 } |
| 31 } |
| 32 |
| 33 bool PepperGtalkMessageFilter::OnMessageReceived(const IPC::Message& msg, |
| 34 bool* message_was_ok) { |
| 35 bool handled = true; |
| 36 IPC_BEGIN_MESSAGE_MAP_EX(PepperGtalkMessageFilter, msg, *message_was_ok) |
| 37 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTalk_GetPermission, OnTalkGetPermission) |
| 38 IPC_MESSAGE_UNHANDLED(handled = false) |
| 39 IPC_END_MESSAGE_MAP_EX() |
| 40 return handled; |
| 41 } |
| 42 |
| 43 void PepperGtalkMessageFilter::OnTalkGetPermission(uint32 plugin_dispatcher_id, |
| 44 PP_Resource resource) { |
| 45 |
| 46 bool user_response = false; |
| 47 #if defined(USE_AURA) |
| 48 string16 title = l10n_util::GetStringUTF16( |
| 49 IDS_GTALK_SCREEN_SHARE_DIALOG_TITLE); |
| 50 string16 message = l10n_util::GetStringUTF16( |
| 51 IDS_GTALK_SCREEN_SHARE_DIALOG_MESSAGE); |
| 52 |
| 53 aura::Window* parent = ash::Shell::GetInstance()->GetContainer( |
| 54 ash::internal::kShellWindowId_SystemModalContainer); |
| 55 user_response = browser::ShowYesNoBox(parent, title, message); |
| 56 #endif |
| 57 Send(new PpapiMsg_PPBTalk_GetPermissionACK(ppapi::API_ID_PPB_TALK, |
| 58 plugin_dispatcher_id, |
| 59 resource, |
| 60 user_response)); |
| 61 } |
OLD | NEW |