Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / renderer / render_frame.h
blob6627363e0c0ad8abf334fa410b823d85f5800207
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 v8 {
35 template <typename T> class Local;
36 class Context;
37 class Isolate;
40 namespace content {
41 class ContextMenuClient;
42 class PluginInstanceThrottler;
43 class RenderView;
44 class ServiceRegistry;
45 struct ContextMenuParams;
46 struct WebPluginInfo;
47 struct WebPreferences;
49 // This interface wraps functionality, which is specific to frames, such as
50 // navigation. It provides communication with a corresponding RenderFrameHost
51 // in the browser process.
52 class CONTENT_EXPORT RenderFrame : public IPC::Listener,
53 public IPC::Sender {
54 public:
55 // Returns the RenderFrame given a WebFrame.
56 static RenderFrame* FromWebFrame(blink::WebFrame* web_frame);
58 // Returns the RenderFrame given a routing id.
59 static RenderFrame* FromRoutingID(int routing_id);
61 // Returns the RenderView associated with this frame.
62 virtual RenderView* GetRenderView() = 0;
64 // Get the routing ID of the frame.
65 virtual int GetRoutingID() = 0;
67 // Returns the associated WebFrame.
68 virtual blink::WebLocalFrame* GetWebFrame() = 0;
70 // Gets the focused element. If no such element exists then
71 // the element will be Null.
72 virtual blink::WebElement GetFocusedElement() const = 0;
74 // Gets WebKit related preferences associated with this frame.
75 virtual WebPreferences& GetWebkitPreferences() = 0;
77 // Shows a context menu with the given information. The given client will
78 // be called with the result.
80 // The request ID will be returned by this function. This is passed to the
81 // client functions for identification.
83 // If the client is destroyed, CancelContextMenu() should be called with the
84 // request ID returned by this function.
86 // Note: if you end up having clients outliving the RenderFrame, we should add
87 // a CancelContextMenuCallback function that takes a request id.
88 virtual int ShowContextMenu(ContextMenuClient* client,
89 const ContextMenuParams& params) = 0;
91 // Cancels a context menu in the event that the client is destroyed before the
92 // menu is closed.
93 virtual void CancelContextMenu(int request_id) = 0;
95 // Gets the node that the context menu was pressed over.
96 virtual blink::WebNode GetContextMenuNode() const = 0;
98 // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
99 // plugin was found. |throttler| may be empty.
100 virtual blink::WebPlugin* CreatePlugin(
101 blink::WebFrame* frame,
102 const WebPluginInfo& info,
103 const blink::WebPluginParams& params,
104 scoped_ptr<PluginInstanceThrottler> throttler) = 0;
106 // The client should handle the navigation externally.
107 virtual void LoadURLExternally(blink::WebLocalFrame* frame,
108 const blink::WebURLRequest& request,
109 blink::WebNavigationPolicy policy) = 0;
111 // Execute a string of JavaScript in this frame's context.
112 virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
114 // Return true if this frame is hidden.
115 virtual bool IsHidden() = 0;
117 // Returns the ServiceRegistry for this frame.
118 virtual ServiceRegistry* GetServiceRegistry() = 0;
120 #if defined(ENABLE_PLUGINS)
121 // Registers a plugin that has been marked peripheral. If the origin
122 // whitelist is later updated and includes |content_origin|, then
123 // |unthrottle_callback| will be called.
124 virtual void RegisterPeripheralPlugin(
125 const GURL& content_origin,
126 const base::Closure& unthrottle_callback) = 0;
127 #endif
129 // Returns true if this frame is a FTP directory listing.
130 virtual bool IsFTPDirectoryListing() = 0;
132 // Attaches the browser plugin identified by |element_instance_id| to guest
133 // content created by the embedder.
134 virtual void AttachGuest(int element_instance_id) = 0;
136 // Detaches the browser plugin identified by |element_instance_id| from guest
137 // content created by the embedder.
138 virtual void DetachGuest(int element_instance_id) = 0;
140 // Notifies the browser of text selection changes made.
141 virtual void SetSelectedText(const base::string16& selection_text,
142 size_t offset,
143 const gfx::Range& range) = 0;
145 // Ensures that builtin mojo bindings modules are available in |context|.
146 virtual void EnsureMojoBuiltinsAreAvailable(
147 v8::Isolate* isolate,
148 v8::Local<v8::Context> context) = 0;
150 // Adds |message| to the DevTools console.
151 virtual void AddMessageToConsole(ConsoleMessageLevel level,
152 const std::string& message) = 0;
154 protected:
155 ~RenderFrame() override {}
157 private:
158 // This interface should only be implemented inside content.
159 friend class RenderFrameImpl;
160 RenderFrame() {}
163 } // namespace content
165 #endif // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_