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_BROWSER_RENDER_FRAME_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_
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"
22 class RenderProcessHost;
26 // The interface provides a communication conduit with a frame in the renderer.
27 class CONTENT_EXPORT RenderFrameHost : public IPC::Listener,
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);
34 virtual ~RenderFrameHost() {}
36 // Returns the route id for this frame.
37 virtual int GetRoutingID() = 0;
39 // Returns the SiteInstance grouping all RenderFrameHosts that have script
40 // access to this RenderFrameHost, and must therefore live in the same
42 virtual SiteInstance* GetSiteInstance() = 0;
44 // Returns the process for this frame.
45 virtual RenderProcessHost* GetProcess() = 0;
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
50 virtual RenderFrameHost* GetParent() = 0;
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;
58 // Returns true if the frame is out of process.
59 virtual bool IsCrossProcessSubframe() = 0;
61 // Returns the last committed URL of the frame.
62 virtual GURL GetLastCommittedURL() = 0;
64 // Returns the associated widget's native view.
65 virtual gfx::NativeView GetNativeView() = 0;
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;
74 // Temporary until we get rid of RenderViewHost.
75 virtual RenderViewHost* GetRenderViewHost() = 0;
78 // This interface should only be implemented inside content.
79 friend class RenderFrameHostImpl;
83 } // namespace content
85 #endif // CONTENT_PUBLIC_BROWSER_RENDER_FRAME_HOST_H_