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.
5 #ifndef CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
6 #define CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_
8 #include "base/strings/string16.h"
9 #include "content/common/content_export.h"
10 #include "ipc/ipc_listener.h"
11 #include "ipc/ipc_sender.h"
12 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
21 struct WebPluginParams
;
25 class ContextMenuClient
;
27 class ServiceRegistry
;
28 struct ContextMenuParams
;
30 struct WebPreferences
;
32 // This interface wraps functionality, which is specific to frames, such as
33 // navigation. It provides communication with a corresponding RenderFrameHost
34 // in the browser process.
35 class CONTENT_EXPORT RenderFrame
: public IPC::Listener
,
38 // Returns the RenderFrame given a WebFrame.
39 static RenderFrame
* FromWebFrame(blink::WebFrame
* web_frame
);
41 // Returns the RenderView associated with this frame.
42 virtual RenderView
* GetRenderView() = 0;
44 // Get the routing ID of the frame.
45 virtual int GetRoutingID() = 0;
47 // Returns the associated WebFrame.
48 virtual blink::WebLocalFrame
* GetWebFrame() = 0;
50 // Gets WebKit related preferences associated with this frame.
51 virtual WebPreferences
& GetWebkitPreferences() = 0;
53 // Shows a context menu with the given information. The given client will
54 // be called with the result.
56 // The request ID will be returned by this function. This is passed to the
57 // client functions for identification.
59 // If the client is destroyed, CancelContextMenu() should be called with the
60 // request ID returned by this function.
62 // Note: if you end up having clients outliving the RenderFrame, we should add
63 // a CancelContextMenuCallback function that takes a request id.
64 virtual int ShowContextMenu(ContextMenuClient
* client
,
65 const ContextMenuParams
& params
) = 0;
67 // Cancels a context menu in the event that the client is destroyed before the
69 virtual void CancelContextMenu(int request_id
) = 0;
71 // Gets the node that the context menu was pressed over.
72 virtual blink::WebNode
GetContextMenuNode() const = 0;
74 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
76 virtual blink::WebPlugin
* CreatePlugin(
77 blink::WebFrame
* frame
,
78 const WebPluginInfo
& info
,
79 const blink::WebPluginParams
& params
) = 0;
81 // The client should handle the navigation externally.
82 virtual void LoadURLExternally(blink::WebLocalFrame
* frame
,
83 const blink::WebURLRequest
& request
,
84 blink::WebNavigationPolicy policy
) = 0;
86 // Execute a string of JavaScript in this frame's context.
87 virtual void ExecuteJavaScript(const base::string16
& javascript
) = 0;
89 // Return true if this frame is hidden.
90 virtual bool IsHidden() = 0;
92 // Returns the ServiceRegistry for this frame.
93 virtual ServiceRegistry
* GetServiceRegistry() = 0;
95 // Returns true if this frame is a FTP directory listing.
96 virtual bool IsFTPDirectoryListing() = 0;
98 // Attaches the browser plugin identified by |element_instance_id| to guest
99 // content created by the embedder.
100 virtual void AttachGuest(int element_instance_id
) = 0;
103 virtual ~RenderFrame() {}
106 // This interface should only be implemented inside content.
107 friend class RenderFrameImpl
;
111 } // namespace content
113 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_