diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 16:20:31 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 16:20:31 +0000 |
commit | a2ef54c1a1061112b48a583c466606ccf07dc28a (patch) | |
tree | dbef7f9418364ac59bf9d32cde8be4da8a98b625 /content | |
parent | 037ffc68a78fd89048dfebc3c1d72b12eac1287e (diff) | |
download | chromium_src-a2ef54c1a1061112b48a583c466606ccf07dc28a.zip chromium_src-a2ef54c1a1061112b48a583c466606ccf07dc28a.tar.gz chromium_src-a2ef54c1a1061112b48a583c466606ccf07dc28a.tar.bz2 |
Make RenderView inherit from content::RenderView, and add missing functions to the interface. In a future change I'll rename RenderView to RenderViewImpl.
BUG=98716
Review URL: http://codereview.chromium.org/8201029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
21 files changed, 311 insertions, 156 deletions
diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h index 9855ee0..a0f8bba 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h @@ -15,7 +15,6 @@ class FilePath; class GURL; -class RenderView; class SkBitmap; namespace WebKit { @@ -33,6 +32,8 @@ template<class T> class Handle; namespace content { +class RenderView; + // Embedder API for participating in renderer logic. class ContentRendererClient { public: diff --git a/content/public/renderer/render_view.h b/content/public/renderer/render_view.h index 11431da..0ae2d2d 100644 --- a/content/public/renderer/render_view.h +++ b/content/public/renderer/render_view.h @@ -8,7 +8,9 @@ #include "base/basictypes.h" #include "content/common/content_export.h" #include "ipc/ipc_message.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationPolicy.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h" +#include "ui/gfx/native_widget_types.h" class FilePath; struct WebPreferences; @@ -18,22 +20,33 @@ class WebFrame; class WebNode; class WebPlugin; class WebString; +class WebURLRequest; class WebView; struct WebContextMenuData; struct WebPluginParams; } +namespace gfx { +class Size; +} + namespace webkit { struct WebPluginInfo; } -namespace content : public IPC::Message::Sender { +namespace content { -class CONTENT_EXPORT RenderView { +class RenderViewVisitor; + +class CONTENT_EXPORT RenderView : public IPC::Message::Sender{ public: // Returns the RenderView containing the given WebView. static RenderView* FromWebView(WebKit::WebView* webview); + // Visit all RenderViews with a live WebView (i.e., RenderViews that have + // been closed but not yet destroyed are excluded). + static void ForEach(RenderViewVisitor* visitor); + virtual ~RenderView() {} // Get the routing ID of the view. @@ -47,6 +60,12 @@ class CONTENT_EXPORT RenderView { // count as regular navigations and do not increment the page id. virtual int GetPageId() = 0; + // Returns the size of the view. + virtual gfx::Size GetSize() = 0; + + // Returns the window we are embedded within. + virtual gfx::NativeViewId GetHostWindow() = 0; + // Gets WebKit related preferences associated with this view. virtual WebPreferences& GetWebkitPreferences() = 0; @@ -70,18 +89,47 @@ class CONTENT_EXPORT RenderView { const webkit::WebPluginInfo& info, const WebKit::WebPluginParams& params) = 0; + // Evaluates a string of JavaScript in a particular frame. + virtual void EvaluateScript(const string16& frame_xpath, + const string16& jscript, + int id, + bool notify_result) = 0; + + // Returns true if we should display scrollbars for the given view size and + // false if the scrollbars should be hidden. + virtual bool ShouldDisplayScrollbars(int width, int height) const = 0; + + // Bitwise-ORed set of extra bindings that have been enabled. See + // BindingsPolicy for details. + virtual int GetEnabledBindings() = 0; + virtual void SetEnabledBindings(int enabled_bindings) = 0; + + // Whether content state (such as form state, scroll position and page + // contents) should be sent to the browser immediately. This is normally + // false, but set to true by some tests. + virtual bool GetContentStateImmediately() = 0; + + // Filtered time per frame based on UpdateRect messages. + virtual float GetFilteredTimePerFrame() = 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; + virtual WebKit::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; + + // The client should handle the navigation externally. + virtual void LoadURLExternally( + WebKit::WebFrame* frame, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationPolicy policy) = 0; }; } // namespace content diff --git a/content/public/renderer/render_view_observer.cc b/content/public/renderer/render_view_observer.cc index 6668990..980985c 100644 --- a/content/public/renderer/render_view_observer.cc +++ b/content/public/renderer/render_view_observer.cc @@ -8,14 +8,21 @@ using WebKit::WebFrame; +// TODO(jam): temporary until RenderView is renamed to RenderViewImpl since +// trying ::RenderView* below gives compile errors in gcc. +typedef RenderView RenderViewImpl; + namespace content { RenderViewObserver::RenderViewObserver(RenderView* render_view) - : render_view_(render_view), - routing_id_(render_view ? render_view->routing_id() : MSG_ROUTING_NONE) { + : render_view_(NULL), + routing_id_(MSG_ROUTING_NONE) { // |render_view| can be NULL on unit testing. - if (render_view_) + if (render_view) { + render_view_ = static_cast<RenderViewImpl*>(render_view); + routing_id_ = render_view_->routing_id(); render_view_->AddObserver(this); + } } RenderViewObserver::~RenderViewObserver() { @@ -39,4 +46,12 @@ bool RenderViewObserver::Send(IPC::Message* message) { return false; } +RenderView* RenderViewObserver::render_view() { + return render_view_; +} + +void RenderViewObserver::set_render_view(::RenderView* rv) { + render_view_ = rv; +} + } // namespace content diff --git a/content/public/renderer/render_view_observer.h b/content/public/renderer/render_view_observer.h index b657af9..e6608a4 100644 --- a/content/public/renderer/render_view_observer.h +++ b/content/public/renderer/render_view_observer.h @@ -28,6 +28,8 @@ struct WebURLError; namespace content { +class RenderView; + // Base class for objects that want to filter incoming IPCs, and also get // notified of changes to the frame. class CONTENT_EXPORT RenderViewObserver : public IPC::Channel::Listener, @@ -87,15 +89,15 @@ class CONTENT_EXPORT RenderViewObserver : public IPC::Channel::Listener, // IPC::Message::Sender implementation. virtual bool Send(IPC::Message* message); - RenderView* render_view() { return render_view_; } + RenderView* render_view(); int routing_id() { return routing_id_; } private: friend class ::RenderView; - void set_render_view(RenderView* rv) { render_view_ = rv; } + void set_render_view(::RenderView* rv); - RenderView* render_view_; + ::RenderView* render_view_; // The routing ID of the associated RenderView. int routing_id_; diff --git a/content/public/renderer/render_view_visitor.h b/content/public/renderer/render_view_visitor.h index d7933c6..59628b4 100644 --- a/content/public/renderer/render_view_visitor.h +++ b/content/public/renderer/render_view_visitor.h @@ -6,10 +6,10 @@ #define CONTENT_PUBLIC_RENDERER_RENDER_VIEW_VISITOR_H_ #pragma once -class RenderView; - namespace content { +class RenderView; + class RenderViewVisitor { public: // Return true to continue visiting RenderViews or false to stop. diff --git a/content/renderer/device_orientation_dispatcher.cc b/content/renderer/device_orientation_dispatcher.cc index c6c9d60..5a70eca 100644 --- a/content/renderer/device_orientation_dispatcher.cc +++ b/content/renderer/device_orientation_dispatcher.cc @@ -5,6 +5,7 @@ #include "content/renderer/device_orientation_dispatcher.h" #include "content/common/device_orientation_messages.h" +#include "content/renderer/render_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientation.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDeviceOrientationController.h" diff --git a/content/renderer/devtools_agent.cc b/content/renderer/devtools_agent.cc index 1934641..0f8f56f 100644 --- a/content/renderer/devtools_agent.cc +++ b/content/renderer/devtools_agent.cc @@ -196,11 +196,11 @@ void DevToolsAgent::OnNavigate() { } void DevToolsAgent::OnSetupDevToolsClient() { - new DevToolsClient(render_view()); + new DevToolsClient(static_cast<RenderView*>(render_view())); } WebDevToolsAgent* DevToolsAgent::GetWebAgent() { - WebView* web_view = render_view()->webview(); + WebView* web_view = render_view()->GetWebView(); if (!web_view) return NULL; return web_view->devToolsAgent(); diff --git a/content/renderer/geolocation_dispatcher.cc b/content/renderer/geolocation_dispatcher.cc index ae457c2..05a9e25 100644 --- a/content/renderer/geolocation_dispatcher.cc +++ b/content/renderer/geolocation_dispatcher.cc @@ -5,6 +5,7 @@ #include "content/renderer/geolocation_dispatcher.h" #include "content/common/geolocation_messages.h" +#include "content/renderer/render_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermissionRequest.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationPermissionRequestManager.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebGeolocationClient.h" diff --git a/content/renderer/intents_dispatcher.cc b/content/renderer/intents_dispatcher.cc index d61df3f..2223109 100644 --- a/content/renderer/intents_dispatcher.cc +++ b/content/renderer/intents_dispatcher.cc @@ -5,6 +5,7 @@ #include "content/renderer/intents_dispatcher.h" #include "content/common/intents_messages.h" +#include "content/renderer/render_view.h" #include "ipc/ipc_message.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h" diff --git a/content/renderer/media/media_stream_dispatcher.cc b/content/renderer/media/media_stream_dispatcher.cc index 6192ed8..6b27867 100644 --- a/content/renderer/media/media_stream_dispatcher.cc +++ b/content/renderer/media/media_stream_dispatcher.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "content/common/media/media_stream_messages.h" #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" +#include "content/renderer/render_view.h" MediaStreamDispatcherEventHandler::~MediaStreamDispatcherEventHandler() {} diff --git a/content/renderer/mhtml_generator.cc b/content/renderer/mhtml_generator.cc index 9bfadaf..883151c 100644 --- a/content/renderer/mhtml_generator.cc +++ b/content/renderer/mhtml_generator.cc @@ -46,7 +46,7 @@ void MHTMLGenerator::NotifyBrowser(int job_id, int64 data_size) { // message loop to process other events. int64 MHTMLGenerator::GenerateMHTML() { WebKit::WebCString mhtml = - WebKit::WebPageSerializer::serializeToMHTML(render_view()->webview()); + WebKit::WebPageSerializer::serializeToMHTML(render_view()->GetWebView()); const size_t chunk_size = 1024; const char* data = mhtml.data(); size_t total_bytes_written = 0; diff --git a/content/renderer/notification_provider.cc b/content/renderer/notification_provider.cc index ce074b5..ae445af 100644 --- a/content/renderer/notification_provider.cc +++ b/content/renderer/notification_provider.cc @@ -70,7 +70,7 @@ void NotificationProvider::requestPermission( const WebSecurityOrigin& origin, WebNotificationPermissionCallback* callback) { // We only request permission in response to a user gesture. - if (!render_view()->webview()->mainFrame()->isProcessingUserGesture()) + if (!render_view()->GetWebView()->mainFrame()->isProcessingUserGesture()) return; int id = manager_.RegisterPermissionRequest(callback); @@ -101,7 +101,7 @@ bool NotificationProvider::ShowHTML(const WebNotification& notification, int id) { DCHECK(notification.isHTML()); DesktopNotificationHostMsg_Show_Params params; - WebDocument document = render_view()->webview()->mainFrame()->document(); + WebDocument document = render_view()->GetWebView()->mainFrame()->document(); params.origin = GURL(document.securityOrigin().toString()); params.is_html = true; params.contents_url = notification.url(); @@ -115,7 +115,7 @@ bool NotificationProvider::ShowText(const WebNotification& notification, DCHECK(!notification.isHTML()); DesktopNotificationHostMsg_Show_Params params; params.is_html = false; - WebDocument document = render_view()->webview()->mainFrame()->document(); + WebDocument document = render_view()->GetWebView()->mainFrame()->document(); params.origin = GURL(document.securityOrigin().toString()); params.icon_url = notification.iconURL(); params.title = notification.title(); diff --git a/content/renderer/p2p/socket_dispatcher.cc b/content/renderer/p2p/socket_dispatcher.cc index 842f848..b9435a2 100644 --- a/content/renderer/p2p/socket_dispatcher.cc +++ b/content/renderer/p2p/socket_dispatcher.cc @@ -8,6 +8,7 @@ #include "content/common/p2p_messages.h" #include "content/renderer/p2p/host_address_request.h" #include "content/renderer/p2p/socket_client.h" +#include "content/renderer/render_view.h" namespace content { diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 3c8cfb6..5d809ae 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -117,8 +117,8 @@ class RenderViewZoomer : public content::RenderViewVisitor { host_ = net::GetHostOrSpecFromURL(url); } - virtual bool Visit(RenderView* render_view) { - WebView* webview = render_view->webview(); + virtual bool Visit(content::RenderView* render_view) { + WebView* webview = render_view->GetWebView(); WebDocument document = webview->mainFrame()->document(); // Don't set zoom level for full-page plugin since they don't use the same diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index eadc4a4..2eb4b19 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -33,6 +33,7 @@ #include "content/common/drag_messages.h" #include "content/common/file_system/file_system_dispatcher.h" #include "content/common/file_system/webfilesystem_callback_dispatcher.h" +#include "content/common/intents_messages.h" #include "content/common/notification_service.h" #include "content/common/pepper_messages.h" #include "content/common/pepper_plugin_registry.h" @@ -442,19 +443,25 @@ RenderView::~RenderView() { } /*static*/ -void RenderView::ForEach(RenderViewVisitor* visitor) { +RenderView* RenderView::FromWebView(WebView* webview) { ViewMap* views = g_view_map.Pointer(); - for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { - if (!visitor->Visit(it->second)) - return; - } + ViewMap::iterator it = views->find(webview); + return it == views->end() ? NULL : it->second; } /*static*/ -RenderView* RenderView::FromWebView(WebView* webview) { +content::RenderView* + content::RenderView::FromWebView(WebKit::WebView* webview) { + return ::RenderView::FromWebView(webview); +} + +/*static*/ +void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { ViewMap* views = g_view_map.Pointer(); - ViewMap::iterator it = views->find(webview); - return it == views->end() ? NULL : it->second; + for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { + if (!visitor->Visit(it->second)) + return; + } } /*static*/ @@ -514,24 +521,6 @@ void RenderView::PluginCrashed(const FilePath& plugin_path) { Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); } -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 NULL; - return new webkit::ppapi::WebPluginImpl( - pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); - } - - return new webkit::npapi::WebPluginImpl( - frame, params, info.path, AsWeakPtr()); -} - void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { plugin_delegates_.insert(delegate); // If the renderer is visible, set initial visibility and focus state. @@ -1860,7 +1849,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, WebPluginParams params_to_use = params; params_to_use.mimeType = WebString::fromUTF8(mime_type); - return CreatePluginInternal(frame, info, params_to_use); + return CreatePlugin(frame, info, params_to_use); } WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { @@ -2949,7 +2938,154 @@ void RenderView::didSerializeDataForFrame( static_cast<int32>(status))); } -// webkit_glue::WebPluginPageDelegate ----------------------------------------- +// content::RenderView implementation ------------------------------------------ + +bool RenderView::Send(IPC::Message* message) { + return RenderWidget::Send(message); +} + +int RenderView::GetRoutingId() const { + return routing_id_; +} + +int RenderView::GetPageId() { + return page_id_; +} + +gfx::Size RenderView::GetSize() { + return size(); +} + +gfx::NativeViewId RenderView::GetHostWindow() { + return host_window(); +} + +WebPreferences& RenderView::GetWebkitPreferences() { + return webkit_preferences_; +} + +WebKit::WebView* RenderView::GetWebView() { + return webview(); +} + +WebKit::WebNode RenderView::GetFocusedNode() const { + if (!webview()) + return WebNode(); + WebFrame* focused_frame = webview()->focusedFrame(); + if (focused_frame) { + WebDocument doc = focused_frame->document(); + if (!doc.isNull()) + return doc.focusedNode(); + } + + return WebNode(); +} + +WebKit::WebNode RenderView::GetContextMenuNode() const { + return context_menu_node_; +} + +bool RenderView::IsEditableNode(const WebKit::WebNode& node) { + bool is_editable_node = false; + if (!node.isNull()) { + if (node.isContentEditable()) { + is_editable_node = true; + } else if (node.isElementNode()) { + is_editable_node = + node.toConst<WebElement>().isTextFormControlElement(); + } + } + return is_editable_node; +} + +WebKit::WebPlugin* RenderView::CreatePlugin( + WebKit::WebFrame* frame, + const webkit::WebPluginInfo& info, + const WebKit::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 NULL; + return new webkit::ppapi::WebPluginImpl( + pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); + } + + return new webkit::npapi::WebPluginImpl( + frame, params, info.path, AsWeakPtr()); +} + +void RenderView::EvaluateScript(const string16& frame_xpath, + const string16& jscript, + int id, + bool notify_result) { + v8::Handle<v8::Value> result; + WebFrame* web_frame = GetChildFrame(frame_xpath); + if (web_frame) + result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); + if (notify_result) { + ListValue list; + if (!result.IsEmpty() && web_frame) { + v8::HandleScope handle_scope; + v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); + v8::Context::Scope context_scope(context); + V8ValueConverterImpl converter; + converter.set_allow_date(true); + converter.set_allow_regexp(true); + list.Set(0, converter.FromV8Value(result, context)); + } else { + list.Set(0, Value::CreateNullValue()); + } + Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); + } +} + +bool RenderView::ShouldDisplayScrollbars(int width, int height) const { + return (!send_preferred_size_changes_ || + (disable_scrollbars_size_limit_.width() <= width || + disable_scrollbars_size_limit_.height() <= height)); +} + +int RenderView::GetEnabledBindings() { + return enabled_bindings_; +} + +void RenderView::SetEnabledBindings(int enabled_bindings) { + enabled_bindings_ = enabled_bindings; +} + +bool RenderView::GetContentStateImmediately() { + return send_content_state_immediately_; +} + +float RenderView::GetFilteredTimePerFrame() { + return filtered_time_per_frame(); +} + +void RenderView::ShowContextMenu(WebKit::WebFrame* frame, + const WebKit::WebContextMenuData& data) { + showContextMenu(frame, data); +} + +WebKit::WebPageVisibilityState RenderView::GetVisibilityState() const { + return visibilityState(); +} + +void RenderView::RunModalAlertDialog(WebKit::WebFrame* frame, + const WebKit::WebString& message) { + return runModalAlertDialog(frame, message); +} + +void RenderView::LoadURLExternally( + WebKit::WebFrame* frame, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationPolicy policy) { + loadURLExternally(frame, request, policy); +} + +// webkit_glue::WebPluginPageDelegate ------------------------------------------ webkit::npapi::WebPluginDelegate* RenderView::CreatePluginDelegate( const FilePath& file_path, @@ -3108,7 +3244,8 @@ GURL RenderView::GetOpenerUrl() const { WebUIBindings* RenderView::GetWebUIBindings() { if (!web_ui_bindings_.get()) { - web_ui_bindings_.reset(new WebUIBindings(this, routing_id_)); + web_ui_bindings_.reset(new WebUIBindings( + static_cast<content::RenderView*>(this), routing_id_)); } return web_ui_bindings_.get(); } @@ -3379,57 +3516,6 @@ WebFrame* RenderView::GetChildFrame(const string16& xpath) const { return frame; } -WebNode RenderView::GetFocusedNode() const { - if (!webview()) - return WebNode(); - WebFrame* focused_frame = webview()->focusedFrame(); - if (focused_frame) { - WebDocument doc = focused_frame->document(); - if (!doc.isNull()) - return doc.focusedNode(); - } - - return WebNode(); -} - -bool RenderView::IsEditableNode(const WebNode& node) { - bool is_editable_node = false; - if (!node.isNull()) { - if (node.isContentEditable()) { - is_editable_node = true; - } else if (node.isElementNode()) { - is_editable_node = - node.toConst<WebElement>().isTextFormControlElement(); - } - } - return is_editable_node; -} - -void RenderView::EvaluateScript(const string16& frame_xpath, - const string16& script, - int id, - bool notify_result) { - v8::Handle<v8::Value> result; - WebFrame* web_frame = GetChildFrame(frame_xpath); - if (web_frame) - result = web_frame->executeScriptAndReturnValue(WebScriptSource(script)); - if (notify_result) { - ListValue list; - if (!result.IsEmpty() && web_frame) { - v8::HandleScope handle_scope; - v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); - v8::Context::Scope context_scope(context); - V8ValueConverterImpl converter; - converter.set_allow_date(true); - converter.set_allow_regexp(true); - list.Set(0, converter.FromV8Value(result, context)); - } else { - list.Set(0, Value::CreateNullValue()); - } - Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); - } -} - void RenderView::OnScriptEvalRequest(const string16& frame_xpath, const string16& jscript, int id, @@ -3802,7 +3888,7 @@ void RenderView::OnResize(const gfx::Size& new_size, webview()->hidePopups(); if (send_preferred_size_changes_) { webview()->mainFrame()->setCanHaveScrollbars( - should_display_scrollbars(new_size.width(), new_size.height())); + ShouldDisplayScrollbars(new_size.width(), new_size.height())); } UpdateScrollState(webview()->mainFrame()); } diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h index c2cac37..753d92b 100644 --- a/content/renderer/render_view.h +++ b/content/renderer/render_view.h @@ -25,10 +25,10 @@ #include "content/renderer/renderer_webcookiejar_impl.h" #include "content/common/content_export.h" #include "content/common/edit_command.h" -#include "content/common/intents_messages.h" #include "content/common/navigation_gesture.h" #include "content/common/page_zoom.h" #include "content/common/renderer_preferences.h" +#include "content/public/renderer/render_view.h" #include "content/renderer/pepper_plugin_delegate_impl.h" #include "content/renderer/render_widget.h" #include "ipc/ipc_platform_file.h" @@ -57,7 +57,6 @@ class AudioMessageFilter; class DeviceOrientationDispatcher; class DevToolsAgent; class ExternalPopupMenu; -class FilePath; class GeolocationDispatcher; class GURL; class IntentsDispatcher; @@ -120,7 +119,6 @@ class WebApplicationCacheHostClient; class WebDataSource; class WebDocument; class WebDragData; -class WebFrame; class WebGeolocationClient; class WebGeolocationServiceInterface; class WebIconURL; @@ -130,19 +128,15 @@ class WebKeyboardEvent; class WebMediaPlayer; class WebMediaPlayerClient; class WebMouseEvent; -class WebPlugin; class WebSpeechInputController; class WebSpeechInputListener; class WebStorageNamespace; class WebTouchEvent; class WebURLLoader; class WebURLRequest; -class WebView; -struct WebContextMenuData; struct WebFileChooserParams; struct WebFindOptions; struct WebMediaPlayerAction; -struct WebPluginParams; struct WebPoint; struct WebWindowFeatures; } @@ -169,6 +163,7 @@ class RenderView : public RenderWidget, public WebKit::WebViewClient, public WebKit::WebFrameClient, public WebKit::WebPageSerializerClient, + public content::RenderView, public webkit::npapi::WebPluginPageDelegate, public base::SupportsWeakPtr<RenderView> { public: @@ -188,10 +183,6 @@ class RenderView : public RenderWidget, int64 session_storage_namespace_id, const string16& frame_name); - // Visit all RenderViews with a live WebView (i.e., RenderViews that have - // been closed but not yet destroyed are excluded). - CONTENT_EXPORT static void ForEach(content::RenderViewVisitor* visitor); - // Returns the RenderView containing the given WebView. CONTENT_EXPORT static RenderView* FromWebView(WebKit::WebView* webview); @@ -207,31 +198,16 @@ class RenderView : public RenderWidget, void OnViewContextSwapBuffersComplete(); void OnViewContextSwapBuffersAborted(); - int page_id() const { return page_id_; } int history_list_offset() const { return history_list_offset_; } - PepperPluginDelegateImpl* pepper_delegate() { return &pepper_delegate_; } const WebPreferences& webkit_preferences() const { return webkit_preferences_; } - bool content_state_immediately() { return send_content_state_immediately_; } - int enabled_bindings() const { return enabled_bindings_; } - void set_enabled_bindings(int b) { enabled_bindings_ = b; } void set_send_content_state_immediately(bool value) { send_content_state_immediately_ = value; } - // Returns true if we should display scrollbars for the given view size and - // false if the scrollbars should be hidden. - bool should_display_scrollbars(int width, int height) const { - return (!send_preferred_size_changes_ || - (disable_scrollbars_size_limit_.width() <= width || - disable_scrollbars_size_limit_.height() <= height)); - } - - const WebKit::WebNode& context_menu_node() { return context_menu_node_; } - // Current P2PSocketDispatcher. Set to NULL if P2P API is disabled. content::P2PSocketDispatcher* p2p_socket_dispatcher() { return p2p_socket_dispatcher_; @@ -241,12 +217,6 @@ class RenderView : public RenderWidget, void AddObserver(content::RenderViewObserver* observer); void RemoveObserver(content::RenderViewObserver* observer); - // Evaluates a string of JavaScript in a particular frame. - CONTENT_EXPORT void EvaluateScript(const string16& frame_xpath, - const string16& jscript, - int id, - bool notify_result); - // Adds the given file chooser request to the file_chooser_completion_ queue // (see that var for more) and requests the chooser be displayed if there are // no other waiting items in the queue. @@ -259,14 +229,7 @@ class RenderView : public RenderWidget, // Sets whether the renderer should report load progress to the browser. void SetReportLoadProgressEnabled(bool enabled); - // Gets the focused node. If no such node exists then the node will be isNull. - CONTENT_EXPORT WebKit::WebNode GetFocusedNode() const; - - // Returns true if the parameter node is a textfield, text area or a content - // editable div. - CONTENT_EXPORT bool IsEditableNode(const WebKit::WebNode& node); - - CONTENT_EXPORT void LoadNavigationErrorPage( + void LoadNavigationErrorPage( WebKit::WebFrame* frame, const WebKit::WebURLRequest& failed_request, const WebKit::WebURLError& error, @@ -283,12 +246,6 @@ class RenderView : public RenderWidget, RenderWidgetFullscreenPepper* CreatePepperFullscreenContainer( webkit::ppapi::PluginInstance* plugin); - // 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. void PpapiPluginFocusChanged(); @@ -592,6 +549,41 @@ class RenderView : public RenderWidget, const WebKit::WebCString& data, PageSerializationStatus status) OVERRIDE; + // content::RenderView implementation ---------------------------------------- + + virtual bool Send(IPC::Message* message) OVERRIDE; + virtual int GetRoutingId() const OVERRIDE; + virtual int GetPageId() OVERRIDE; + virtual gfx::Size GetSize() OVERRIDE; + virtual gfx::NativeViewId GetHostWindow() OVERRIDE; + virtual WebPreferences& GetWebkitPreferences() OVERRIDE; + virtual WebKit::WebView* GetWebView() OVERRIDE; + virtual WebKit::WebNode GetFocusedNode() const OVERRIDE; + virtual WebKit::WebNode GetContextMenuNode() const OVERRIDE; + virtual bool IsEditableNode(const WebKit::WebNode& node) OVERRIDE; + virtual WebKit::WebPlugin* CreatePlugin( + WebKit::WebFrame* frame, + const webkit::WebPluginInfo& info, + const WebKit::WebPluginParams& params) OVERRIDE; + virtual void EvaluateScript(const string16& frame_xpath, + const string16& jscript, + int id, + bool notify_result) OVERRIDE; + virtual bool ShouldDisplayScrollbars(int width, int height) const OVERRIDE; + virtual int GetEnabledBindings() OVERRIDE; + virtual void SetEnabledBindings(int enabled_bindings) OVERRIDE; + virtual bool GetContentStateImmediately() OVERRIDE; + virtual float GetFilteredTimePerFrame() OVERRIDE; + virtual void ShowContextMenu(WebKit::WebFrame* frame, + const WebKit::WebContextMenuData& data) OVERRIDE; + virtual WebKit::WebPageVisibilityState GetVisibilityState() const OVERRIDE; + virtual void RunModalAlertDialog(WebKit::WebFrame* frame, + const WebKit::WebString& message) OVERRIDE; + virtual void LoadURLExternally( + WebKit::WebFrame* frame, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationPolicy policy) OVERRIDE; + // webkit_glue::WebPluginPageDelegate implementation ------------------------- virtual webkit::npapi::WebPluginDelegate* CreatePluginDelegate( diff --git a/content/renderer/renderer_accessibility.cc b/content/renderer/renderer_accessibility.cc index bdf3346..49d0d15 100644 --- a/content/renderer/renderer_accessibility.cc +++ b/content/renderer/renderer_accessibility.cc @@ -407,7 +407,7 @@ void RendererAccessibility::OnSetAccessibilityFocus(int acc_obj_id) { // By convention, calling SetFocus on the root of the tree should clear the // current focus. Otherwise set the focus to the new node. if (acc_obj_id == root.axID()) - render_view()->webview()->clearFocusedNode(); + render_view()->GetWebView()->clearFocusedNode(); else obj.setFocused(true); } @@ -424,7 +424,7 @@ bool RendererAccessibility::ShouldIncludeChildren( } WebDocument RendererAccessibility::GetMainDocument() { - WebView* view = render_view()->webview(); + WebView* view = render_view()->GetWebView(); WebFrame* main_frame = view ? view->mainFrame() : NULL; if (main_frame) diff --git a/content/renderer/speech_input_dispatcher.cc b/content/renderer/speech_input_dispatcher.cc index 2cbcd7d..735cc0b 100644 --- a/content/renderer/speech_input_dispatcher.cc +++ b/content/renderer/speech_input_dispatcher.cc @@ -62,7 +62,7 @@ bool SpeechInputDispatcher::startRecognition( params.origin_url = UTF16ToUTF8(origin.toString()); params.render_view_id = routing_id(); params.request_id = request_id; - gfx::Size scroll = render_view()->webview()->mainFrame()->scrollOffset(); + gfx::Size scroll = render_view()->GetWebView()->mainFrame()->scrollOffset(); params.element_rect = element_rect; params.element_rect.Offset(-scroll.width(), -scroll.height()); @@ -111,7 +111,7 @@ void SpeechInputDispatcher::OnSpeechRecognitionComplete(int request_id) { void SpeechInputDispatcher::OnSpeechRecognitionToggleSpeechInput() { VLOG(1) << "SpeechInputDispatcher::OnSpeechRecognitionToggleSpeechInput"; - WebView* web_view = render_view()->webview(); + WebView* web_view = render_view()->GetWebView(); WebFrame* frame = web_view->mainFrame(); if (!frame) diff --git a/content/renderer/text_input_client_observer.cc b/content/renderer/text_input_client_observer.cc index b4b5b9e..67d7486 100644 --- a/content/renderer/text_input_client_observer.cc +++ b/content/renderer/text_input_client_observer.cc @@ -37,7 +37,7 @@ bool TextInputClientObserver::OnMessageReceived(const IPC::Message& message) { } WebKit::WebView* TextInputClientObserver::webview() { - return render_view()->webview(); + return render_view()->GetWebView(); } void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) { diff --git a/content/test/render_view_fake_resources_test.cc b/content/test/render_view_fake_resources_test.cc index 38aadfb..a3a6867 100644 --- a/content/test/render_view_fake_resources_test.cc +++ b/content/test/render_view_fake_resources_test.cc @@ -47,8 +47,8 @@ bool RenderViewFakeResourcesTest::OnMessageReceived( return true; } -bool RenderViewFakeResourcesTest::Visit(RenderView* render_view) { - view_ = render_view; +bool RenderViewFakeResourcesTest::Visit(content::RenderView* render_view) { + view_ = static_cast<RenderView*>(render_view); return false; } @@ -100,6 +100,10 @@ void RenderViewFakeResourcesTest::TearDown() { mock_process_.reset(); } +content::RenderView* RenderViewFakeResourcesTest::view() { + return view_; +} + WebKit::WebFrame* RenderViewFakeResourcesTest::GetMainFrame() { return view_->webview()->mainFrame(); } @@ -186,7 +190,7 @@ void RenderViewFakeResourcesTest::GoToOffset( int offset, const WebKit::WebHistoryItem& history_item) { ViewMsg_Navigate_Params params; - params.page_id = view_->page_id() + offset; + params.page_id = view_->GetPageId() + offset; params.pending_history_list_offset = view_->history_list_offset() + offset; params.current_history_list_offset = view_->history_list_offset(); diff --git a/content/test/render_view_fake_resources_test.h b/content/test/render_view_fake_resources_test.h index d42e8a8..b0b28b7 100644 --- a/content/test/render_view_fake_resources_test.h +++ b/content/test/render_view_fake_resources_test.h @@ -71,7 +71,7 @@ class RenderViewFakeResourcesTest : public ::testing::Test, virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; // RenderViewVisitor implementation. - virtual bool Visit(RenderView* render_view) OVERRIDE; + virtual bool Visit(content::RenderView* render_view) OVERRIDE; protected: RenderViewFakeResourcesTest(); @@ -82,6 +82,8 @@ class RenderViewFakeResourcesTest : public ::testing::Test, virtual void SetUp() OVERRIDE; virtual void TearDown() OVERRIDE; + content::RenderView* view(); + // Loads |url| into the RenderView, waiting for the load to finish. // Before loading the url, add any content that you want to return // to responses_. |