render_frame.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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 WebPlugin; 18class WebURLRequest; 19struct WebPluginParams; 20} 21 22namespace content { 23class ContextMenuClient; 24class RenderView; 25struct ContextMenuParams; 26struct WebPluginInfo; 27 28// This interface wraps functionality, which is specific to frames, such as 29// navigation. It provides communication with a corresponding RenderFrameHost 30// in the browser process. 31class CONTENT_EXPORT RenderFrame : public IPC::Listener, 32 public IPC::Sender { 33 public: 34 // Returns the RenderFrame given a WebFrame. 35 static RenderFrame* FromWebFrame(blink::WebFrame* web_frame); 36 37 // Returns the RenderView associated with this frame. 38 virtual RenderView* GetRenderView() = 0; 39 40 // Get the routing ID of the frame. 41 virtual int GetRoutingID() = 0; 42 43 // Returns the associated WebFrame. 44 virtual blink::WebFrame* GetWebFrame() = 0; 45 46 // Gets WebKit related preferences associated with this frame. 47 virtual WebPreferences& GetWebkitPreferences() = 0; 48 49 // Shows a context menu with the given information. The given client will 50 // be called with the result. 51 // 52 // The request ID will be returned by this function. This is passed to the 53 // client functions for identification. 54 // 55 // If the client is destroyed, CancelContextMenu() should be called with the 56 // request ID returned by this function. 57 // 58 // Note: if you end up having clients outliving the RenderFrame, we should add 59 // a CancelContextMenuCallback function that takes a request id. 60 virtual int ShowContextMenu(ContextMenuClient* client, 61 const ContextMenuParams& params) = 0; 62 63 // Cancels a context menu in the event that the client is destroyed before the 64 // menu is closed. 65 virtual void CancelContextMenu(int request_id) = 0; 66 67 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no 68 // plugin was found. 69 virtual blink::WebPlugin* CreatePlugin( 70 blink::WebFrame* frame, 71 const WebPluginInfo& info, 72 const blink::WebPluginParams& params) = 0; 73 74 // The client should handle the navigation externally. 75 virtual void LoadURLExternally( 76 blink::WebFrame* frame, 77 const blink::WebURLRequest& request, 78 blink::WebNavigationPolicy policy) = 0; 79 80 protected: 81 virtual ~RenderFrame() {} 82 83 private: 84 // This interface should only be implemented inside content. 85 friend class RenderFrameImpl; 86 RenderFrame() {} 87}; 88 89} // namespace content 90 91#endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_ 92