OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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/renderer_host/pepper/pepper_extensions_common_message_f
ilter.h" |
| 6 |
| 7 #include "base/values.h" |
| 8 #include "content/public/browser/browser_ppapi_host.h" |
| 9 #include "content/public/browser/browser_thread.h" |
| 10 #include "ipc/ipc_message.h" |
| 11 #include "ipc/ipc_message_macros.h" |
| 12 #include "ppapi/c/pp_errors.h" |
| 13 #include "ppapi/host/dispatch_host_message.h" |
| 14 #include "ppapi/host/host_message_context.h" |
| 15 #include "ppapi/proxy/ppapi_messages.h" |
| 16 |
| 17 namespace chrome { |
| 18 |
| 19 // static |
| 20 PepperExtensionsCommonMessageFilter* |
| 21 PepperExtensionsCommonMessageFilter::Create(content::BrowserPpapiHost* host, |
| 22 PP_Instance instance) { |
| 23 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 24 |
| 25 int render_process_id = 0; |
| 26 int render_view_id = 0; |
| 27 if (!host->GetRenderViewIDsForInstance(instance, &render_process_id, |
| 28 &render_view_id)) { |
| 29 return NULL; |
| 30 } |
| 31 |
| 32 base::FilePath profile_directory = host->GetProfileDataDirectory(); |
| 33 GURL document_url = host->GetDocumentURLForInstance(instance); |
| 34 |
| 35 return new PepperExtensionsCommonMessageFilter(render_process_id, |
| 36 render_view_id, |
| 37 profile_directory, |
| 38 document_url); |
| 39 } |
| 40 |
| 41 PepperExtensionsCommonMessageFilter::PepperExtensionsCommonMessageFilter( |
| 42 int render_process_id, |
| 43 int render_view_id, |
| 44 const base::FilePath& profile_directory, |
| 45 const GURL& document_url) |
| 46 : render_process_id_(render_process_id), |
| 47 render_view_id_(render_view_id), |
| 48 profile_directory_(profile_directory), |
| 49 document_url_(document_url) { |
| 50 } |
| 51 |
| 52 PepperExtensionsCommonMessageFilter::~PepperExtensionsCommonMessageFilter() { |
| 53 } |
| 54 |
| 55 scoped_refptr<base::TaskRunner> |
| 56 PepperExtensionsCommonMessageFilter::OverrideTaskRunnerForMessage( |
| 57 const IPC::Message& msg) { |
| 58 return content::BrowserThread::GetMessageLoopProxyForThread( |
| 59 content::BrowserThread::UI); |
| 60 } |
| 61 |
| 62 int32_t PepperExtensionsCommonMessageFilter::OnResourceMessageReceived( |
| 63 const IPC::Message& msg, |
| 64 ppapi::host::HostMessageContext* context) { |
| 65 IPC_BEGIN_MESSAGE_MAP(PepperExtensionsCommonMessageFilter, msg) |
| 66 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, |
| 67 OnPost) |
| 68 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, |
| 69 OnCall) |
| 70 IPC_END_MESSAGE_MAP() |
| 71 return PP_ERROR_FAILED; |
| 72 } |
| 73 |
| 74 int32_t PepperExtensionsCommonMessageFilter::OnPost( |
| 75 ppapi::host::HostMessageContext* context, |
| 76 const std::string& request_name, |
| 77 base::ListValue& args) { |
| 78 // TODO(yzshen): Implement it. |
| 79 return PP_ERROR_FAILED; |
| 80 } |
| 81 |
| 82 int32_t PepperExtensionsCommonMessageFilter::OnCall( |
| 83 ppapi::host::HostMessageContext* context, |
| 84 const std::string& request_name, |
| 85 base::ListValue& args) { |
| 86 // TODO(yzshen): Implement it. |
| 87 return PP_ERROR_FAILED; |
| 88 } |
| 89 |
| 90 } // namespace chrome |
OLD | NEW |