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;
29 template <typename T> class Handle;
35 class ContextMenuClient;
37 class ServiceRegistry;
38 struct ContextMenuParams;
40 struct WebPreferences;
42 // This interface wraps functionality, which is specific to frames, such as
43 // navigation. It provides communication with a corresponding RenderFrameHost
44 // in the browser process.
45 class CONTENT_EXPORT RenderFrame : public IPC::Listener,
48 // Returns the RenderFrame given a WebFrame.
49 static RenderFrame* FromWebFrame(blink::WebFrame* web_frame);
51 // Returns the RenderView associated with this frame.
52 virtual RenderView* GetRenderView() = 0;
54 // Get the routing ID of the frame.
55 virtual int GetRoutingID() = 0;
57 // Returns the associated WebFrame.
58 virtual blink::WebLocalFrame* GetWebFrame() = 0;
60 // Gets WebKit related preferences associated with this frame.
61 virtual WebPreferences& GetWebkitPreferences() = 0;
63 // Shows a context menu with the given information. The given client will
64 // be called with the result.
66 // The request ID will be returned by this function. This is passed to the
67 // client functions for identification.
69 // If the client is destroyed, CancelContextMenu() should be called with the
70 // request ID returned by this function.
72 // Note: if you end up having clients outliving the RenderFrame, we should add
73 // a CancelContextMenuCallback function that takes a request id.
74 virtual int ShowContextMenu(ContextMenuClient* client,
75 const ContextMenuParams& params) = 0;
77 // Cancels a context menu in the event that the client is destroyed before the
79 virtual void CancelContextMenu(int request_id) = 0;
81 // Gets the node that the context menu was pressed over.
82 virtual blink::WebNode GetContextMenuNode() const = 0;
84 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
86 virtual blink::WebPlugin* CreatePlugin(
87 blink::WebFrame* frame,
88 const WebPluginInfo& info,
89 const blink::WebPluginParams& params) = 0;
91 // The client should handle the navigation externally.
92 virtual void LoadURLExternally(blink::WebLocalFrame* frame,
93 const blink::WebURLRequest& request,
94 blink::WebNavigationPolicy policy) = 0;
96 // Execute a string of JavaScript in this frame's context.
97 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
99 // Return true if this frame is hidden.
100 virtual bool IsHidden() = 0;
102 // Returns the ServiceRegistry for this frame.
103 virtual ServiceRegistry* GetServiceRegistry() = 0;
105 // Returns true if this frame is a FTP directory listing.
106 virtual bool IsFTPDirectoryListing() = 0;
108 // Attaches the browser plugin identified by |element_instance_id| to guest
109 // content created by the embedder.
110 virtual void AttachGuest(int element_instance_id) = 0;
112 // Notifies the browser of text selection changes made.
113 virtual void SetSelectedText(const base::string16& selection_text,
115 const gfx::Range& range) = 0;
117 // Ensures that builtin mojo bindings modules are available in |context|.
118 virtual void EnsureMojoBuiltinsAreAvailable(
119 v8::Isolate* isolate,
120 v8::Handle<v8::Context> context) = 0;
123 ~RenderFrame() override {}
126 // This interface should only be implemented inside content.
127 friend class RenderFrameImpl;
131 } // namespace content
133 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_