| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/plugin_process_host.h" | 7 #include "chrome/browser/plugin_process_host.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <windows.h> | 10 #include <windows.h> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "chrome/common/logging_chrome.h" | 35 #include "chrome/common/logging_chrome.h" |
| 36 #include "chrome/common/plugin_messages.h" | 36 #include "chrome/common/plugin_messages.h" |
| 37 #include "chrome/common/render_messages.h" | 37 #include "chrome/common/render_messages.h" |
| 38 #include "net/base/cookie_monster.h" | 38 #include "net/base/cookie_monster.h" |
| 39 #include "net/base/file_stream.h" | 39 #include "net/base/file_stream.h" |
| 40 #include "net/base/io_buffer.h" | 40 #include "net/base/io_buffer.h" |
| 41 #include "net/url_request/url_request.h" | 41 #include "net/url_request/url_request.h" |
| 42 #include "net/url_request/url_request_context.h" | 42 #include "net/url_request/url_request_context.h" |
| 43 #include "webkit/glue/plugins/plugin_constants_win.h" | 43 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 44 | 44 |
| 45 // TODO(port): Port these files. | |
| 46 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
| 47 #include "base/win_util.h" | 46 #include "base/win_util.h" |
| 48 #include "chrome/browser/sandbox_policy.h" | 47 #include "chrome/browser/sandbox_policy.h" |
| 49 #include "chrome/common/win_util.h" | 48 #include "chrome/common/win_util.h" |
| 50 #include "sandbox/src/sandbox.h" | 49 #include "sandbox/src/sandbox.h" |
| 51 #endif | 50 #endif |
| 52 | 51 |
| 53 static const char kDefaultPluginFinderURL[] = | 52 static const char kDefaultPluginFinderURL[] = |
| 54 "http://dl.google.com/chrome/plugins/plugins2.xml"; | 53 "http://dl.google.com/chrome/plugins/plugins2.xml"; |
| 55 | 54 |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 487 } |
| 489 | 488 |
| 490 void PluginProcessHost::OnResolveProxy(const GURL& url, | 489 void PluginProcessHost::OnResolveProxy(const GURL& url, |
| 491 IPC::Message* reply_msg) { | 490 IPC::Message* reply_msg) { |
| 492 resolve_proxy_msg_helper_.Start(url, reply_msg); | 491 resolve_proxy_msg_helper_.Start(url, reply_msg); |
| 493 } | 492 } |
| 494 | 493 |
| 495 void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg, | 494 void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg, |
| 496 int result, | 495 int result, |
| 497 const std::string& proxy_list) { | 496 const std::string& proxy_list) { |
| 498 #if defined(OS_WIN) | |
| 499 PluginProcessHostMsg_ResolveProxy::WriteReplyParams( | 497 PluginProcessHostMsg_ResolveProxy::WriteReplyParams( |
| 500 reply_msg, result, proxy_list); | 498 reply_msg, result, proxy_list); |
| 501 Send(reply_msg); | 499 Send(reply_msg); |
| 502 #else | |
| 503 // TODO(port): Port plugin_messages_internal.h. | |
| 504 NOTIMPLEMENTED(); | |
| 505 #endif | |
| 506 } | 500 } |
| 507 | 501 |
| 508 void PluginProcessHost::ReplyToRenderer( | 502 void PluginProcessHost::ReplyToRenderer( |
| 509 ResourceMessageFilter* renderer_message_filter, | 503 ResourceMessageFilter* renderer_message_filter, |
| 510 const std::wstring& channel, const FilePath& plugin_path, | 504 const std::wstring& channel, const FilePath& plugin_path, |
| 511 IPC::Message* reply_msg) { | 505 IPC::Message* reply_msg) { |
| 512 ViewHostMsg_OpenChannelToPlugin::WriteReplyParams(reply_msg, channel, | 506 ViewHostMsg_OpenChannelToPlugin::WriteReplyParams(reply_msg, channel, |
| 513 plugin_path); | 507 plugin_path); |
| 514 renderer_message_filter->Send(reply_msg); | 508 renderer_message_filter->Send(reply_msg); |
| 515 } | 509 } |
| 516 | 510 |
| 517 URLRequestContext* PluginProcessHost::GetRequestContext( | 511 URLRequestContext* PluginProcessHost::GetRequestContext( |
| 518 uint32 request_id, | 512 uint32 request_id, |
| 519 const ViewHostMsg_Resource_Request& request_data) { | 513 const ViewHostMsg_Resource_Request& request_data) { |
| 520 return CPBrowsingContextManager::Instance()->ToURLRequestContext(request_id); | 514 return CPBrowsingContextManager::Instance()->ToURLRequestContext(request_id); |
| 521 } | 515 } |
| 522 | 516 |
| 523 void PluginProcessHost::RequestPluginChannel( | 517 void PluginProcessHost::RequestPluginChannel( |
| 524 ResourceMessageFilter* renderer_message_filter, | 518 ResourceMessageFilter* renderer_message_filter, |
| 525 const std::string& mime_type, IPC::Message* reply_msg) { | 519 const std::string& mime_type, IPC::Message* reply_msg) { |
| 526 #if defined(OS_WIN) | |
| 527 // We can't send any sync messages from the browser because it might lead to | 520 // We can't send any sync messages from the browser because it might lead to |
| 528 // a hang. However this async messages must be answered right away by the | 521 // a hang. However this async messages must be answered right away by the |
| 529 // plugin process (i.e. unblocks a Send() call like a sync message) otherwise | 522 // plugin process (i.e. unblocks a Send() call like a sync message) otherwise |
| 530 // a deadlock can occur if the plugin creation request from the renderer is | 523 // a deadlock can occur if the plugin creation request from the renderer is |
| 531 // a result of a sync message by the plugin process. | 524 // a result of a sync message by the plugin process. |
| 532 PluginProcessMsg_CreateChannel* msg = new PluginProcessMsg_CreateChannel( | 525 PluginProcessMsg_CreateChannel* msg = new PluginProcessMsg_CreateChannel( |
| 533 renderer_message_filter->off_the_record()); | 526 renderer_message_filter->off_the_record()); |
| 534 msg->set_unblock(true); | 527 msg->set_unblock(true); |
| 535 if (Send(msg)) { | 528 if (Send(msg)) { |
| 536 sent_requests_.push(ChannelRequest( | 529 sent_requests_.push(ChannelRequest( |
| 537 renderer_message_filter, mime_type, reply_msg)); | 530 renderer_message_filter, mime_type, reply_msg)); |
| 538 } else { | 531 } else { |
| 539 ReplyToRenderer(renderer_message_filter, std::wstring(), FilePath(), | 532 ReplyToRenderer(renderer_message_filter, std::wstring(), FilePath(), |
| 540 reply_msg); | 533 reply_msg); |
| 541 } | 534 } |
| 542 #else | |
| 543 // TODO(port): Figure out what the plugin process is expecting in this case. | |
| 544 NOTIMPLEMENTED(); | |
| 545 #endif | |
| 546 } | 535 } |
| 547 | 536 |
| 548 void PluginProcessHost::OnChannelCreated(const std::wstring& channel_name) { | 537 void PluginProcessHost::OnChannelCreated(const std::wstring& channel_name) { |
| 549 ReplyToRenderer(sent_requests_.front().renderer_message_filter_.get(), | 538 ReplyToRenderer(sent_requests_.front().renderer_message_filter_.get(), |
| 550 channel_name, | 539 channel_name, |
| 551 info_.path, | 540 info_.path, |
| 552 sent_requests_.front().reply_msg); | 541 sent_requests_.front().reply_msg); |
| 553 sent_requests_.pop(); | 542 sent_requests_.pop(); |
| 554 } | 543 } |
| 555 | 544 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 569 DCHECK(MessageLoop::current() == | 558 DCHECK(MessageLoop::current() == |
| 570 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 559 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
| 571 | 560 |
| 572 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path); | 561 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path); |
| 573 if (chrome_plugin) { | 562 if (chrome_plugin) { |
| 574 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); | 563 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); |
| 575 uint32 data_len = static_cast<uint32>(data.size()); | 564 uint32 data_len = static_cast<uint32>(data.size()); |
| 576 chrome_plugin->functions().on_message(data_ptr, data_len); | 565 chrome_plugin->functions().on_message(data_ptr, data_len); |
| 577 } | 566 } |
| 578 } | 567 } |
| OLD | NEW |