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 "content/renderer/pepper/pepper_in_process_resource_creation.h" | 5 #include "content/renderer/pepper/pepper_in_process_resource_creation.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "content/renderer/render_view_impl.h" | 10 #include "content/renderer/render_view_impl.h" |
11 #include "content/renderer/pepper/pepper_in_process_router.h" | 11 #include "content/renderer/pepper/pepper_in_process_router.h" |
12 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 12 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
14 #include "ipc/ipc_message_macros.h" | 14 #include "ipc/ipc_message_macros.h" |
15 #include "ppapi/host/ppapi_host.h" | 15 #include "ppapi/host/ppapi_host.h" |
16 #include "ppapi/proxy/browser_font_resource_trusted.h" | |
16 #include "ppapi/proxy/file_chooser_resource.h" | 17 #include "ppapi/proxy/file_chooser_resource.h" |
17 #include "ppapi/proxy/ppapi_messages.h" | 18 #include "ppapi/proxy/ppapi_messages.h" |
18 #include "ppapi/proxy/printing_resource.h" | 19 #include "ppapi/proxy/printing_resource.h" |
19 #include "ppapi/proxy/url_request_info_resource.h" | 20 #include "ppapi/proxy/url_request_info_resource.h" |
20 #include "ppapi/proxy/url_response_info_resource.h" | 21 #include "ppapi/proxy/url_response_info_resource.h" |
21 #include "ppapi/proxy/websocket_resource.h" | 22 #include "ppapi/proxy/websocket_resource.h" |
22 #include "ppapi/shared_impl/ppapi_globals.h" | 23 #include "ppapi/shared_impl/ppapi_globals.h" |
23 #include "ppapi/shared_impl/ppapi_permissions.h" | 24 #include "ppapi/shared_impl/ppapi_permissions.h" |
24 #include "ppapi/shared_impl/resource_tracker.h" | 25 #include "ppapi/shared_impl/resource_tracker.h" |
25 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 26 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
26 | 27 |
27 // Note that the code in the creation functions in this file should generally | 28 // Note that the code in the creation functions in this file should generally |
28 // be the same as that in ppapi/proxy/resource_creation_proxy.cc. See | 29 // be the same as that in ppapi/proxy/resource_creation_proxy.cc. See |
29 // pepper_in_process_resource_creation.h for what this file is for. | 30 // pepper_in_process_resource_creation.h for what this file is for. |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 | 33 |
33 // PepperInProcessResourceCreation -------------------------------------------- | 34 // PepperInProcessResourceCreation -------------------------------------------- |
34 | 35 |
35 PepperInProcessResourceCreation::PepperInProcessResourceCreation( | 36 PepperInProcessResourceCreation::PepperInProcessResourceCreation( |
36 RendererPpapiHostImpl* host_impl, | 37 RendererPpapiHostImpl* host_impl, |
37 webkit::ppapi::PluginInstance* instance) | 38 webkit::ppapi::PluginInstance* instance) |
38 : ResourceCreationImpl(instance), | 39 : ResourceCreationImpl(instance), |
39 host_impl_(host_impl) { | 40 host_impl_(host_impl) { |
40 } | 41 } |
41 | 42 |
42 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { | 43 PepperInProcessResourceCreation::~PepperInProcessResourceCreation() { |
43 } | 44 } |
44 | 45 |
46 PP_Resource PepperInProcessResourceCreation::CreateBrowserFont( | |
47 PP_Instance instance, | |
48 const PP_BrowserFont_Trusted_Description* description) { | |
49 ppapi::Preferences prefs( | |
50 host_impl_->GetRenderViewForInstance(instance)->GetWebkitPreferences()); | |
51 scoped_refptr<ppapi::proxy::BrowserFontResource_Trusted> font( | |
52 new ppapi::proxy::BrowserFontResource_Trusted( | |
53 host_impl_->in_process_router()->GetPluginConnection(), | |
54 instance, | |
55 *description, | |
56 prefs)); | |
57 if (!ppapi::proxy::BrowserFontResource_Trusted::IsPPFontDescriptionValid( | |
brettw
2012/11/26 23:50:37
Can you do this at the beginning of the function?
victorhsieh
2012/11/27 03:00:50
Done.
| |
58 *description)) | |
59 return 0; | |
60 return font->GetReference(); | |
61 } | |
62 | |
45 PP_Resource PepperInProcessResourceCreation::CreateFileChooser( | 63 PP_Resource PepperInProcessResourceCreation::CreateFileChooser( |
46 PP_Instance instance, | 64 PP_Instance instance, |
47 PP_FileChooserMode_Dev mode, | 65 PP_FileChooserMode_Dev mode, |
48 const char* accept_types) { | 66 const char* accept_types) { |
49 return (new ppapi::proxy::FileChooserResource( | 67 return (new ppapi::proxy::FileChooserResource( |
50 host_impl_->in_process_router()->GetPluginConnection(), | 68 host_impl_->in_process_router()->GetPluginConnection(), |
51 instance, mode, accept_types))->GetReference(); | 69 instance, mode, accept_types))->GetReference(); |
52 } | 70 } |
53 | 71 |
54 PP_Resource PepperInProcessResourceCreation::CreatePrinting( | 72 PP_Resource PepperInProcessResourceCreation::CreatePrinting( |
(...skipping 21 matching lines...) Expand all Loading... | |
76 } | 94 } |
77 | 95 |
78 PP_Resource PepperInProcessResourceCreation::CreateWebSocket( | 96 PP_Resource PepperInProcessResourceCreation::CreateWebSocket( |
79 PP_Instance instance) { | 97 PP_Instance instance) { |
80 return (new ppapi::proxy::WebSocketResource( | 98 return (new ppapi::proxy::WebSocketResource( |
81 host_impl_->in_process_router()->GetPluginConnection(), | 99 host_impl_->in_process_router()->GetPluginConnection(), |
82 instance))->GetReference(); | 100 instance))->GetReference(); |
83 } | 101 } |
84 | 102 |
85 } // namespace content | 103 } // namespace content |
OLD | NEW |