| 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/browser/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/browser_child_process_host_impl.h" | 14 #include "content/browser/browser_child_process_host_impl.h" |
| 15 #include "content/browser/plugin_service_impl.h" | 15 #include "content/browser/plugin_service_impl.h" |
| 16 #include "content/browser/renderer_host/render_message_filter.h" | 16 #include "content/browser/renderer_host/render_message_filter.h" |
| 17 #include "content/common/child_process_host_impl.h" | 17 #include "content/common/child_process_host_impl.h" |
| 18 #include "content/common/child_process_messages.h" | 18 #include "content/common/child_process_messages.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/pepper_plugin_info.h" | 21 #include "content/public/common/pepper_plugin_info.h" |
| 22 #include "content/public/common/pepper_permissions_config.h" |
| 22 #include "content/public/common/process_type.h" | 23 #include "content/public/common/process_type.h" |
| 23 #include "ipc/ipc_switches.h" | 24 #include "ipc/ipc_switches.h" |
| 24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| 25 #include "ppapi/proxy/ppapi_messages.h" | 26 #include "ppapi/proxy/ppapi_messages.h" |
| 26 #include "ui/base/ui_base_switches.h" | 27 #include "ui/base/ui_base_switches.h" |
| 27 #include "webkit/plugins/plugin_switches.h" | 28 #include "webkit/plugins/plugin_switches.h" |
| 28 | 29 |
| 29 using content::ChildProcessHost; | 30 using content::ChildProcessHost; |
| 30 using content::ChildProcessHostImpl; | 31 using content::ChildProcessHostImpl; |
| 31 | 32 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 155 } |
| 155 | 156 |
| 156 // We already have an open channel, send a request right away to plugin. | 157 // We already have an open channel, send a request right away to plugin. |
| 157 RequestPluginChannel(client); | 158 RequestPluginChannel(client); |
| 158 } | 159 } |
| 159 | 160 |
| 160 PpapiPluginProcessHost::PpapiPluginProcessHost( | 161 PpapiPluginProcessHost::PpapiPluginProcessHost( |
| 161 const content::PepperPluginInfo& info, | 162 const content::PepperPluginInfo& info, |
| 162 const FilePath& profile_data_directory, | 163 const FilePath& profile_data_directory, |
| 163 net::HostResolver* host_resolver) | 164 net::HostResolver* host_resolver) |
| 164 : network_observer_(new PluginNetworkObserver(this)), | 165 : permissions_(content::CreatePepperPermissionsForPlugin(info)), |
| 166 network_observer_(new PluginNetworkObserver(this)), |
| 165 profile_data_directory_(profile_data_directory), | 167 profile_data_directory_(profile_data_directory), |
| 166 is_broker_(false) { | 168 is_broker_(false) { |
| 167 process_.reset(new BrowserChildProcessHostImpl( | 169 process_.reset(new BrowserChildProcessHostImpl( |
| 168 content::PROCESS_TYPE_PPAPI_PLUGIN, this)); | 170 content::PROCESS_TYPE_PPAPI_PLUGIN, this)); |
| 169 | 171 |
| 170 filter_ = new PepperMessageFilter(PepperMessageFilter::PLUGIN, | 172 filter_ = new PepperMessageFilter(PepperMessageFilter::PLUGIN, |
| 171 host_resolver); | 173 host_resolver); |
| 172 | 174 |
| 173 ppapi::PpapiPermissions permissions(info.permissions); | 175 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions_); |
| 174 host_impl_ = new content::BrowserPpapiHostImpl(this, permissions); | |
| 175 | 176 |
| 176 file_filter_ = new PepperTrustedFileMessageFilter( | 177 file_filter_ = new PepperTrustedFileMessageFilter( |
| 177 process_->GetData().id, info.name, profile_data_directory); | 178 process_->GetData().id, info.name, profile_data_directory); |
| 178 | 179 |
| 179 process_->GetHost()->AddFilter(filter_.get()); | 180 process_->GetHost()->AddFilter(filter_.get()); |
| 180 process_->GetHost()->AddFilter(file_filter_.get()); | 181 process_->GetHost()->AddFilter(file_filter_.get()); |
| 181 process_->GetHost()->AddFilter(host_impl_.get()); | 182 process_->GetHost()->AddFilter(host_impl_.get()); |
| 182 | 183 |
| 183 content::GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_); | 184 content::GetContentClient()->browser()->DidCreatePpapiPlugin(host_impl_); |
| 184 } | 185 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 IPC_END_MESSAGE_MAP() | 309 IPC_END_MESSAGE_MAP() |
| 309 DCHECK(handled); | 310 DCHECK(handled); |
| 310 return handled; | 311 return handled; |
| 311 } | 312 } |
| 312 | 313 |
| 313 // Called when the browser <--> plugin channel has been established. | 314 // Called when the browser <--> plugin channel has been established. |
| 314 void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) { | 315 void PpapiPluginProcessHost::OnChannelConnected(int32 peer_pid) { |
| 315 // This will actually load the plugin. Errors will actually not be reported | 316 // This will actually load the plugin. Errors will actually not be reported |
| 316 // back at this point. Instead, the plugin will fail to establish the | 317 // back at this point. Instead, the plugin will fail to establish the |
| 317 // connections when we request them on behalf of the renderer(s). | 318 // connections when we request them on behalf of the renderer(s). |
| 318 Send(new PpapiMsg_LoadPlugin(plugin_path_)); | 319 Send(new PpapiMsg_LoadPlugin(plugin_path_, permissions_)); |
| 319 | 320 |
| 320 // Process all pending channel requests from the renderers. | 321 // Process all pending channel requests from the renderers. |
| 321 for (size_t i = 0; i < pending_requests_.size(); i++) | 322 for (size_t i = 0; i < pending_requests_.size(); i++) |
| 322 RequestPluginChannel(pending_requests_[i]); | 323 RequestPluginChannel(pending_requests_[i]); |
| 323 pending_requests_.clear(); | 324 pending_requests_.clear(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 // Called when the browser <--> plugin channel has an error. This normally | 327 // Called when the browser <--> plugin channel has an error. This normally |
| 327 // means the plugin has crashed. | 328 // means the plugin has crashed. |
| 328 void PpapiPluginProcessHost::OnChannelError() { | 329 void PpapiPluginProcessHost::OnChannelError() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 355 if (sent_requests_.empty()) | 356 if (sent_requests_.empty()) |
| 356 return; | 357 return; |
| 357 | 358 |
| 358 // All requests should be processed FIFO, so the next item in the | 359 // All requests should be processed FIFO, so the next item in the |
| 359 // sent_requests_ queue should be the one that the plugin just created. | 360 // sent_requests_ queue should be the one that the plugin just created. |
| 360 Client* client = sent_requests_.front(); | 361 Client* client = sent_requests_.front(); |
| 361 sent_requests_.pop(); | 362 sent_requests_.pop(); |
| 362 | 363 |
| 363 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); | 364 client->OnPpapiChannelOpened(channel_handle, process_->GetData().id); |
| 364 } | 365 } |
| OLD | NEW |