| 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" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 | 155 |
| 156 // We already have an open channel, send a request right away to plugin. | 156 // We already have an open channel, send a request right away to plugin. |
| 157 RequestPluginChannel(client); | 157 RequestPluginChannel(client); |
| 158 } | 158 } |
| 159 | 159 |
| 160 PpapiPluginProcessHost::PpapiPluginProcessHost( | 160 PpapiPluginProcessHost::PpapiPluginProcessHost( |
| 161 const content::PepperPluginInfo& info, | 161 const content::PepperPluginInfo& info, |
| 162 const FilePath& profile_data_directory, | 162 const FilePath& profile_data_directory, |
| 163 net::HostResolver* host_resolver) | 163 net::HostResolver* host_resolver) |
| 164 : network_observer_(new PluginNetworkObserver(this)), | 164 : permissions_( |
| 165 ppapi::PpapiPermissions::GetForCommandLine(info.permissions)), |
| 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 |