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 PepperExtensionsCommonMessageFilter* | |
raymes
2013/05/08 18:28:56
please add a // static comment
yzshen1
2013/05/08 19:38:18
Done.
| |
20 PepperExtensionsCommonMessageFilter::Create(content::BrowserPpapiHost* host, | |
21 PP_Instance instance) { | |
22 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | |
23 | |
24 int render_process_id = 0; | |
25 int render_view_id = 0; | |
26 if (!host->GetRenderViewIDsForInstance(instance, &render_process_id, | |
27 &render_view_id)) { | |
28 return NULL; | |
29 } | |
30 | |
31 base::FilePath profile_directory = host->GetProfileDataDirectory(); | |
32 GURL document_url = host->GetDocumentURLForInstance(instance); | |
33 | |
34 return new PepperExtensionsCommonMessageFilter(render_process_id, | |
35 render_view_id, | |
36 profile_directory, | |
37 document_url); | |
38 } | |
39 | |
40 PepperExtensionsCommonMessageFilter::PepperExtensionsCommonMessageFilter( | |
41 int render_process_id, | |
42 int render_view_id, | |
43 const base::FilePath& profile_directory, | |
44 const GURL& document_url) | |
45 : render_process_id_(render_process_id), | |
46 render_view_id_(render_view_id), | |
47 profile_directory_(profile_directory), | |
48 document_url_(document_url) { | |
49 } | |
50 | |
51 PepperExtensionsCommonMessageFilter::~PepperExtensionsCommonMessageFilter() { | |
52 } | |
53 | |
54 scoped_refptr<base::TaskRunner> | |
55 PepperExtensionsCommonMessageFilter::OverrideTaskRunnerForMessage( | |
56 const IPC::Message& msg) { | |
57 return content::BrowserThread::GetMessageLoopProxyForThread( | |
58 content::BrowserThread::UI); | |
59 } | |
60 | |
61 int32_t PepperExtensionsCommonMessageFilter::OnResourceMessageReceived( | |
62 const IPC::Message& msg, | |
63 ppapi::host::HostMessageContext* context) { | |
64 IPC_BEGIN_MESSAGE_MAP(PepperExtensionsCommonMessageFilter, msg) | |
65 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Post, | |
66 OnPost) | |
67 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_ExtensionsCommon_Call, | |
68 OnCall) | |
69 IPC_END_MESSAGE_MAP() | |
70 return PP_ERROR_FAILED; | |
71 } | |
72 | |
73 int32_t PepperExtensionsCommonMessageFilter::OnPost( | |
74 ppapi::host::HostMessageContext* context, | |
75 const std::string& request_name, | |
76 base::ListValue& args) { | |
77 // TODO(yzshen): Implement it. | |
78 return PP_ERROR_FAILED; | |
79 } | |
80 | |
81 int32_t PepperExtensionsCommonMessageFilter::OnCall( | |
82 ppapi::host::HostMessageContext* context, | |
83 const std::string& request_name, | |
84 base::ListValue& args) { | |
85 // TODO(yzshen): Implement it. | |
86 return PP_ERROR_FAILED; | |
87 } | |
88 | |
89 } // namespace chrome | |
OLD | NEW |