summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-08 01:34:11 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-08 01:34:11 +0000
commita813c8e4868ecd41fe76a387b9a5a92a2f7fe67c (patch)
tree2182da5f92ada028888723fa22f499970429e564 /content
parent555e75d02851c9e8ed138f49a6b254dfcac8c1c5 (diff)
downloadchromium_src-a813c8e4868ecd41fe76a387b9a5a92a2f7fe67c.zip
chromium_src-a813c8e4868ecd41fe76a387b9a5a92a2f7fe67c.tar.gz
chromium_src-a813c8e4868ecd41fe76a387b9a5a92a2f7fe67c.tar.bz2
Add a content::RenderView API. I'll make RenderView use it in a future change. To make chrome not know about PepperPluginDelegateImpl and to remove a duplicated block of code, I've modified the plugin creation code a little in content. This also makes WebPlugin creation simpler since it doesn't get the mime type in two ways and has to know to ignore the one in the struct.
BUG=98716 Review URL: http://codereview.chromium.org/8200019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/content_renderer.gypi1
-rw-r--r--content/public/renderer/render_view.h89
-rw-r--r--content/renderer/render_view.cc52
-rw-r--r--content/renderer/render_view.h29
4 files changed, 114 insertions, 57 deletions
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 3bd2be3..d77fdae 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -30,6 +30,7 @@
'public/renderer/render_process_observer.h',
'public/renderer/render_thread.cc',
'public/renderer/render_thread.h',
+ 'public/renderer/render_view.h',
'public/renderer/render_view_observer.cc',
'public/renderer/render_view_observer.h',
'public/renderer/render_view_observer_tracker.h',
diff --git a/content/public/renderer/render_view.h b/content/public/renderer/render_view.h
new file mode 100644
index 0000000..11431da
--- /dev/null
+++ b/content/public/renderer/render_view.h
@@ -0,0 +1,89 @@
+// Copyright (c) 2011 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.
+
+#ifndef CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_
+#define CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_
+
+#include "base/basictypes.h"
+#include "content/common/content_export.h"
+#include "ipc/ipc_message.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
+
+class FilePath;
+struct WebPreferences;
+
+namespace WebKit {
+class WebFrame;
+class WebNode;
+class WebPlugin;
+class WebString;
+class WebView;
+struct WebContextMenuData;
+struct WebPluginParams;
+}
+
+namespace webkit {
+struct WebPluginInfo;
+}
+
+namespace content : public IPC::Message::Sender {
+
+class CONTENT_EXPORT RenderView {
+ public:
+ // Returns the RenderView containing the given WebView.
+ static RenderView* FromWebView(WebKit::WebView* webview);
+
+ virtual ~RenderView() {}
+
+ // Get the routing ID of the view.
+ virtual int GetRoutingId() const = 0;
+
+ // Page IDs allow the browser to identify pages in each renderer process for
+ // keeping back/forward history in sync.
+ // Note that this is NOT updated for every main frame navigation, only for
+ // "regular" navigations that go into session history. In particular, client
+ // redirects, like the page cycler uses (document.location.href="foo") do not
+ // count as regular navigations and do not increment the page id.
+ virtual int GetPageId() = 0;
+
+ // Gets WebKit related preferences associated with this view.
+ virtual WebPreferences& GetWebkitPreferences() = 0;
+
+ // Returns the associated WebView. May return NULL when the view is closing.
+ virtual WebKit::WebView* GetWebView() = 0;
+
+ // Gets the focused node. If no such node exists then the node will be isNull.
+ virtual WebKit::WebNode GetFocusedNode() const = 0;
+
+ // Gets the node that the context menu was pressed over.
+ virtual WebKit::WebNode GetContextMenuNode() const = 0;
+
+ // Returns true if the parameter node is a textfield, text area or a content
+ // editable div.
+ virtual bool IsEditableNode(const WebKit::WebNode& node) = 0;
+
+ // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
+ // plugin was found.
+ virtual WebKit::WebPlugin* CreatePlugin(
+ WebKit::WebFrame* frame,
+ const webkit::WebPluginInfo& info,
+ const WebKit::WebPluginParams& params) = 0;
+
+ // Shows a context menu with commands relevant to a specific element on
+ // the given frame. Additional context data is supplied.
+ virtual void ShowContextMenu(WebKit::WebFrame* frame,
+ const WebKit::WebContextMenuData& data) = 0;
+
+ // Returns the current visibility of the WebView.
+ virtual WebPageVisibilityState GetVisibilityState() const = 0;
+
+ // Displays a modal alert dialog containing the given message. Returns
+ // once the user dismisses the dialog.
+ virtual void RunModalAlertDialog(WebKit::WebFrame* frame,
+ const WebKit::WebString& message) = 0;
+};
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_RENDERER_RENDER_VIEW_H_
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index bb518ef..4dfc3f9 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -514,25 +514,22 @@ void RenderView::PluginCrashed(const FilePath& plugin_path) {
Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path));
}
-WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
- const WebPluginParams& params) {
- webkit::WebPluginInfo info;
- std::string mime_type;
- bool found = GetPluginInfo(params.url, frame->top()->document().url(),
- params.mimeType.utf8(), &info, &mime_type);
- if (!found)
- return NULL;
-
+WebPlugin* RenderView::CreatePluginInternal(WebKit::WebFrame* frame,
+ const webkit::WebPluginInfo& info,
+ const WebPluginParams& params) {
bool pepper_plugin_was_registered = false;
scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
pepper_delegate_.CreatePepperPluginModule(info,
&pepper_plugin_was_registered));
if (pepper_plugin_was_registered) {
- if (pepper_module)
- return CreatePepperPlugin(frame, params, info.path, pepper_module.get());
- return NULL;
+ if (!pepper_module)
+ return NULL;
+ return new webkit::ppapi::WebPluginImpl(
+ pepper_module.get(), params, pepper_delegate_.AsWeakPtr());
}
- return CreateNPAPIPlugin(frame, params, info.path, mime_type);
+
+ return new webkit::npapi::WebPluginImpl(
+ frame, params, info.path, AsWeakPtr());
}
void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) {
@@ -1854,7 +1851,16 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame,
return plugin;
}
- return CreatePluginNoCheck(frame, params);
+ webkit::WebPluginInfo info;
+ std::string mime_type;
+ bool found = GetPluginInfo(params.url, frame->top()->document().url(),
+ params.mimeType.utf8(), &info, &mime_type);
+ if (!found)
+ return NULL;
+
+ WebPluginParams params_to_use = params;
+ params_to_use.mimeType = WebString::fromUTF8(mime_type);
+ return CreatePluginInternal(frame, info, params_to_use);
}
WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) {
@@ -3273,24 +3279,6 @@ void RenderView::OnFindReplyAck() {
}
}
-WebPlugin* RenderView::CreatePepperPlugin(
- WebFrame* frame,
- const WebPluginParams& params,
- const FilePath& path,
- webkit::ppapi::PluginModule* pepper_module) {
- return new webkit::ppapi::WebPluginImpl(
- pepper_module, params, pepper_delegate_.AsWeakPtr());
-}
-
-WebPlugin* RenderView::CreateNPAPIPlugin(
- WebFrame* frame,
- const WebPluginParams& params,
- const FilePath& path,
- const std::string& mime_type) {
- return new webkit::npapi::WebPluginImpl(
- frame, params, path, mime_type, AsWeakPtr());
-}
-
void RenderView::OnZoom(PageZoom::Function function) {
if (!webview()) // Not sure if this can happen, but no harm in being safe.
return;
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 4f229d34..c2cac37 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -279,27 +279,14 @@ class RenderView : public RenderWidget,
// Notification that the given plugin has crashed.
void PluginCrashed(const FilePath& plugin_path);
- // Create a new NPAPI plugin.
- CONTENT_EXPORT WebKit::WebPlugin* CreateNPAPIPlugin(
- WebKit::WebFrame* frame,
- const WebKit::WebPluginParams& params,
- const FilePath& path,
- const std::string& mime_type);
-
- // Create a new Pepper plugin.
- CONTENT_EXPORT WebKit::WebPlugin* CreatePepperPlugin(
- WebKit::WebFrame* frame,
- const WebKit::WebPluginParams& params,
- const FilePath& path,
- webkit::ppapi::PluginModule* pepper_module);
-
// Creates a fullscreen container for a pepper plugin instance.
RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer(
webkit::ppapi::PluginInstance* plugin);
- // Create a new plugin without checking the content settings.
- CONTENT_EXPORT WebKit::WebPlugin* CreatePluginNoCheck(
+ // Create a new plugin.
+ CONTENT_EXPORT WebKit::WebPlugin* CreatePluginInternal(
WebKit::WebFrame* frame,
+ const webkit::WebPluginInfo& info,
const WebKit::WebPluginParams& params);
// Informs the render view that a PPAPI plugin has gained or lost focus.
@@ -1016,15 +1003,7 @@ class RenderView : public RenderWidget,
base::OneShotTimer<RenderView> nav_state_sync_timer_;
// Page IDs ------------------------------------------------------------------
- //
- // Page IDs allow the browser to identify pages in each renderer process for
- // keeping back/forward history in sync.
-
- // ID of the current page. Note that this is NOT updated for every main
- // frame navigation, only for "regular" navigations that go into session
- // history. In particular, client redirects, like the page cycler uses
- // (document.location.href="foo") do not count as regular navigations and do
- // not increment the page id.
+ // See documentation in content::RenderView.
int32 page_id_;
// Indicates the ID of the last page that we sent a FrameNavigate to the