diff options
author | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 20:13:11 +0000 |
---|---|---|
committer | amanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-06 20:13:11 +0000 |
commit | 4d9ef386a1e45a363178a92d3215664dba439a2f (patch) | |
tree | b4a25629b3d90b9f6ede3951cc3fc1ecb21a7893 /webkit | |
parent | ad80d5e5bc4b8924778b8418058761ef0ad19aa4 (diff) | |
download | chromium_src-4d9ef386a1e45a363178a92d3215664dba439a2f.zip chromium_src-4d9ef386a1e45a363178a92d3215664dba439a2f.tar.gz chromium_src-4d9ef386a1e45a363178a92d3215664dba439a2f.tar.bz2 |
Reverting 31266. threw asserts in test_shell on the bots.
Review URL: http://codereview.chromium.org/377013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31278 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, 141 insertions, 18 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 39df8fd..8384e73 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -127,6 +127,7 @@ 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, @@ -147,6 +148,7 @@ 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 @@ -188,9 +190,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 36e115c..a2f7459 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm +++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm @@ -74,6 +74,24 @@ 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) @@ -95,7 +113,6 @@ WebPluginDelegateImpl::WebPluginDelegateImpl( #ifndef NP_NO_QUICKDRAW memset(&qd_port_, 0, sizeof(qd_port_)); #endif - instance->set_windowless(true); } WebPluginDelegateImpl::~WebPluginDelegateImpl() { @@ -114,9 +131,35 @@ void WebPluginDelegateImpl::PluginDestroyed() { delete this; } -void WebPluginDelegateImpl::PlatformInitialize() { +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; + 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() }; @@ -139,19 +182,46 @@ void WebPluginDelegateImpl::PlatformInitialize() { 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); } - plugin_->SetWindow(NULL); + 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. } 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 @@ -202,27 +272,52 @@ void WebPluginDelegateImpl::Print(CGContextRef context) { // in .01 mm units. } -void WebPluginDelegateImpl::InstallMissingPlugin() { - NOTIMPLEMENTED(); +NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() { + return instance_->GetPluginScriptableObject(); } -bool WebPluginDelegateImpl::WindowedCreatePlugin() { - NOTREACHED(); - return false; +void WebPluginDelegateImpl::DidFinishLoadWithReason( + const GURL& url, NPReason reason, intptr_t notify_data) { + instance()->DidFinishLoadWithReason( + url, reason, reinterpret_cast<void*>(notify_data)); } -void WebPluginDelegateImpl::WindowedDestroyWindow() { - NOTREACHED(); +int WebPluginDelegateImpl::GetProcessId() { + // We are in process, so the plugin pid is this current process pid. + return getpid(); } -bool WebPluginDelegateImpl::WindowedReposition(const gfx::Rect& window_rect, - const gfx::Rect& clip_rect) { - NOTREACHED(); - return false; +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::DidReceiveManualData(const char* buffer, + int length) { + instance()->DidReceiveManualData(buffer, length); +} + +void WebPluginDelegateImpl::DidFinishManualLoading() { + instance()->DidFinishManualLoading(); } -void WebPluginDelegateImpl::WindowedSetWindow() { - NOTREACHED(); +void WebPluginDelegateImpl::DidManualLoadFail() { + instance()->DidManualLoadFail(); +} + +void WebPluginDelegateImpl::InstallMissingPlugin() { + NOTIMPLEMENTED(); } void WebPluginDelegateImpl::WindowlessUpdateGeometry( @@ -690,6 +785,27 @@ 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 47e8de6..1fa755b 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -415,6 +415,11 @@ }], ['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$']], |