Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / content / public / renderer / render_frame.h
blob4bb763bbeb06fda3974c6d5a101b80ce8323db33
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/callback_forward.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "content/common/content_export.h"
12 #include "content/public/common/console_message_level.h"
13 #include "ipc/ipc_listener.h"
14 #include "ipc/ipc_sender.h"
15 #include "third_party/WebKit/public/web/WebNavigationPolicy.h"
17 class GURL;
19 namespace blink {
20 class WebElement;
21 class WebFrame;
22 class WebLocalFrame;
23 class WebNode;
24 class WebPlugin;
25 class WebURLRequest;
26 class WebURLResponse;
27 struct WebPluginParams;
30 namespace gfx {
31 class Range;
34 namespace url {
35 class Origin;
38 namespace v8 {
39 template <typename T> class Local;
40 class Context;
41 class Isolate;
44 namespace content {
45 class ContextMenuClient;
46 class PluginInstanceThrottler;
47 class RenderView;
48 class ServiceRegistry;
49 struct ContextMenuParams;
50 struct WebPluginInfo;
51 struct WebPreferences;
53 // This interface wraps functionality, which is specific to frames, such as
54 // navigation. It provides communication with a corresponding RenderFrameHost
55 // in the browser process.
56 class CONTENT_EXPORT RenderFrame : public IPC::Listener,
57 public IPC::Sender {
58 public:
59 // Returns the RenderFrame given a WebFrame.
60 static RenderFrame* FromWebFrame(blink::WebFrame* web_frame);
62 // Returns the RenderFrame given a routing id.
63 static RenderFrame* FromRoutingID(int routing_id);
65 // Returns the RenderView associated with this frame.
66 virtual RenderView* GetRenderView() = 0;
68 // Get the routing ID of the frame.
69 virtual int GetRoutingID() = 0;
71 // Returns the associated WebFrame.
72 virtual blink::WebLocalFrame* GetWebFrame() = 0;
74 // Gets the focused element. If no such element exists then
75 // the element will be Null.
76 virtual blink::WebElement GetFocusedElement() const = 0;
78 // Gets WebKit related preferences associated with this frame.
79 virtual WebPreferences& GetWebkitPreferences() = 0;
81 // Shows a context menu with the given information. The given client will
82 // be called with the result.
84 // The request ID will be returned by this function. This is passed to the
85 // client functions for identification.
87 // If the client is destroyed, CancelContextMenu() should be called with the
88 // request ID returned by this function.
90 // Note: if you end up having clients outliving the RenderFrame, we should add
91 // a CancelContextMenuCallback function that takes a request id.
92 virtual int ShowContextMenu(ContextMenuClient* client,
93 const ContextMenuParams& params) = 0;
95 // Cancels a context menu in the event that the client is destroyed before the
96 // menu is closed.
97 virtual void CancelContextMenu(int request_id) = 0;
99 // Gets the node that the context menu was pressed over.
100 virtual blink::WebNode GetContextMenuNode() const = 0;
102 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
103 // plugin was found. |throttler| may be empty.
104 virtual blink::WebPlugin* CreatePlugin(
105 blink::WebFrame* frame,
106 const WebPluginInfo& info,
107 const blink::WebPluginParams& params,
108 scoped_ptr<PluginInstanceThrottler> throttler) = 0;
110 // The client should handle the navigation externally.
111 virtual void LoadURLExternally(blink::WebLocalFrame* frame,
112 const blink::WebURLRequest& request,
113 blink::WebNavigationPolicy policy) = 0;
115 // Execute a string of JavaScript in this frame's context.
116 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
118 // Return true if this frame is hidden.
119 virtual bool IsHidden() = 0;
121 // Returns the ServiceRegistry for this frame.
122 virtual ServiceRegistry* GetServiceRegistry() = 0;
124 #if defined(ENABLE_PLUGINS)
125 // Registers a plugin that has been marked peripheral. If the origin
126 // whitelist is later updated and includes |content_origin|, then
127 // |unthrottle_callback| will be called.
128 virtual void RegisterPeripheralPlugin(
129 const url::Origin& content_origin,
130 const base::Closure& unthrottle_callback) = 0;
131 #endif
133 // Returns true if this frame is a FTP directory listing.
134 virtual bool IsFTPDirectoryListing() = 0;
136 // Attaches the browser plugin identified by |element_instance_id| to guest
137 // content created by the embedder.
138 virtual void AttachGuest(int element_instance_id) = 0;
140 // Detaches the browser plugin identified by |element_instance_id| from guest
141 // content created by the embedder.
142 virtual void DetachGuest(int element_instance_id) = 0;
144 // Notifies the browser of text selection changes made.
145 virtual void SetSelectedText(const base::string16& selection_text,
146 size_t offset,
147 const gfx::Range& range) = 0;
149 // Ensures that builtin mojo bindings modules are available in |context|.
150 virtual void EnsureMojoBuiltinsAreAvailable(
151 v8::Isolate* isolate,
152 v8::Local<v8::Context> context) = 0;
154 // Adds |message| to the DevTools console.
155 virtual void AddMessageToConsole(ConsoleMessageLevel level,
156 const std::string& message) = 0;
158 protected:
159 ~RenderFrame() override {}
161 private:
162 // This interface should only be implemented inside content.
163 friend class RenderFrameImpl;
164 RenderFrame() {}
167 } // namespace content
169 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_