diff options
author | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 19:49:16 +0000 |
---|---|---|
committer | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 19:49:16 +0000 |
commit | 47dc04a3cb1f9ffefbee94a7d3547db6d1aefd8b (patch) | |
tree | 0b37f5c1a3a7d3b14206d4507895f89102ff1cef /webkit | |
parent | 4acbedb1fe0f43802c64027cf7cbf81441297a95 (diff) | |
download | chromium_src-47dc04a3cb1f9ffefbee94a7d3547db6d1aefd8b.zip chromium_src-47dc04a3cb1f9ffefbee94a7d3547db6d1aefd8b.tar.gz chromium_src-47dc04a3cb1f9ffefbee94a7d3547db6d1aefd8b.tar.bz2 |
Unfork shared methods of WebPluginDelegateImpl. As a side effect, should fix
potential races/crashes in plugin shutdown. May fix 25833,25974,25978 (can't
repro those, so we may only be able to tell when the crash reports stop).
BUG=23868
Review URL: http://codereview.chromium.org/372025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_mac.mm | 150 | ||||
-rw-r--r-- | webkit/webkit.gyp | 5 |
3 files changed, 18 insertions, 141 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 8384e73..39df8fd 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -127,7 +127,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Called by DestroyInstance(), used for platform-specific destruction. void PlatformDestroyInstance(); -#if !defined(OS_MACOSX) //-------------------------- // used for windowed plugins void WindowedUpdateGeometry(const gfx::Rect& window_rect, @@ -148,7 +147,6 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { // Tells the plugin about the current state of the window. // See NPAPI NPP_SetWindow for more information. void WindowedSetWindow(); -#endif #if defined(OS_WIN) // Registers the window class for our window @@ -190,9 +188,9 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate { #if !defined(OS_MACOSX) // used for windowed plugins gfx::PluginWindowHandle windowed_handle_; - bool windowed_did_set_window_; gfx::Rect windowed_last_pos_; #endif + bool windowed_did_set_window_; // TODO(dglazkov): No longer used by Windows, make sure the removal // causes no regressions and eliminate from other platforms. diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm index a2f7459..36e115c 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -74,24 +74,6 @@ int g_current_y_offset = 0; } // namespace -WebPluginDelegateImpl* WebPluginDelegateImpl::Create( - const FilePath& filename, - const std::string& mime_type, - gfx::PluginWindowHandle containing_view) { - scoped_refptr<NPAPI::PluginLib> plugin = - NPAPI::PluginLib::CreatePluginLib(filename); - if (plugin.get() == NULL) - return NULL; - - NPError err = plugin->NP_Initialize(); - if (err != NPERR_NO_ERROR) - return NULL; - - scoped_refptr<NPAPI::PluginInstance> instance = - plugin->CreateInstance(mime_type); - return new WebPluginDelegateImpl(containing_view, instance.get()); -} - WebPluginDelegateImpl::WebPluginDelegateImpl( gfx::PluginWindowHandle containing_view, NPAPI::PluginInstance *instance) @@ -113,6 +95,7 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( #ifndef NP_NO_QUICKDRAW memset(&qd_port_, 0, sizeof(qd_port_)); #endif + instance->set_windowless(true); } WebPluginDelegateImpl::~WebPluginDelegateImpl() { @@ -131,35 +114,9 @@ void WebPluginDelegateImpl::PluginDestroyed() { delete this; } -bool WebPluginDelegateImpl::Initialize(const GURL& url, - const std::vector<std::string>& arg_names, - const std::vector<std::string>& arg_values, - WebPlugin* plugin, - bool load_manually) { - plugin_ = plugin; - - instance_->set_web_plugin(plugin); - - int argc = 0; - scoped_array<char*> argn(new char*[arg_names.size()]); - scoped_array<char*> argv(new char*[arg_names.size()]); - for (size_t i = 0; i < arg_names.size(); ++i) { - if (quirks_ & PLUGIN_QUIRK_NO_WINDOWLESS && - LowerCaseEqualsASCII(arg_names[i], "windowlessvideo")) { - continue; - } - argn[argc] = const_cast<char*>(arg_names[i].c_str()); - argv[argc] = const_cast<char*>(arg_values[i].c_str()); - argc++; - } - - bool start_result = instance_->Start( - url, argn.get(), argv.get(), argc, load_manually); - if (!start_result) - return false; - +void WebPluginDelegateImpl::PlatformInitialize() { FakePluginWindowTracker* window_tracker = - FakePluginWindowTracker::SharedInstance(); + FakePluginWindowTracker::SharedInstance(); cg_context_.window = window_tracker->GenerateFakeWindowForDelegate(this); cg_context_.context = NULL; Rect window_bounds = { 0, 0, window_rect_.height(), window_rect_.width() }; @@ -182,46 +139,19 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url, break; } - plugin->SetWindow(NULL); - plugin_url_ = url.spec(); - // If the plugin wants Carbon events, fire up a source of idle events. if (instance_->event_model() == NPEventModelCarbon) { MessageLoop::current()->PostDelayedTask(FROM_HERE, null_event_factory_.NewRunnableMethod( &WebPluginDelegateImpl::OnNullEvent), kPluginIdleThrottleDelayMs); } - return true; -} - -void WebPluginDelegateImpl::DestroyInstance() { - if (instance_ && (instance_->npp()->ndata != NULL)) { - // Shutdown all streams before destroying so that - // no streams are left "in progress". Need to do - // this before calling set_web_plugin(NULL) because the - // instance uses the helper to do the download. - instance_->CloseStreams(); - instance_->NPP_Destroy(); - instance_->set_web_plugin(NULL); - instance_ = 0; - } -} - -void WebPluginDelegateImpl::PlatformInitialize() { - // TODO(port): implement these after unforking. + plugin_->SetWindow(NULL); } void WebPluginDelegateImpl::PlatformDestroyInstance() { // TODO(port): implement these after unforking. } -void WebPluginDelegateImpl::UpdateGeometry( - const gfx::Rect& window_rect, - const gfx::Rect& clip_rect) { - DCHECK(windowless_); - WindowlessUpdateGeometry(window_rect, clip_rect); -} - void WebPluginDelegateImpl::UpdateContext(CGContextRef context) { // Flash on the Mac apparently caches the context from the struct it recieves // in NPP_SetWindow, and continue to use it even when the contents of the @@ -272,52 +202,27 @@ void WebPluginDelegateImpl::Print(CGContextRef context) { // in .01 mm units. } -NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() { - return instance_->GetPluginScriptableObject(); -} - -void WebPluginDelegateImpl::DidFinishLoadWithReason( - const GURL& url, NPReason reason, intptr_t notify_data) { - instance()->DidFinishLoadWithReason( - url, reason, reinterpret_cast<void*>(notify_data)); -} - -int WebPluginDelegateImpl::GetProcessId() { - // We are in process, so the plugin pid is this current process pid. - return getpid(); -} - -void WebPluginDelegateImpl::SendJavaScriptStream(const GURL& url, - const std::string& result, - bool success, - bool notify_needed, - intptr_t notify_data) { - instance()->SendJavaScriptStream(url, result, success, notify_needed, - notify_data); -} - -void WebPluginDelegateImpl::DidReceiveManualResponse( - const GURL& url, const std::string& mime_type, - const std::string& headers, uint32 expected_length, uint32 last_modified) { - instance()->DidReceiveManualResponse(url, mime_type, headers, - expected_length, last_modified); +void WebPluginDelegateImpl::InstallMissingPlugin() { + NOTIMPLEMENTED(); } -void WebPluginDelegateImpl::DidReceiveManualData(const char* buffer, - int length) { - instance()->DidReceiveManualData(buffer, length); +bool WebPluginDelegateImpl::WindowedCreatePlugin() { + NOTREACHED(); + return false; } -void WebPluginDelegateImpl::DidFinishManualLoading() { - instance()->DidFinishManualLoading(); +void WebPluginDelegateImpl::WindowedDestroyWindow() { + NOTREACHED(); } -void WebPluginDelegateImpl::DidManualLoadFail() { - instance()->DidManualLoadFail(); +bool WebPluginDelegateImpl::WindowedReposition(const gfx::Rect& window_rect, + const gfx::Rect& clip_rect) { + NOTREACHED(); + return false; } -void WebPluginDelegateImpl::InstallMissingPlugin() { - NOTIMPLEMENTED(); +void WebPluginDelegateImpl::WindowedSetWindow() { + NOTREACHED(); } void WebPluginDelegateImpl::WindowlessUpdateGeometry( @@ -785,27 +690,6 @@ bool WebPluginDelegateImpl::HandleInputEvent(const WebInputEvent& event, return ret; } -WebPluginResourceClient* WebPluginDelegateImpl::CreateResourceClient( - int resource_id, const GURL& url, bool notify_needed, - intptr_t notify_data, intptr_t existing_stream) { - // Stream already exists. This typically happens for range requests - // initiated via NPN_RequestRead. - if (existing_stream) { - NPAPI::PluginStream* plugin_stream = - reinterpret_cast<NPAPI::PluginStream*>(existing_stream); - - plugin_stream->CancelRequest(); - - return plugin_stream->AsResourceClient(); - } - - std::string mime_type; - NPAPI::PluginStreamUrl *stream = instance()->CreateStream( - resource_id, url, mime_type, notify_needed, - reinterpret_cast<void*>(notify_data)); - return stream; -} - void WebPluginDelegateImpl::OnNullEvent() { #ifndef NP_NO_CARBON if (!webkit_glue::IsPluginRunningInRendererProcess()) { diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 1fa755b..47e8de6 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -415,11 +415,6 @@ }], ['OS!="mac"', { 'sources/': [['exclude', '_mac\\.(cc|mm)$']] - }, { # else: OS=="mac" - 'sources!': [ - # TODO(port): Unfork webplugin_delegate_impl_mac and this file. - 'glue/plugins/webplugin_delegate_impl.cc', - ], }], ['OS!="win"', { 'sources/': [['exclude', '_win\\.cc$']], |