diff options
Diffstat (limited to 'chrome/plugin')
-rw-r--r-- | chrome/plugin/chrome_plugin_host.cc | 13 | ||||
-rw-r--r-- | chrome/plugin/npobject_proxy.cc | 5 | ||||
-rw-r--r-- | chrome/plugin/npobject_proxy.h | 2 | ||||
-rw-r--r-- | chrome/plugin/npobject_stub.cc | 4 | ||||
-rw-r--r-- | chrome/plugin/npobject_stub.h | 6 | ||||
-rw-r--r-- | chrome/plugin/npobject_util.cc | 18 | ||||
-rw-r--r-- | chrome/plugin/npobject_util.h | 3 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 18 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel.h | 7 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel_base.cc | 4 | ||||
-rw-r--r-- | chrome/plugin/plugin_channel_base.h | 5 | ||||
-rw-r--r-- | chrome/plugin/plugin_main.cc | 31 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 24 | ||||
-rw-r--r-- | chrome/plugin/plugin_thread.h | 1 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.cc | 32 | ||||
-rw-r--r-- | chrome/plugin/webplugin_delegate_stub.h | 9 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.cc | 43 | ||||
-rw-r--r-- | chrome/plugin/webplugin_proxy.h | 17 |
18 files changed, 154 insertions, 88 deletions
diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index fcba5f6..992afcf 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -8,6 +8,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/message_loop.h" +#include "base/process_util.h" #include "chrome/common/child_process.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_plugin_lib.h" @@ -42,8 +43,8 @@ class PluginRequestHandlerProxy PluginRequestHandlerProxy(ChromePluginLib* plugin, ScopableCPRequest* cprequest) - : PluginHelper(plugin), cprequest_(cprequest), response_data_offset_(0), - completed_(false), sync_(false), read_buffer_(NULL) { + : PluginHelper(plugin), cprequest_(cprequest), sync_(false), + response_data_offset_(0), completed_(false), read_buffer_(NULL) { load_flags_ = PluginResponseUtils::CPLoadFlagsToNetFlags(0); cprequest_->data = this; // see FromCPRequest(). } @@ -150,7 +151,7 @@ class PluginRequestHandlerProxy "null", // main_frame_origin extra_headers_, load_flags_, - GetCurrentProcessId(), + base::GetCurrentProcId(), ResourceType::OBJECT, cprequest_->context, WebAppCacheContext::kNoAppCacheContextId, @@ -207,7 +208,6 @@ class PluginRequestHandlerProxy if (count > avail) count = avail; - int rv = CPERR_FAILURE; if (count) { // Data is ready now. memcpy(buf, &response_data_[0] + response_data_offset_, count); @@ -241,7 +241,7 @@ class PluginRequestHandlerProxy scoped_refptr<net::HttpResponseHeaders> response_headers_; std::string response_data_; - int response_data_offset_; + size_t response_data_offset_; bool completed_; void* read_buffer_; uint32 read_buffer_size_; @@ -414,8 +414,7 @@ CPError STDCALL CPB_CreateRequest(CPID id, CPBrowsingContext context, CHECK(plugin); ScopableCPRequest* cprequest = new ScopableCPRequest(url, method, context); - PluginRequestHandlerProxy* handler = - new PluginRequestHandlerProxy(plugin, cprequest); + new PluginRequestHandlerProxy(plugin, cprequest); *request = cprequest; return CPERR_SUCCESS; diff --git a/chrome/plugin/npobject_proxy.cc b/chrome/plugin/npobject_proxy.cc index 0264321..fa48d87 100644 --- a/chrome/plugin/npobject_proxy.cc +++ b/chrome/plugin/npobject_proxy.cc @@ -6,7 +6,6 @@ #include "base/waitable_event.h" #include "chrome/common/plugin_messages.h" -#include "chrome/common/win_util.h" #include "chrome/plugin/npobject_util.h" #include "chrome/plugin/plugin_channel_base.h" #include "webkit/glue/webkit_glue.h" @@ -302,10 +301,10 @@ bool NPObjectProxy::NPRemoveProperty(NPObject *obj, } void NPObjectProxy::NPPInvalidate(NPObject *obj) { - bool result = false; NPObjectProxy* proxy = GetProxy(obj); if (!proxy) { - return obj->_class->invalidate(obj); + obj->_class->invalidate(obj); + return; } proxy->Send(new NPObjectMsg_Invalidate(proxy->route_id())); diff --git a/chrome/plugin/npobject_proxy.h b/chrome/plugin/npobject_proxy.h index bb0ec2c..d4a22d4 100644 --- a/chrome/plugin/npobject_proxy.h +++ b/chrome/plugin/npobject_proxy.h @@ -110,9 +110,9 @@ class NPObjectProxy : public IPC::Channel::Listener, static void NPPInvalidate(NPObject *obj); static NPClass npclass_proxy_; + scoped_refptr<PluginChannelBase> channel_; int route_id_; intptr_t npobject_ptr_; - scoped_refptr<PluginChannelBase> channel_; base::WaitableEvent* modal_dialog_event_; }; diff --git a/chrome/plugin/npobject_stub.cc b/chrome/plugin/npobject_stub.cc index 12a9df7..26780d2 100644 --- a/chrome/plugin/npobject_stub.cc +++ b/chrome/plugin/npobject_stub.cc @@ -16,8 +16,8 @@ NPObjectStub::NPObjectStub( PluginChannelBase* channel, int route_id, base::WaitableEvent* modal_dialog_event) - : channel_(channel), - npobject_(npobject), + : npobject_(npobject), + channel_(channel), route_id_(route_id), valid_(true), web_plugin_delegate_proxy_(NULL), diff --git a/chrome/plugin/npobject_stub.h b/chrome/plugin/npobject_stub.h index cd75853..0ab0019 100644 --- a/chrome/plugin/npobject_stub.h +++ b/chrome/plugin/npobject_stub.h @@ -78,16 +78,16 @@ class NPObjectStub : public IPC::Channel::Listener, private: NPObject* npobject_; - int route_id_; scoped_refptr<PluginChannelBase> channel_; - - base::WaitableEvent* modal_dialog_event_; + int route_id_; // These variables are used to ensure that the window script object is not // called after the plugin widget has gone away, as the frame manually // deallocates it and ignores the refcount to avoid leaks. bool valid_; WebPluginDelegateProxy* web_plugin_delegate_proxy_; + + base::WaitableEvent* modal_dialog_event_; }; #endif // CHROME_PLUGIN_NPOBJECT_STUB_H_ diff --git a/chrome/plugin/npobject_util.cc b/chrome/plugin/npobject_util.cc index d7bad8f..ececfa2 100644 --- a/chrome/plugin/npobject_util.cc +++ b/chrome/plugin/npobject_util.cc @@ -4,15 +4,8 @@ #include "chrome/plugin/npobject_util.h" -// TODO(port) Just compile an empty file on posix so we can generate the -// libplugin target needed by other targets. This whole file does compile (see -// r9934), but it doesn't link because of undefined refs to files which aren't -// compiling yet (e.g. npobject_proxy stuff). -#if defined(OS_WIN) - +#include "base/string_util.h" #include "chrome/common/plugin_messages.h" -#include "chrome/common/win_util.h" - #include "chrome/plugin/npobject_proxy.h" #include "chrome/plugin/plugin_channel_base.h" #include "webkit/glue/plugins/nphostapi.h" @@ -133,7 +126,6 @@ bool IsPluginProcess() { return g_plugin_process; } -#if defined(OS_WIN) void CreateNPIdentifierParam(NPIdentifier id, NPIdentifier_Param* param) { param->identifier = id; } @@ -190,7 +182,7 @@ void CreateNPVariantParam(const NPVariant& variant, // (release==true), we should still do that. param->type = NPVARIANT_PARAM_OBJECT_ROUTING_ID; int route_id = channel->GenerateRouteID(); - NPObjectStub* object_stub = new NPObjectStub( + new NPObjectStub( variant.value.objectValue, channel, route_id, modal_dialog_event); param->npobject_routing_id = route_id; param->npobject_pointer = @@ -235,7 +227,7 @@ void CreateNPVariant(const NPVariant_Param& param, case NPVARIANT_PARAM_STRING: result->type = NPVariantType_String; result->value.stringValue.UTF8Characters = - static_cast<NPUTF8 *>(_strdup(param.string_value.c_str())); + static_cast<NPUTF8 *>(base::strdup(param.string_value.c_str())); result->value.stringValue.UTF8Length = static_cast<int>(param.string_value.size()); break; @@ -257,7 +249,3 @@ void CreateNPVariant(const NPVariant_Param& param, NOTREACHED(); } } - -#endif // defined(OS_WIN) - -#endif // defined(OS_WIN) diff --git a/chrome/plugin/npobject_util.h b/chrome/plugin/npobject_util.h index 1ff38a0..ee58225 100644 --- a/chrome/plugin/npobject_util.h +++ b/chrome/plugin/npobject_util.h @@ -12,6 +12,7 @@ #if defined(OS_WIN) #include <windows.h> #endif + #include "chrome/plugin/npobject_stub.h" struct _NPVariant; @@ -51,13 +52,13 @@ void CreateNPVariantParam(const NPVariant& variant, bool release, base::WaitableEvent* modal_dialog_event); -#if defined(OS_WIN) // Creates an NPVariant from the marshalled object. void CreateNPVariant(const NPVariant_Param& param, PluginChannelBase* channel, NPVariant* result, base::WaitableEvent* modal_dialog_event); +#if defined(OS_WIN) // Given a plugin's HWND, returns an event associated with the WebContents // that's set when inside a messagebox. This tells the plugin process that // the message queue should be pumped (as what would happen if everything was diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index 1c6a809..f14300f 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <windows.h> - #include "chrome/plugin/plugin_channel.h" #include "base/command_line.h" @@ -17,7 +15,7 @@ PluginChannel* PluginChannel::GetPluginChannel(MessageLoop* ipc_message_loop) { static int next_id; std::wstring channel_name = StringPrintf( - L"%d.r%d", GetCurrentProcessId(), ++next_id); + L"%d.r%d", base::GetCurrentProcId(), ++next_id); return static_cast<PluginChannel*>(PluginChannelBase::GetChannel( channel_name, @@ -27,7 +25,8 @@ PluginChannel* PluginChannel::GetPluginChannel(MessageLoop* ipc_message_loop) { false)); } -PluginChannel::PluginChannel() : in_send_(0), off_the_record_(false) { +PluginChannel::PluginChannel() : renderer_handle_(0), in_send_(0), + off_the_record_(false) { SendUnblockingOnlyDuringDispatch(); ChildProcess::current()->AddRefProcess(); const CommandLine* command_line = CommandLine::ForCurrentProcess(); @@ -35,6 +34,8 @@ PluginChannel::PluginChannel() : in_send_(0), off_the_record_(false) { } PluginChannel::~PluginChannel() { + if (renderer_handle_) + base::CloseProcessHandle(renderer_handle_); ChildProcess::current()->ReleaseProcess(); } @@ -95,8 +96,8 @@ void PluginChannel::OnGenerateRouteID(int* route_id) { } int PluginChannel::GenerateRouteID() { - static LONG last_id = 0; - return InterlockedIncrement(&last_id); + static int last_id = 0; + return ++last_id; } void PluginChannel::OnChannelConnected(int32 peer_pid) { @@ -104,12 +105,13 @@ void PluginChannel::OnChannelConnected(int32 peer_pid) { if (!base::OpenProcessHandle(peer_pid, &handle)) { NOTREACHED(); } - renderer_handle_.Set(handle); + renderer_handle_ = handle; PluginChannelBase::OnChannelConnected(peer_pid); } void PluginChannel::OnChannelError() { - renderer_handle_.Set(NULL); + base::CloseProcessHandle(renderer_handle_); + renderer_handle_ = 0; PluginChannelBase::OnChannelError(); CleanUp(); } diff --git a/chrome/plugin/plugin_channel.h b/chrome/plugin/plugin_channel.h index 94d18f9..a1643d1 100644 --- a/chrome/plugin/plugin_channel.h +++ b/chrome/plugin/plugin_channel.h @@ -7,6 +7,7 @@ #include <vector> #include "base/scoped_handle.h" +#include "build/build_config.h" #include "chrome/plugin/plugin_channel_base.h" #include "chrome/plugin/webplugin_delegate_stub.h" @@ -21,7 +22,7 @@ class PluginChannel : public PluginChannelBase { virtual bool Send(IPC::Message* msg); virtual void OnMessageReceived(const IPC::Message& message); - HANDLE renderer_handle() { return renderer_handle_.Get(); } + base::ProcessHandle renderer_handle() const { return renderer_handle_; } int GenerateRouteID(); bool in_send() { return in_send_ != 0; } @@ -48,10 +49,10 @@ class PluginChannel : public PluginChannelBase { void OnDestroyInstance(int instance_id, IPC::Message* reply_msg); void OnGenerateRouteID(int* route_id); - std::vector<scoped_refptr<WebPluginDelegateStub>> plugin_stubs_; + std::vector<scoped_refptr<WebPluginDelegateStub> > plugin_stubs_; // Handle to the renderer process who is on the other side of the channel. - ScopedHandle renderer_handle_; + base::ProcessHandle renderer_handle_; int in_send_; // Tracks if we're in a Send call. bool log_messages_; // True if we should log sent and received messages. diff --git a/chrome/plugin/plugin_channel_base.cc b/chrome/plugin/plugin_channel_base.cc index 0e26e86..3a4a958 100644 --- a/chrome/plugin/plugin_channel_base.cc +++ b/chrome/plugin/plugin_channel_base.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <windows.h> - #include "chrome/plugin/plugin_channel_base.h" #include "base/hash_tables.h" @@ -59,7 +57,7 @@ PluginChannelBase::~PluginChannelBase() { void PluginChannelBase::CleanupChannels() { // Make a copy of the references as we can't iterate the map since items will // be removed from it as we clean them up. - std::vector<scoped_refptr<PluginChannelBase>> channels; + std::vector<scoped_refptr<PluginChannelBase> > channels; for (PluginChannelMap::const_iterator iter = g_plugin_channels_.begin(); iter != g_plugin_channels_.end(); ++iter) { diff --git a/chrome/plugin/plugin_channel_base.h b/chrome/plugin/plugin_channel_base.h index dd70cba..70a9c30 100644 --- a/chrome/plugin/plugin_channel_base.h +++ b/chrome/plugin/plugin_channel_base.h @@ -108,10 +108,13 @@ class PluginChannelBase : public IPC::Channel::Listener, // error. This flag is used to indicate the same. bool channel_valid_; + // Track whether we're within a dispatch; works like a refcount, 0 when we're + // not. + int in_dispatch_; + // If true, sync messages will only be marked as unblocking if the channel is // in the middle of dispatching a message. bool send_unblocking_only_during_dispatch_; - int in_dispatch_; DISALLOW_EVIL_CONSTRUCTORS(PluginChannelBase); }; diff --git a/chrome/plugin/plugin_main.cc b/chrome/plugin/plugin_main.cc index fe71ea0..7b21066 100644 --- a/chrome/plugin/plugin_main.cc +++ b/chrome/plugin/plugin_main.cc @@ -6,22 +6,22 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/system_monitor.h" +#include "build/build_config.h" #include "chrome/common/child_process.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/main_function_params.h" -#include "chrome/common/win_util.h" #include "chrome/plugin/plugin_thread.h" + +#if defined(OS_WIN) +#include "chrome/common/win_util.h" #include "chrome/test/injection_test_dll.h" #include "sandbox/src/sandbox.h" +#endif -// mainline routine for running as the plugin process +// main() routine for running as the plugin process. int PluginMain(const MainFunctionParams& parameters) { - const CommandLine& parsed_command_line = parameters.command_line_; - sandbox::TargetServices* target_services = - parameters.sandbox_info_.TargetServices(); - // The main thread of the plugin services IO. MessageLoopForIO main_message_loop; std::wstring app_name = chrome::kBrowserAppName; @@ -30,6 +30,12 @@ int PluginMain(const MainFunctionParams& parameters) { // Initialize the SystemMonitor base::SystemMonitor::Start(); +#if defined(OS_WIN) + const CommandLine& parsed_command_line = parameters.command_line_; + + sandbox::TargetServices* target_services = + parameters.sandbox_info_.TargetServices(); + CoInitialize(NULL); DLOG(INFO) << "Started plugin with " << parsed_command_line.command_line_string(); @@ -53,12 +59,15 @@ int PluginMain(const MainFunctionParams& parameters) { win_util::MessageBox(NULL, L"plugin starting...", title, MB_OK | MB_SETFOREGROUND); } +#else + NOTIMPLEMENTED() << " non-windows startup, plugin startup dialog etc."; +#endif { ChildProcess plugin_process(new PluginThread()); - if (!no_sandbox && target_services) { +#if defined(OS_WIN) + if (!no_sandbox && target_services) target_services->LowerToken(); - } if (sandbox_test_module) { RunRendererTests run_security_tests = @@ -75,12 +84,14 @@ int PluginMain(const MainFunctionParams& parameters) { __debugbreak(); } } +#endif - // Load the accelerator table from the browser executable and tell the - // message loop to use it when translating messages. MessageLoop::current()->Run(); } +#if defined(OS_WIN) CoUninitialize(); +#endif + return 0; } diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 3b7c614..d24faf0 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -2,12 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/plugin/plugin_thread.h" + +#include "build/build_config.h" + +#if defined(OS_WIN) #include <windows.h> #include <objbase.h> - -#include "chrome/plugin/plugin_thread.h" +#endif #include "base/command_line.h" +#include "base/process_util.h" #include "chrome/common/child_process.h" #include "chrome/common/chrome_plugin_lib.h" #include "chrome/common/chrome_switches.h" @@ -46,8 +51,12 @@ void PluginThread::OnControlMessageReceived(const IPC::Message& msg) { void PluginThread::Init() { ChildThread::Init(); + PatchNPNFunctions(); +#if defined(OS_WIN) CoInitialize(NULL); +#endif + notification_service_.reset(new NotificationService); // Preload the library to avoid loading, unloading then reloading @@ -68,17 +77,19 @@ void PluginThread::Init() { void PluginThread::CleanUp() { if (preloaded_plugin_module_) { - FreeLibrary(preloaded_plugin_module_); + base::UnloadNativeLibrary(preloaded_plugin_module_); preloaded_plugin_module_ = NULL; } PluginChannelBase::CleanupChannels(); NPAPI::PluginLib::UnloadAllPlugins(); ChromePluginLib::UnloadAllPlugins(); notification_service_.reset(); +#if defined(OS_WIN) CoUninitialize(); +#endif if (webkit_glue::ShouldForcefullyTerminatePluginProcess()) - TerminateProcess(GetCurrentProcess(), 0); + base::KillProcess(base::GetCurrentProcessHandle(), 0, /* wait= */ false); // Call this last because it deletes the ResourceDispatcher, which is used // in some of the above cleanup. @@ -146,7 +157,12 @@ bool GetPluginFinderURL(std::string* plugin_finder_url) { } bool IsDefaultPluginEnabled() { +#if defined(OS_WIN) return true; +#else + NOTIMPLEMENTED(); + return false; +#endif } // Dispatch the resolve proxy resquest to the right code, depending on which diff --git a/chrome/plugin/plugin_thread.h b/chrome/plugin/plugin_thread.h index a110a2c..06b2f7f 100644 --- a/chrome/plugin/plugin_thread.h +++ b/chrome/plugin/plugin_thread.h @@ -9,6 +9,7 @@ #include "base/native_library.h" #include "chrome/common/child_thread.h" #include "chrome/plugin/plugin_channel.h" +#include "webkit/glue/plugins/plugin_lib.h" class NotificationService; diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc index 9d83b49..73f5b79 100644 --- a/chrome/plugin/webplugin_delegate_stub.cc +++ b/chrome/plugin/webplugin_delegate_stub.cc @@ -4,11 +4,11 @@ #include "chrome/plugin/webplugin_delegate_stub.h" +#include "build/build_config.h" + #include "base/command_line.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/gfx/emf.h" #include "chrome/common/plugin_messages.h" -#include "chrome/common/win_util.h" #include "chrome/plugin/npobject_stub.h" #include "chrome/plugin/plugin_channel.h" #include "chrome/plugin/plugin_thread.h" @@ -19,6 +19,11 @@ #include "webkit/glue/webcursor.h" #include "webkit/glue/webplugin_delegate.h" +#if defined(OS_WIN) +#include "chrome/common/gfx/emf.h" +#include "chrome/common/win_util.h" +#endif + class FinishDestructionTask : public Task { public: FinishDestructionTask(WebPluginDelegate* delegate, WebPlugin* webplugin) @@ -124,8 +129,8 @@ void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, } const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - FilePath path = - FilePath(command_line.GetSwitchValue(switches::kPluginPath)); + FilePath path = FilePath::FromWStringHack( + command_line.GetSwitchValue(switches::kPluginPath)); delegate_ = WebPluginDelegate::Create( path, mime_type_, gfx::NativeViewFromId(params.containing_window)); if (delegate_) { @@ -215,6 +220,7 @@ void WebPluginDelegateStub::OnDidPaint() { void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, size_t* size) { +#if defined(OS_WIN) gfx::Emf emf; if (!emf.CreateDc(NULL, NULL)) { NOTREACHED(); @@ -236,15 +242,20 @@ void WebPluginDelegateStub::OnPrint(base::SharedMemoryHandle* shared_memory, // Retrieve a copy of the data. bool success = emf.GetData(shared_buf.memory(), *size); DCHECK(success); +#else + // TODO(port): plugin printing. + NOTIMPLEMENTED(); +#endif } void WebPluginDelegateStub::OnUpdateGeometry( const gfx::Rect& window_rect, const gfx::Rect& clip_rect, - const base::SharedMemoryHandle& windowless_buffer, - const base::SharedMemoryHandle& background_buffer) { + const TransportDIB::Id& windowless_buffer_id, + const TransportDIB::Id& background_buffer_id) { webplugin_->UpdateGeometry( - window_rect, clip_rect, windowless_buffer, background_buffer); + window_rect, clip_rect, + windowless_buffer_id, background_buffer_id); } void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, @@ -259,7 +270,7 @@ void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, *npobject_ptr = reinterpret_cast<intptr_t>(object); // The stub will delete itself when the proxy tells it that it's released, or // otherwise when the channel is closed. - NPObjectStub* stub = new NPObjectStub( + new NPObjectStub( object, channel_.get(), *route_id, webplugin_->modal_dialog_event()); // Release ref added by GetPluginScriptableObject (our stub holds its own). @@ -315,6 +326,7 @@ void WebPluginDelegateStub::CreateSharedBuffer( return; } +#if defined(OS_WIN) BOOL result = DuplicateHandle(GetCurrentProcess(), shared_buf->handle(), channel_->renderer_handle(), @@ -325,6 +337,10 @@ void WebPluginDelegateStub::CreateSharedBuffer( // If the calling function's shared_buf is on the stack, its destructor will // close the shared memory buffer handle. This is fine since we already // duplicated the handle to the renderer process so it will stay "alive". +#else + // TODO(port): this should use TransportDIB. + NOTIMPLEMENTED(); +#endif } void WebPluginDelegateStub::OnHandleURLRequestReply( diff --git a/chrome/plugin/webplugin_delegate_stub.h b/chrome/plugin/webplugin_delegate_stub.h index 995d318..d2103a0 100644 --- a/chrome/plugin/webplugin_delegate_stub.h +++ b/chrome/plugin/webplugin_delegate_stub.h @@ -12,6 +12,7 @@ #include "base/shared_memory.h" #include "base/task.h" #include "chrome/common/ipc_channel.h" +#include "chrome/common/transport_dib.h" #include "third_party/npapi/bindings/npapi.h" class GURL; @@ -66,8 +67,8 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, void OnUpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, - const base::SharedMemoryHandle& windowless_buffer, - const base::SharedMemoryHandle& background_buffer); + const TransportDIB::Id& windowless_buffer, + const TransportDIB::Id& background_buffer); void OnGetPluginScriptableObject(int* route_id, intptr_t* npobject_ptr); void OnSendJavaScriptStream(const std::string& url, const std::wstring& result, @@ -92,15 +93,15 @@ class WebPluginDelegateStub : public IPC::Channel::Listener, base::SharedMemory* shared_buf, base::SharedMemoryHandle* remote_handle); - int instance_id_; std::string mime_type_; + int instance_id_; scoped_refptr<PluginChannel> channel_; WebPluginDelegate* delegate_; WebPluginProxy* webplugin_; - DISALLOW_EVIL_CONSTRUCTORS(WebPluginDelegateStub); + DISALLOW_IMPLICIT_CONSTRUCTORS(WebPluginDelegateStub); }; #endif // CHROME_PLUGIN_WEBPLUGIN_DELEGATE_STUB_H_ diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc index 6a827ce..3890ec9 100644 --- a/chrome/plugin/webplugin_proxy.cc +++ b/chrome/plugin/webplugin_proxy.cc @@ -4,15 +4,14 @@ #include "chrome/plugin/webplugin_proxy.h" -#include "base/gfx/gdi_util.h" #include "base/scoped_handle.h" #include "base/shared_memory.h" #include "base/singleton.h" #include "base/waitable_event.h" +#include "build/build_config.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/url_constants.h" -#include "chrome/common/win_util.h" #include "chrome/plugin/npobject_proxy.h" #include "chrome/plugin/npobject_util.h" #include "chrome/plugin/plugin_channel.h" @@ -21,6 +20,11 @@ #include "skia/ext/platform_device.h" #include "webkit/glue/webplugin_delegate.h" +#if defined(OS_WIN) +#include "base/gfx/gdi_util.h" +#include "chrome/common/win_util.h" +#endif + typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; static ContextMap& GetContextMap() { return *Singleton<ContextMap>::get(); @@ -37,8 +41,8 @@ WebPluginProxy::WebPluginProxy( plugin_element_(NULL), delegate_(delegate), waiting_for_paint_(false), -#pragma warning(suppress: 4355) // can use this - runnable_method_factory_(this) { + ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) +{ } WebPluginProxy::~WebPluginProxy() { @@ -256,9 +260,10 @@ void WebPluginProxy::HandleURLRequest(const char *method, return; } - if (!target && (0 == _strcmpi(method, "GET"))) { + if (!target && (0 == base::strcasecmp(method, "GET"))) { // Please refer to https://bugzilla.mozilla.org/show_bug.cgi?id=366082 // for more details on this. +#if defined(OS_WIN) if (delegate_->GetQuirks() & WebPluginDelegate::PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS) { GURL request_url(url); @@ -268,6 +273,10 @@ void WebPluginProxy::HandleURLRequest(const char *method, return; } } +#else + // TODO(port): we need a GetQuirks() on our delegate impl. + NOTIMPLEMENTED(); +#endif } PluginHostMsg_URLRequest_Params params; @@ -291,6 +300,7 @@ void WebPluginProxy::HandleURLRequest(const char *method, } void WebPluginProxy::Paint(const gfx::Rect& rect) { +#if defined(OS_WIN) if (!windowless_hdc_) return; @@ -317,21 +327,31 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) { SelectClipRgn(windowless_hdc_, NULL); DeleteObject(clip_region); +#else + // TODO(port): windowless painting. + NOTIMPLEMENTED(); +#endif } void WebPluginProxy::UpdateGeometry( const gfx::Rect& window_rect, const gfx::Rect& clip_rect, - const base::SharedMemoryHandle& windowless_buffer, - const base::SharedMemoryHandle& background_buffer) { + const TransportDIB::Id& windowless_buffer_id, + const TransportDIB::Id& background_buffer_id) { +#if defined(OS_WIN) + // TODO(port): this isn't correct usage of a TransportDIB; for now, + // the caller temporarly just stuffs the handle into the HANDLE + // field of the TransportDIB::Id so it should behave like the older + // code. gfx::Rect old = delegate_->GetRect(); gfx::Rect old_clip_rect = delegate_->GetClipRect(); bool moved = old.x() != window_rect.x() || old.y() != window_rect.y(); delegate_->UpdateGeometry(window_rect, clip_rect); - if (windowless_buffer) { + if (windowless_buffer_id.handle) { // The plugin's rect changed, so now we have a new buffer to draw into. - SetWindowlessBuffer(windowless_buffer, background_buffer); + SetWindowlessBuffer(windowless_buffer_id.handle, + background_buffer_id.handle); } else if (moved) { // The plugin moved, so update our world transform. UpdateTransform(); @@ -342,8 +362,12 @@ void WebPluginProxy::UpdateGeometry( old_clip_rect.IsEmpty() && !damaged_rect_.IsEmpty()) { InvalidateRect(damaged_rect_); } +#else + NOTIMPLEMENTED(); +#endif } +#if defined(OS_WIN) void WebPluginProxy::SetWindowlessBuffer( const base::SharedMemoryHandle& windowless_buffer, const base::SharedMemoryHandle& background_buffer) { @@ -411,6 +435,7 @@ void WebPluginProxy::UpdateTransform() { xf.eM22 = 1; SetWorldTransform(windowless_hdc_, &xf); } +#endif void WebPluginProxy::CancelDocumentLoad() { Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h index ea2c124..f181613 100644 --- a/chrome/plugin/webplugin_proxy.h +++ b/chrome/plugin/webplugin_proxy.h @@ -13,6 +13,7 @@ #include "base/timer.h" #include "chrome/common/ipc_message.h" #include "chrome/common/chrome_plugin_api.h" +#include "chrome/common/transport_dib.h" #include "webkit/glue/webplugin.h" namespace base { @@ -87,8 +88,8 @@ class WebPluginProxy : public WebPlugin { void UpdateGeometry(const gfx::Rect& window_rect, const gfx::Rect& clip_rect, - const base::SharedMemoryHandle& windowless_buffer, - const base::SharedMemoryHandle& background_buffer); + const TransportDIB::Id& windowless_buffer, + const TransportDIB::Id& background_buffer); void CancelDocumentLoad(); @@ -107,6 +108,10 @@ class WebPluginProxy : public WebPlugin { private: bool Send(IPC::Message* msg); + // Handler for sending over the paint event to the plugin. + void OnPaint(const gfx::Rect& damaged_rect); + +#if defined(OS_WIN) // Updates the shared memory section where windowless plugins paint. void SetWindowlessBuffer(const base::SharedMemoryHandle& windowless_buffer, const base::SharedMemoryHandle& background_buffer); @@ -118,26 +123,25 @@ class WebPluginProxy : public WebPlugin { ScopedBitmap* bitmap, ScopedHDC* hdc); - // Handler for sending over the paint event to the plugin. - void OnPaint(const gfx::Rect& damaged_rect); - // Called when a plugin's origin moves, so that we can update the world // transform of the local HDC. void UpdateTransform(); +#endif typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; ResourceClientMap resource_clients_; scoped_refptr<PluginChannel> channel_; int route_id_; + uint32 cp_browsing_context_; NPObject* window_npobject_; NPObject* plugin_element_; WebPluginDelegate* delegate_; gfx::Rect damaged_rect_; bool waiting_for_paint_; - uint32 cp_browsing_context_; scoped_ptr<base::WaitableEvent> modal_dialog_event_; +#if defined(OS_WIN) // Variables used for desynchronized windowless plugin painting. See note in // webplugin_delegate_proxy.h for how this works. @@ -150,6 +154,7 @@ class WebPluginProxy : public WebPlugin { ScopedHandle background_shared_section_; ScopedBitmap background_bitmap_; ScopedHDC background_hdc_; +#endif ScopedRunnableMethodFactory<WebPluginProxy> runnable_method_factory_; }; |