Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / content / public / renderer / render_frame.h
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 "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"
13
14 namespace blink {
15 class WebFrame;
16 class WebLocalFrame;
17 class WebNode;
18 class WebPlugin;
19 class WebURLRequest;
20 class WebURLResponse;
21 struct WebPluginParams;
22 }
23
24 namespace gfx {
25 class Range;
26 }
27
28 namespace v8 {
29 template <typename T> class Handle;
30 class Context;
31 class Isolate;
32 }
33
34 namespace content {
35 class ContextMenuClient;
36 class RenderView;
37 class ServiceRegistry;
38 struct ContextMenuParams;
39 struct WebPluginInfo;
40 struct WebPreferences;
41
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,
46                                    public IPC::Sender {
47  public:
48   // Returns the RenderFrame given a WebFrame.
49   static RenderFrame* FromWebFrame(blink::WebFrame* web_frame);
50
51   // Returns the RenderView associated with this frame.
52   virtual RenderView* GetRenderView() = 0;
53
54   // Get the routing ID of the frame.
55   virtual int GetRoutingID() = 0;
56
57   // Returns the associated WebFrame.
58   virtual blink::WebLocalFrame* GetWebFrame() = 0;
59
60    // Gets WebKit related preferences associated with this frame.
61   virtual WebPreferences& GetWebkitPreferences() = 0;
62
63   // Shows a context menu with the given information. The given client will
64   // be called with the result.
65   //
66   // The request ID will be returned by this function. This is passed to the
67   // client functions for identification.
68   //
69   // If the client is destroyed, CancelContextMenu() should be called with the
70   // request ID returned by this function.
71   //
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;
76
77   // Cancels a context menu in the event that the client is destroyed before the
78   // menu is closed.
79   virtual void CancelContextMenu(int request_id) = 0;
80
81   // Gets the node that the context menu was pressed over.
82   virtual blink::WebNode GetContextMenuNode() const = 0;
83
84   // Create a new NPAPI/Pepper plugin depending on |info|. Returns NULL if no
85   // plugin was found.
86   virtual blink::WebPlugin* CreatePlugin(
87       blink::WebFrame* frame,
88       const WebPluginInfo& info,
89       const blink::WebPluginParams& params) = 0;
90
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;
95
96   // Execute a string of JavaScript in this frame's context.
97   virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
98
99   // Return true if this frame is hidden.
100   virtual bool IsHidden() = 0;
101
102   // Returns the ServiceRegistry for this frame.
103   virtual ServiceRegistry* GetServiceRegistry() = 0;
104
105   // Returns true if this frame is a FTP directory listing.
106   virtual bool IsFTPDirectoryListing() = 0;
107
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;
111
112   // Notifies the browser of text selection changes made.
113   virtual void SetSelectedText(const base::string16& selection_text,
114                                size_t offset,
115                                const gfx::Range& range) = 0;
116
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;
121
122  protected:
123   ~RenderFrame() override {}
124
125  private:
126   // This interface should only be implemented inside content.
127   friend class RenderFrameImpl;
128   RenderFrame() {}
129 };
130
131 }  // namespace content
132
133 #endif  // CONTENT_PUBLIC_RENDERER_RENDER_FRAME_H_