| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); | 370 base::FilePath exe_path = ChildProcessHost::GetChildPath(flags); |
| 371 if (exe_path.empty()) { | 371 if (exe_path.empty()) { |
| 372 VLOG(1) << "Pepper plugin exe path is empty."; | 372 VLOG(1) << "Pepper plugin exe path is empty."; |
| 373 return false; | 373 return false; |
| 374 } | 374 } |
| 375 | 375 |
| 376 base::CommandLine* cmd_line = new base::CommandLine(exe_path); | 376 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
| 377 cmd_line->AppendSwitchASCII(switches::kProcessType, | 377 cmd_line->AppendSwitchASCII(switches::kProcessType, |
| 378 is_broker_ ? switches::kPpapiBrokerProcess | 378 is_broker_ ? switches::kPpapiBrokerProcess |
| 379 : switches::kPpapiPluginProcess); | 379 : switches::kPpapiPluginProcess); |
| 380 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); |
| 380 | 381 |
| 381 #if defined(OS_WIN) | 382 #if defined(OS_WIN) |
| 382 cmd_line->AppendArg(is_broker_ ? switches::kPrefetchArgumentPpapiBroker | 383 cmd_line->AppendArg(is_broker_ ? switches::kPrefetchArgumentPpapiBroker |
| 383 : switches::kPrefetchArgumentPpapi); | 384 : switches::kPrefetchArgumentPpapi); |
| 384 #endif // defined(OS_WIN) | 385 #endif // defined(OS_WIN) |
| 385 | 386 |
| 386 // These switches are forwarded to both plugin and broker pocesses. | 387 // These switches are forwarded to both plugin and broker pocesses. |
| 387 static const char* const kCommonForwardSwitches[] = { | 388 static const char* const kCommonForwardSwitches[] = { |
| 388 switches::kVModule | 389 switches::kVModule |
| 389 }; | 390 }; |
| 390 cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches, | 391 cmd_line->CopySwitchesFrom(browser_command_line, kCommonForwardSwitches, |
| 391 arraysize(kCommonForwardSwitches)); | 392 arraysize(kCommonForwardSwitches)); |
| 392 | 393 |
| 393 if (!is_broker_) { | 394 if (!is_broker_) { |
| 394 static const char* const kPluginForwardSwitches[] = { | 395 static const char* const kPluginForwardSwitches[] = { |
| 395 switches::kDisableSeccompFilterSandbox, | 396 switches::kDisableSeccompFilterSandbox, |
| 396 #if defined(OS_MACOSX) | 397 #if defined(OS_MACOSX) |
| 397 switches::kEnableSandboxLogging, | 398 switches::kEnableSandboxLogging, |
| 398 #endif | 399 #endif |
| 399 switches::kNoSandbox, | 400 switches::kNoSandbox, |
| 400 switches::kPpapiStartupDialog, | 401 switches::kPpapiStartupDialog, |
| 401 }; | 402 }; |
| 402 cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches, | 403 cmd_line->CopySwitchesFrom(browser_command_line, kPluginForwardSwitches, |
| 403 arraysize(kPluginForwardSwitches)); | 404 arraysize(kPluginForwardSwitches)); |
| 404 | 405 |
| 405 // Copy any flash args over and introduce field trials if necessary. | 406 // Copy any flash args over if necessary. |
| 406 // TODO(vtl): Stop passing flash args in the command line, or windows is | 407 // TODO(vtl): Stop passing flash args in the command line, or windows is |
| 407 // going to explode. | 408 // going to explode. |
| 408 std::string existing_args = | 409 std::string existing_args = |
| 409 browser_command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs); | 410 browser_command_line.GetSwitchValueASCII(switches::kPpapiFlashArgs); |
| 410 cmd_line->AppendSwitchASCII(switches::kPpapiFlashArgs, existing_args); | 411 cmd_line->AppendSwitchASCII(switches::kPpapiFlashArgs, existing_args); |
| 411 } | 412 } |
| 412 | 413 |
| 413 std::string locale = GetContentClient()->browser()->GetApplicationLocale(); | 414 std::string locale = GetContentClient()->browser()->GetApplicationLocale(); |
| 414 if (!locale.empty()) { | 415 if (!locale.empty()) { |
| 415 // Pass on the locale so the plugin will know what language we're using. | 416 // Pass on the locale so the plugin will know what language we're using. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 void PpapiPluginProcessHost::OnProcessCrashed(int exit_code) { | 473 void PpapiPluginProcessHost::OnProcessCrashed(int exit_code) { |
| 473 VLOG(1) << "ppapi plugin process crashed."; | 474 VLOG(1) << "ppapi plugin process crashed."; |
| 474 PluginServiceImpl::GetInstance()->RegisterPluginCrash(plugin_path_); | 475 PluginServiceImpl::GetInstance()->RegisterPluginCrash(plugin_path_); |
| 475 } | 476 } |
| 476 | 477 |
| 477 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { | 478 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 478 bool handled = true; | 479 bool handled = true; |
| 479 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) | 480 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) |
| 480 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, | 481 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, |
| 481 OnRendererPluginChannelCreated) | 482 OnRendererPluginChannelCreated) |
| 483 IPC_MESSAGE_HANDLER(PpapiHostMsg_FieldTrialActivated, |
| 484 OnFieldTrialActivated); |
| 482 IPC_MESSAGE_UNHANDLED(handled = false) | 485 IPC_MESSAGE_UNHANDLED(handled = false) |
| 483 IPC_END_MESSAGE_MAP() | 486 IPC_END_MESSAGE_MAP() |
| 484 DCHECK(handled); | 487 DCHECK(handled); |
| 485 return handled; | 488 return handled; |
| 486 } | 489 } |
| 487 | 490 |
| 488 // Called when the browser <--> plugin channel has been established. | 491 // Called when the browser <--> plugin channel has been established. |
| 489 void PpapiPluginProcessHost::OnChannelConnected(int32_t peer_pid) { | 492 void PpapiPluginProcessHost::OnChannelConnected(int32_t peer_pid) { |
| 490 // This will actually load the plugin. Errors will actually not be reported | 493 // This will actually load the plugin. Errors will actually not be reported |
| 491 // back at this point. Instead, the plugin will fail to establish the | 494 // back at this point. Instead, the plugin will fail to establish the |
| 492 // connections when we request them on behalf of the renderer(s). | 495 // connections when we request them on behalf of the renderer(s). |
| 493 Send(new PpapiMsg_LoadPlugin(plugin_path_, permissions_)); | 496 Send(new PpapiMsg_LoadPlugin(plugin_path_, permissions_)); |
| 494 | 497 |
| 495 // Process all pending channel requests from the renderers. | 498 // Process all pending channel requests from the renderers. |
| 496 for (size_t i = 0; i < pending_requests_.size(); i++) | 499 for (size_t i = 0; i < pending_requests_.size(); i++) |
| 497 RequestPluginChannel(pending_requests_[i]); | 500 RequestPluginChannel(pending_requests_[i]); |
| 498 pending_requests_.clear(); | 501 pending_requests_.clear(); |
| 499 } | 502 } |
| 500 | 503 |
| 504 void PpapiPluginProcessHost::OnFieldTrialActivated( |
| 505 const std::string& trial_name) { |
| 506 // Activate the trial in the browser process to match its state in the |
| 507 // PPAPI process. This is done by calling FindFullName which finalizes the |
| 508 // group and activates the trial. |
| 509 base::FieldTrialList::FindFullName(trial_name); |
| 510 } |
| 511 |
| 501 // Called when the browser <--> plugin channel has an error. This normally | 512 // Called when the browser <--> plugin channel has an error. This normally |
| 502 // means the plugin has crashed. | 513 // means the plugin has crashed. |
| 503 void PpapiPluginProcessHost::OnChannelError() { | 514 void PpapiPluginProcessHost::OnChannelError() { |
| 504 VLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") | 515 VLOG(1) << "PpapiPluginProcessHost" << (is_broker_ ? "[broker]" : "") |
| 505 << "::OnChannelError()"; | 516 << "::OnChannelError()"; |
| 506 // We don't need to notify the renderers that were communicating with the | 517 // We don't need to notify the renderers that were communicating with the |
| 507 // plugin since they have their own channels which will go into the error | 518 // plugin since they have their own channels which will go into the error |
| 508 // state at the same time. Instead, we just need to notify any renderers | 519 // state at the same time. Instead, we just need to notify any renderers |
| 509 // that have requested a connection but have not yet received one. | 520 // that have requested a connection but have not yet received one. |
| 510 CancelRequests(); | 521 CancelRequests(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 536 // sent_requests_ queue should be the one that the plugin just created. | 547 // sent_requests_ queue should be the one that the plugin just created. |
| 537 Client* client = sent_requests_.front(); | 548 Client* client = sent_requests_.front(); |
| 538 sent_requests_.pop(); | 549 sent_requests_.pop(); |
| 539 | 550 |
| 540 const ChildProcessData& data = process_->GetData(); | 551 const ChildProcessData& data = process_->GetData(); |
| 541 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), | 552 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), |
| 542 data.id); | 553 data.id); |
| 543 } | 554 } |
| 544 | 555 |
| 545 } // namespace content | 556 } // namespace content |
| OLD | NEW |