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