summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webplugin_impl.h
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 17:10:59 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-02 17:10:59 +0000
commitf103ab7a3af66f93aa6b674598ee8c977917f5f2 (patch)
tree670587d6caf0d0fc0a864f7b8d6e7b8da8f11f6d /webkit/glue/webplugin_impl.h
parentee2bd0350faae7e862af993b8884d6c9c48559a4 (diff)
downloadchromium_src-f103ab7a3af66f93aa6b674598ee8c977917f5f2.zip
chromium_src-f103ab7a3af66f93aa6b674598ee8c977917f5f2.tar.gz
chromium_src-f103ab7a3af66f93aa6b674598ee8c977917f5f2.tar.bz2
Eliminate remaining WebCore dependencies from webplugin_impl.cc
Introduces WebPluginPageDelegate to hold the methods that only existed on WebViewDelegate to allow WebPluginImpl to talk to the RenderView. This enables us to eliminate those methods from WebViewDelegate, which eliminates the last dependency on gfx/ native_widget_types.h in our WebKit interface! WebViewDelegate grows a CreatePlugin method that returns a WebKit::WebPlugin. It loses its CreatePluginDelegate method, which now lives on WebPluginPageDelegate. This change makes RenderView use WeakPtr when it hands itself to each WebPluginDelegateProxy and WebPluginImpl instance. This makes the memory management simpler. This change also moves various WebPlugin* interfaces defined in webkit/glue into the webkit_glue namespace. This was to help reduce confusion with similarly named types in the WebKit namespace. WebKit::WebPluginParams is added to contain the set of parameters used to construct a plugin. WebPluginContainer gets a couple more methods to allow us to avoid WebCore dependencies in WebPluginImpl. R=jam BUG=10036 TEST=none Review URL: http://codereview.chromium.org/181014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25184 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webplugin_impl.h')
-rw-r--r--webkit/glue/webplugin_impl.h92
1 files changed, 35 insertions, 57 deletions
diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h
index 09505af..07e043c 100644
--- a/webkit/glue/webplugin_impl.h
+++ b/webkit/glue/webplugin_impl.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -9,45 +9,33 @@
#include <map>
#include <vector>
-#include "Widget.h"
-
#include "base/basictypes.h"
#include "base/gfx/native_widget_types.h"
#include "base/linked_ptr.h"
+#include "base/task.h"
+#include "base/weak_ptr.h"
+#include "googleurl/src/gurl.h"
#include "webkit/api/public/WebPlugin.h"
+#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURLLoaderClient.h"
#include "webkit/api/public/WebURLRequest.h"
-#include "webkit/glue/webframe_impl.h"
+#include "webkit/api/public/WebVector.h"
#include "webkit/glue/webplugin.h"
-
-class WebFrameImpl;
-class WebPluginDelegate;
-
-namespace WebCore {
-class Event;
-class Frame;
-class HTMLPlugInElement;
-class IntRect;
-class KeyboardEvent;
-class KURL;
-class MouseEvent;
-class ResourceError;
-class ResourceResponse;
-class ScrollView;
-class String;
-class Widget;
-}
+class WebViewDelegate;
namespace WebKit {
+class WebFrame;
class WebPluginContainer;
class WebURLResponse;
class WebURLLoader;
}
namespace webkit_glue {
+
class MultipartResponseDelegate;
-}
+class WebPluginDelegate;
+class WebPluginPageDelegate;
// This is the WebKit side of the plugin implementation that forwards calls,
// after changing out of WebCore types, to a delegate. The delegate may
@@ -56,19 +44,11 @@ class WebPluginImpl : public WebPlugin,
public WebKit::WebPlugin,
public WebKit::WebURLLoaderClient {
public:
- // Creates a WebPlugin instance, as long as the delegate's initialization
- // succeeds. If it fails, the delegate is deleted and NULL is returned.
- // Note that argn and argv are UTF8.
- static PassRefPtr<WebCore::Widget> Create(const GURL& url,
- char** argn,
- char** argv,
- int argc,
- WebCore::HTMLPlugInElement* element,
- WebFrameImpl* frame,
- WebPluginDelegate* delegate,
- bool load_manually,
- const std::string& mime_type);
- virtual ~WebPluginImpl();
+ WebPluginImpl(
+ WebKit::WebFrame* frame,
+ const WebKit::WebPluginParams& params,
+ const base::WeakPtr<WebPluginPageDelegate>& page_delegate);
+ ~WebPluginImpl();
// Helper function for sorting post data.
static bool SetPostData(WebKit::WebURLRequest* request,
@@ -76,12 +56,9 @@ class WebPluginImpl : public WebPlugin,
uint32 length);
private:
- WebPluginImpl(
- WebFrameImpl* frame, WebPluginDelegate* delegate, const GURL& plugin_url,
- bool load_manually, const std::string& mime_type, int arg_count,
- char** arg_names, char** arg_values);
-
// WebKit::WebPlugin methods:
+ virtual bool initialize(
+ WebKit::WebPluginContainer* container);
virtual void destroy();
virtual NPObject* scriptableObject();
virtual void paint(
@@ -123,6 +100,13 @@ class WebPluginImpl : public WebPlugin,
bool notify_needed, intptr_t notify_data,
bool popups_allowed);
+ enum RoutingStatus {
+ ROUTED,
+ NOT_ROUTED,
+ INVALID_URL,
+ GENERAL_FAILURE
+ };
+
// Given a download request, check if we need to route the output to a frame.
// Returns ROUTED if the load is done and routed to a frame, NOT_ROUTED or
// corresponding error codes otherwise.
@@ -130,7 +114,7 @@ class WebPluginImpl : public WebPlugin,
const char* target, unsigned int len,
const char* buf, bool is_file_data,
bool notify_needed, intptr_t notify_data,
- const char* url, GURL* completeURL);
+ const char* url);
// Cancels a pending request.
void CancelResource(int id);
@@ -195,8 +179,6 @@ class WebPluginImpl : public WebPlugin,
// request given a handle.
void RemoveClient(WebKit::WebURLLoader* loader);
- WebCore::Frame* frame() { return webframe_ ? webframe_->frame() : NULL; }
-
void HandleURLRequest(const char *method,
bool is_javascript_url,
const char* target, unsigned int len,
@@ -231,16 +213,9 @@ class WebPluginImpl : public WebPlugin,
// to handle the response identified by the loader parameter.
bool ReinitializePluginForResponse(WebKit::WebURLLoader* loader);
- // Helper functions to convert an array of names/values to a vector.
- static void ArrayToVector(int total_values, char** values,
- std::vector<std::string>* value_vector);
-
// Delayed task for downloading the plugin source URL.
void OnDownloadPluginSrcUrl();
- // Returns the WebViewDelegate associated with webframe_;
- WebViewDelegate* GetWebViewDelegate();
-
struct ClientInfo {
int id;
WebPluginResourceClient* client;
@@ -257,7 +232,8 @@ class WebPluginImpl : public WebPlugin,
bool windowless_;
gfx::PluginWindowHandle window_;
- WebFrameImpl* webframe_;
+ base::WeakPtr<WebPluginPageDelegate> page_delegate_;
+ WebKit::WebFrame* webframe_;
WebPluginDelegate* delegate_;
@@ -290,15 +266,17 @@ class WebPluginImpl : public WebPlugin,
// The mime type of the plugin.
std::string mime_type_;
- // Holds the list of argument names passed to the plugin.
- std::vector<std::string> arg_names_;
-
- // Holds the list of argument values passed to the plugin.
- std::vector<std::string> arg_values_;
+ // Holds the list of argument names and values passed to the plugin. We keep
+ // these so that we can re-initialize the plugin if we need to.
+ char** arg_names_;
+ char** arg_values_;
+ size_t arg_count_;
ScopedRunnableMethodFactory<WebPluginImpl> method_factory_;
DISALLOW_COPY_AND_ASSIGN(WebPluginImpl);
};
+} // namespace webkit_glue
+
#endif // #ifndef WEBKIT_GLUE_WEBPLUGIN_IMPL_H_