summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authoramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 23:49:05 +0000
committeramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 23:49:05 +0000
commit6ef2d78d1166ce8225e1219ae8a599705bca88d2 (patch)
tree927fae391271f538b9c392e6962fa57375bc1d5b /webkit/glue
parenta74050aee8760154318b1bece223259788e072aa (diff)
downloadchromium_src-6ef2d78d1166ce8225e1219ae8a599705bca88d2.zip
chromium_src-6ef2d78d1166ce8225e1219ae8a599705bca88d2.tar.gz
chromium_src-6ef2d78d1166ce8225e1219ae8a599705bca88d2.tar.bz2
Reverting 25262. Worked OK in the browser, but blew up TestShell.
TBR=evan Review URL: http://codereview.chromium.org/194001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h4
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm163
2 files changed, 147 insertions, 20 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 8520965..51f3839 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -107,6 +107,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,
@@ -127,6 +128,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
@@ -165,10 +167,12 @@ class WebPluginDelegateImpl : public webkit_glue::WebPluginDelegate {
// Closes down and destroys our plugin instance.
void DestroyInstance();
+#if !defined(OS_MACOSX)
// used for windowed plugins
gfx::PluginWindowHandle windowed_handle_;
bool windowed_did_set_window_;
gfx::Rect windowed_last_pos_;
+#endif
// 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 a73ba8c..08e91bc 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -64,6 +64,24 @@ int g_current_y_offset = 0;
} // namespace
+WebPluginDelegate* WebPluginDelegate::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)
@@ -93,7 +111,26 @@ void WebPluginDelegateImpl::PluginDestroyed() {
delete this;
}
-void WebPluginDelegateImpl::PlatformInitialize() {
+bool WebPluginDelegateImpl::Initialize(const GURL& url,
+ char** argn,
+ char** argv,
+ int argc,
+ WebPlugin* plugin,
+ bool load_manually) {
+ plugin_ = plugin;
+
+ instance_->set_web_plugin(plugin);
+ NPAPI::PluginInstance* old_instance =
+ NPAPI::PluginInstance::SetInitializingInstance(instance_);
+
+
+ bool start_result = instance_->Start(url, argn, argv, argc, load_manually);
+
+ NPAPI::PluginInstance::SetInitializingInstance(old_instance);
+
+ if (!start_result)
+ return false;
+
FakePluginWindowTracker* window_tracker =
FakePluginWindowTracker::SharedInstance();
cg_context_.window = window_tracker->GenerateFakeWindowForDelegate(this);
@@ -102,18 +139,43 @@ void WebPluginDelegateImpl::PlatformInitialize() {
SetWindowBounds(cg_context_.window, kWindowContentRgn, &window_bounds);
window_.window = &cg_context_;
window_.type = NPWindowTypeWindow;
- instance_->set_window_handle(cg_context_.window);
- instance_->set_windowless(true);
- windowless_ = true;
- plugin_->SetWindow(NULL);
+
+ plugin->SetWindow(NULL);
+ plugin_url_ = url.spec();
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.
}
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) {
@@ -133,9 +195,64 @@ void WebPluginDelegateImpl::Paint(CGContextRef context, const gfx::Rect& rect) {
}
void WebPluginDelegateImpl::Print(CGContextRef context) {
+ // Disabling the call to NPP_Print as it causes a crash in
+ // flash in some cases. In any case this does not work as expected
+ // as the EMF meta file dc passed in needs to be created with the
+ // the plugin window dc as its sibling dc and the window rect
+ // 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::DidReceiveManualData(const char* buffer,
+ int length) {
+ instance()->DidReceiveManualData(buffer, length);
+}
+
+void WebPluginDelegateImpl::DidFinishManualLoading() {
+ instance()->DidFinishManualLoading();
+}
+
+void WebPluginDelegateImpl::DidManualLoadFail() {
+ instance()->DidManualLoadFail();
+}
+
+FilePath WebPluginDelegateImpl::GetPluginPath() {
+ return instance()->plugin_lib()->plugin_info().path;
}
void WebPluginDelegateImpl::InstallMissingPlugin() {
+ NPEvent evt;
+ instance()->NPP_HandleEvent(&evt);
}
void WebPluginDelegateImpl::WindowlessUpdateGeometry(
@@ -212,21 +329,6 @@ static void UpdateDummyWindowBoundsWithOffset(WindowRef window,
}
}
-void WebPluginDelegateImpl::WindowedSetWindow() {
- NOTREACHED();
-}
-
-bool WebPluginDelegateImpl::WindowedReposition(
- const gfx::Rect& window_rect,
- const gfx::Rect& clip_rect) {
- NOTREACHED();
- return false;
-}
-
-bool WebPluginDelegateImpl::WindowedCreatePlugin() {
- return true;
-}
-
void WebPluginDelegateImpl::WindowlessSetWindow(bool force_set_window) {
if (!instance())
return;
@@ -422,6 +524,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() {
NPEvent np_event = {0};
np_event.what = nullEvent;