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