render_frame.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ 6#define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ 7 8#include "content/common/content_export.h" 9#include "ipc/ipc_listener.h" 10#include "ipc/ipc_sender.h" 11#include "third_party/WebKit/public/web/WebNavigationPolicy.h" 12 13struct WebPreferences; 14 15namespace blink { 16class WebFrame; 17class WebNode; 18class WebPlugin; 19class WebURLRequest; 20struct WebPluginParams; 21} 22 23namespace content { 24class ContextMenuClient; 25class RenderView; 26struct ContextMenuParams; 27struct WebPluginInfo; 28 29// This interface wraps functionality, which is specific to frames, such as 30// navigation. It provides communication with a corresponding RenderFrameHost 31// in the browser process. 32class CONTENT_EXPORT RenderFrame : public IPC::Listener, 33 public IPC::Sender { 34 public: 35 // Returns the RenderFrame given a WebFrame. 36 static RenderFrame* FromWebFrame(blink::WebFrame* web_frame); 37 38 // Returns the RenderView associated with this frame. 39 virtual RenderView* GetRenderView() = 0; 40 41 // Get the routing ID of the frame. 42 virtual int GetRoutingID() = 0; 43 44 // Returns the associated WebFrame. 45 virtual blink::WebFrame* GetWebFrame() = 0; 46 47 // Gets WebKit related preferences associated with this frame. 48 virtual WebPreferences& GetWebkitPreferences() = 0; 49 50 // Shows a context menu with the given information. The given client will 51 // be called with the result. 52 // 53 // The request ID will be returned by this function. This is passed to the 54 // client functions for identification. 55 // 56 // If the client is destroyed, CancelContextMenu() should be called with the 57 // request ID returned by this function. 58 // 59 // Note: if you end up having clients outliving the RenderFrame, we should add 60 // a CancelContextMenuCallback function that takes a request id. 61 virtual int ShowContextMenu(ContextMenuClient* client, 62 const ContextMenuParams& params) = 0; 63 64 // Cancels a context menu in the event that the client is destroyed before the 65 // menu is closed. 66 virtual void CancelContextMenu(int request_id) = 0; 67 68 // Gets the node that the context menu was pressed over. 69 virtual blink::WebNode GetContextMenuNode() const = 0; 70 71 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no 72 // plugin was found. 73 virtual blink::WebPlugin* CreatePlugin( 74 blink::WebFrame* frame, 75 const WebPluginInfo& info, 76 const blink::WebPluginParams& params) = 0; 77 78 // The client should handle the navigation externally. 79 virtual void LoadURLExternally( 80 blink::WebFrame* frame, 81 const blink::WebURLRequest& request, 82 blink::WebNavigationPolicy policy) = 0; 83 84 protected: 85 virtual ~RenderFrame() {} 86 87 private: 88 // This interface should only be implemented inside content. 89 friend class RenderFrameImpl; 90 RenderFrame() {} 91}; 92 93} // namespace content 94 95#endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ 96