Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / public / browser / render_frame_host.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_BROWSER_RENDER_FRAME_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "content/common/content_export.h"
12 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_sender.h"
14 #include "ui/gfx/native_widget_types.h"
15 #include "url/gurl.h"
16
17 namespace base {
18 class Value;
19 }
20
21 namespace content {
22 class RenderProcessHost;
23 class RenderViewHost;
24 class SiteInstance;
25
26 // The interface provides a communication conduit with a frame in the renderer.
27 class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
28                                        public IPC::Sender {
29  public:
30   // Returns the RenderFrameHost given its ID and the ID of its render process.
31   // Returns NULL if the IDs do not correspond to a live RenderFrameHost.
32   static RenderFrameHost* FromID(int render_process_id, int render_frame_id);
33
34   virtual ~RenderFrameHost() {}
35
36   // Returns the route id for this frame.
37   virtual int GetRoutingID() = 0;
38
39   // Returns the SiteInstance grouping all RenderFrameHosts that have script
40   // access to this RenderFrameHost, and must therefore live in the same
41   // process.
42   virtual SiteInstance* GetSiteInstance() = 0;
43
44   // Returns the process for this frame.
45   virtual RenderProcessHost* GetProcess() = 0;
46
47   // Returns the current RenderFrameHost of the parent frame, or NULL if there
48   // is no parent. The result may be in a different process than the current
49   // RenderFrameHost.
50   virtual RenderFrameHost* GetParent() = 0;
51
52   // Returns the assigned name of the frame, the name of the iframe tag
53   // declaring it. For example, <iframe name="framename">[...]</iframe>. It is
54   // quite possible for a frame to have no name, in which case GetFrameName will
55   // return an empty string.
56   virtual const std::string& GetFrameName() = 0;
57
58   // Returns true if the frame is out of process.
59   virtual bool IsCrossProcessSubframe() = 0;
60
61   // Returns the last committed URL of the frame.
62   virtual GURL GetLastCommittedURL() = 0;
63
64   // Returns the associated widget's native view.
65   virtual gfx::NativeView GetNativeView() = 0;
66
67   // Runs some JavaScript in this frame's context. If a callback is provided, it
68   // will be used to return the result, when the result is available.
69   typedef base::Callback<void(const base::Value*)> JavaScriptResultCallback;
70   virtual void ExecuteJavaScript(const base::string16& javascript) = 0;
71   virtual void ExecuteJavaScript(const base::string16& javascript,
72                                  const JavaScriptResultCallback& callback) = 0;
73
74   // Temporary until we get rid of RenderViewHost.
75   virtual RenderViewHost* GetRenderViewHost() = 0;
76
77  private:
78   // This interface should only be implemented inside content.
79   friend class RenderFrameHostImpl;
80   RenderFrameHost() {}
81 };
82
83 }  // namespace content
84
85 #endif  // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_