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:12:21 +0000
committeramanda@chromium.org <amanda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 23:12:21 +0000
commite703ee9cf1b2bcdceb0112b2f06c88d719b50b4f (patch)
tree01f67ce3a04b262731330b201896fde1b55748d6 /webkit/glue
parent01b0df26a5cbdd2e66d244246d815695b7f2363a (diff)
downloadchromium_src-e703ee9cf1b2bcdceb0112b2f06c88d719b50b4f.zip
chromium_src-e703ee9cf1b2bcdceb0112b2f06c88d719b50b4f.tar.gz
chromium_src-e703ee9cf1b2bcdceb0112b2f06c88d719b50b4f.tar.bz2
Unfork shared parts of webplugin_delegate_impl_mac.mm.
(Mac side of http://codereview.chromium.org/174479) evan/darin: review, whoever sees it first jam: FYI BUG=none TEST=pages with plugins that worked before this patch should still work after it. Review URL: http://codereview.chromium.org/172116 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25262 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, 20 insertions, 147 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index 51f3839..8520965 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -107,7 +107,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,
@@ -128,7 +127,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
@@ -167,12 +165,10 @@ 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 08e91bc..a73ba8c 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -64,24 +64,6 @@ 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)
@@ -111,26 +93,7 @@ void WebPluginDelegateImpl::PluginDestroyed() {
delete this;
}
-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;
-
+void WebPluginDelegateImpl::PlatformInitialize() {
FakePluginWindowTracker* window_tracker =
FakePluginWindowTracker::SharedInstance();
cg_context_.window = window_tracker->GenerateFakeWindowForDelegate(this);
@@ -139,43 +102,18 @@ bool WebPluginDelegateImpl::Initialize(const GURL& url,
SetWindowBounds(cg_context_.window, kWindowContentRgn, &window_bounds);
window_.window = &cg_context_;
window_.type = NPWindowTypeWindow;
-
- plugin->SetWindow(NULL);
- plugin_url_ = url.spec();
+ instance_->set_window_handle(cg_context_.window);
+ instance_->set_windowless(true);
+ windowless_ = true;
+ plugin_->SetWindow(NULL);
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) {
@@ -195,64 +133,9 @@ 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(
@@ -329,6 +212,21 @@ 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;
@@ -524,27 +422,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() {
NPEvent np_event = {0};
np_event.what = nullEvent;